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 * @file saml/saml2/metadata/ChainingMetadataProvider.h
20 * MetadataProvider that uses multiple providers in sequence.
23 #ifndef __saml_chainmeta_h__
24 #define __saml_chainmeta_h__
26 #include <saml/saml2/metadata/ObservableMetadataProvider.h>
27 #include <xmltooling/logging.h>
28 #include <xmltooling/util/Threads.h>
33 #if defined (_MSC_VER)
34 #pragma warning( push )
35 #pragma warning( disable : 4251 )
39 * MetadataProvider that uses multiple providers in sequence.
41 class SAML_API ChainingMetadataProvider
42 : public ObservableMetadataProvider, public ObservableMetadataProvider::Observer {
47 * If a DOM is supplied, the following XML content is supported:
50 * <li><MetadataProvider> elements with a type attribute
53 * XML namespaces are ignored in the processing of this content.
55 * @param e DOM to supply configuration for provider
57 ChainingMetadataProvider(const xercesc::DOMElement* e=NULL);
60 * Destructor will delete any embedded engines.
62 virtual ~ChainingMetadataProvider();
65 * Adds a provider for future calls. The provider <strong>MUST</strong> be
66 * initialized before adding it.
68 * @param newProvider provider to add
70 void addMetadataProvider(MetadataProvider* newProvider) {
71 m_providers.push_back(newProvider);
75 * Removes a provider. The caller must delete the provider if necessary.
77 * @param oldProvider provider to remove
78 * @return the old provider
80 MetadataProvider* removeMetadataProvider(MetadataProvider* oldProvider) {
81 for (std::vector<MetadataProvider*>::iterator i=m_providers.begin(); i!=m_providers.end(); i++) {
82 if (oldProvider==(*i)) {
90 using MetadataProvider::getEntityDescriptor;
91 using MetadataProvider::getEntitiesDescriptor;
93 xmltooling::Lockable* lock();
96 const xmltooling::XMLObject* getMetadata() const;
97 const EntitiesDescriptor* getEntitiesDescriptor(const char* name, bool requireValidMetadata=true) const;
98 std::pair<const EntityDescriptor*,const RoleDescriptor*> getEntityDescriptor(const Criteria& criteria) const;
99 void onEvent(const ObservableMetadataProvider& provider) const;
101 const xmltooling::Credential* resolve(const xmltooling::CredentialCriteria* criteria=NULL) const;
102 std::vector<const xmltooling::Credential*>::size_type resolve(
103 std::vector<const xmltooling::Credential*>& results, const xmltooling::CredentialCriteria* criteria=NULL
108 xmltooling::ThreadKey* m_tlsKey;
109 std::vector<MetadataProvider*> m_providers;
110 xmltooling::logging::Category& m_log;
113 #if defined (_MSC_VER)
114 #pragma warning( pop )
120 #endif /* __saml_chainmeta_h__ */