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/AbstractMetadataProvider.h
20 * Base class for caching metadata providers.
23 #ifndef __saml2_absmetadataprov_h__
24 #define __saml2_absmetadataprov_h__
26 #include <saml/saml2/metadata/ObservableMetadataProvider.h>
28 #include <xmltooling/security/Credential.h>
29 #include <xmltooling/security/CredentialCriteria.h>
30 #include <xmltooling/util/Threads.h>
35 class SAML_API MetadataFilter;
38 * Base class for caching metadata providers.
40 class SAML_API AbstractMetadataProvider : public ObservableMetadataProvider
46 * If a DOM is supplied, a set of default logic will be used to identify
47 * and build a KeyInfoResolver plugin and install it into the provider.
49 * The following XML content is supported:
52 * <li><KeyInfoResolver> elements with a type attribute
55 * XML namespaces are ignored in the processing of these elements.
57 * @param e DOM to supply configuration for provider
59 AbstractMetadataProvider(const xercesc::DOMElement* e=NULL);
62 virtual ~AbstractMetadataProvider();
64 using MetadataProvider::getEntityDescriptor;
65 using MetadataProvider::getEntitiesDescriptor;
67 void emitChangeEvent() const;
68 std::pair<const EntityDescriptor*,const RoleDescriptor*> getEntityDescriptor(const Criteria& criteria) const;
69 const EntitiesDescriptor* getEntitiesDescriptor(const char* name, bool requireValidMetadata=true) const;
70 const xmltooling::Credential* resolve(const xmltooling::CredentialCriteria* criteria=NULL) const;
71 std::vector<const xmltooling::Credential*>::size_type resolve(
72 std::vector<const xmltooling::Credential*>& results, const xmltooling::CredentialCriteria* criteria=NULL
76 /** Embedded KeyInfoResolver instance. */
77 xmltooling::KeyInfoResolver* m_resolver;
80 * Loads an entity into the cache for faster lookup. This includes
81 * processing known reverse lookup strategies for artifacts.
83 * @param site entity definition
84 * @param validUntil maximum expiration time of the entity definition
85 * @param replace true iff existing entries for the same entity should be cleared/replaced
87 virtual void index(EntityDescriptor* site, time_t validUntil, bool replace=false) const;
90 * Loads a group of entities into the cache for faster lookup.
92 * @param group group definition
93 * @param validUntil maximum expiration time of the group definition
95 virtual void index(EntitiesDescriptor* group, time_t validUntil) const;
98 * Clear the cache of known entities and groups.
100 * @param freeSites true iff the objects cached in the site map should be freed.
102 virtual void clearDescriptorIndex(bool freeSites=false);
105 typedef std::multimap<std::string,const EntityDescriptor*> sitemap_t;
106 typedef std::multimap<std::string,const EntitiesDescriptor*> groupmap_t;
107 mutable sitemap_t m_sites;
108 mutable sitemap_t m_sources;
109 mutable groupmap_t m_groups;
111 mutable xmltooling::Mutex* m_credentialLock;
112 typedef std::map< const RoleDescriptor*, std::vector<xmltooling::Credential*> > credmap_t;
113 mutable credmap_t m_credentialMap;
114 const credmap_t::mapped_type& resolveCredentials(const RoleDescriptor& role) const;
120 #endif /* __saml2_absmetadataprov_h__ */