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/security/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/util/Threads.h>
32 #if defined (_MSC_VER)
33 #pragma warning( push )
34 #pragma warning( disable : 4251 )
38 * MetadataProvider that uses multiple providers in sequence.
40 class SAML_API ChainingMetadataProvider
41 : public ObservableMetadataProvider, public ObservableMetadataProvider::Observer {
46 * If a DOM is supplied, the following XML content is supported:
49 * <li><MetadataProvider> elements with a type attribute
52 * XML namespaces are ignored in the processing of this content.
54 * @param e DOM to supply configuration for provider
56 ChainingMetadataProvider(const xercesc::DOMElement* e=NULL);
59 * Destructor will delete any embedded engines.
61 virtual ~ChainingMetadataProvider();
64 * Adds a provider for future calls. The provider <strong>MUST</strong> be
65 * initialized before adding it.
67 * @param newProvider provider to add
69 void addMetadataProvider(MetadataProvider* newProvider) {
70 m_providers.push_back(newProvider);
74 * Removes a provider. The caller must delete the provider if necessary.
76 * @param oldProvider provider to remove
77 * @return the old provider
79 MetadataProvider* removeMetadataProvider(MetadataProvider* oldProvider) {
80 for (std::vector<MetadataProvider*>::iterator i=m_providers.begin(); i!=m_providers.end(); i++) {
81 if (oldProvider==(*i)) {
89 xmltooling::Lockable* lock();
92 const xmltooling::XMLObject* getMetadata() const;
93 const EntitiesDescriptor* getEntitiesDescriptor(const char* name, bool requireValidMetadata=true) const;
94 const EntityDescriptor* getEntityDescriptor(const char* id, bool requireValidMetadata=true) const;
95 const EntityDescriptor* getEntityDescriptor(const SAMLArtifact* artifact) const;
96 void onEvent(const ObservableMetadataProvider& provider) const;
98 const xmltooling::Credential* resolve(const xmltooling::CredentialCriteria* criteria=NULL) const;
99 std::vector<const xmltooling::Credential*>::size_type resolve(
100 std::vector<const xmltooling::Credential*>& results, const xmltooling::CredentialCriteria* criteria=NULL
104 xmltooling::ThreadKey* m_tlsKey;
105 std::vector<MetadataProvider*> m_providers;
108 #if defined (_MSC_VER)
109 #pragma warning( pop )
115 #endif /* __saml_chainmeta_h__ */