2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
22 * NullMetadataProvider.cpp
24 * Dummy provider that returns an empty entity supporting any role.
28 #include "saml2/metadata/Metadata.h"
29 #include "saml2/metadata/DynamicMetadataProvider.h"
31 #include <xmltooling/util/XMLHelper.h>
33 using namespace opensaml::saml2md;
34 using namespace xmltooling;
39 class SAML_DLLLOCAL NullMetadataProvider : public DynamicMetadataProvider
42 NullMetadataProvider(const DOMElement* e) : DynamicMetadataProvider(e) {
43 e = XMLHelper::getFirstChildElement(e, samlconstants::SAML20MD_NS, EntityDescriptor::LOCAL_NAME);
45 m_template.reset(dynamic_cast<EntityDescriptor*>(XMLObjectBuilder::buildOneFromElement(const_cast<DOMElement*>(e))));
48 virtual ~NullMetadataProvider() {}
51 EntityDescriptor* resolve(const char* entityID) const;
54 auto_ptr<EntityDescriptor> m_template;
57 MetadataProvider* SAML_DLLLOCAL NullMetadataProviderFactory(const DOMElement* const & e)
59 return new NullMetadataProvider(e);
64 EntityDescriptor* NullMetadataProvider::resolve(const char* entityID) const
66 // Resolving for us just means fabricating a new dummy element.
67 EntityDescriptor* entity = m_template.get() ? m_template->cloneEntityDescriptor() : EntityDescriptorBuilder::buildEntityDescriptor();
68 auto_ptr_XMLCh temp(entityID);
69 entity->setEntityID(temp.get());