2 * Copyright 2001-2007 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * NullMetadataProvider.cpp
20 * Dummy provider that returns an empty entity supporting any role.
24 #include "saml2/metadata/Metadata.h"
25 #include "saml2/metadata/DynamicMetadataProvider.h"
27 #include <xmltooling/util/XMLHelper.h>
29 using namespace opensaml::saml2md;
30 using namespace xmltooling;
35 class SAML_DLLLOCAL NullMetadataProvider : public DynamicMetadataProvider
38 NullMetadataProvider(const DOMElement* e) : DynamicMetadataProvider(e), m_template(NULL) {
39 e = XMLHelper::getFirstChildElement(e, samlconstants::SAML20MD_NS, EntityDescriptor::LOCAL_NAME);
41 m_template = dynamic_cast<EntityDescriptor*>(XMLObjectBuilder::buildOneFromElement(const_cast<DOMElement*>(e)));
44 virtual ~NullMetadataProvider() {
49 EntityDescriptor* resolve(const char* entityID) const;
52 EntityDescriptor* m_template;
55 MetadataProvider* SAML_DLLLOCAL NullMetadataProviderFactory(const DOMElement* const & e)
57 return new NullMetadataProvider(e);
62 EntityDescriptor* NullMetadataProvider::resolve(const char* entityID) const
64 // Resolving for us just means fabricating a new dummy element.
65 EntityDescriptor* entity = m_template ? m_template->cloneEntityDescriptor() : EntityDescriptorBuilder::buildEntityDescriptor();
66 auto_ptr_XMLCh temp(entityID);
67 entity->setEntityID(temp.get());