2 * Copyright 2001-2006 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 MetadataProvider.h
20 * Supplies an individual source of metadata.
23 #ifndef __saml2_metadataprov_h__
24 #define __saml2_metadataprov_h__
26 #include <xmltooling/Lockable.h>
27 #include <saml/saml2/metadata/MetadataFilter.h>
34 * Supplies an individual source of metadata.
36 * The source can be a local file, remote service, or the result of a
37 * dynamic lookup, can include local caching, etc.
39 class SAML_API MetadataProvider : public virtual xmltooling::Lockable
41 MAKE_NONCOPYABLE(MetadataProvider);
43 MetadataProvider() : m_filter(NULL) {}
46 virtual ~MetadataProvider() {
51 * Gets the metadata filter applied to the resolved metadata.
53 * @return the metadata filter applied to the resolved metadata
55 const MetadataFilter* getMetadataFilter() const {
60 * Sets the metadata filter applied to the resolved metadata.
62 * @param newFilter the metadata filter applied to the resolved metadata
64 void setMetadataFilter(MetadataFilter* newFilter) {
70 * Should be called after instantiating provider and setting filter, but before
71 * performing any lookup operations. Allows the provider to defer initialization
72 * processes that are likely to result in exceptions until after the provider is
73 * safely created. Providers SHOULD perform as much processing as possible in
74 * this method so as to report/log any errors that would affect later processing.
75 * Also, any inputs supplied to the factory MUST persist until the completion of
76 * this method, but the caller is then free to modify or delete them.
78 virtual void init()=0;
81 * Gets the entire metadata tree, after the registered filter has been applied.
82 * The caller MUST unlock the provider when finished with the data.
84 * @return the entire metadata tree
86 virtual const xmltooling::XMLObject* getMetadata() const=0;
89 * Gets the metadata for a given entity. If a valid entity is returned,
90 * the provider will be left in a locked state. The caller MUST unlock the
91 * provider when finished with the entity.
93 * @param id the ID of the entity
94 * @param requireValidMetadata indicates whether the metadata for the entity must be valid/current
96 * @return the entity's metadata or NULL if there is no metadata or no valid metadata
98 virtual const EntityDescriptor* getEntityDescriptor(const XMLCh* id, bool requireValidMetadata=true) const=0;
101 * Gets the metadata for a given entity. If a valid entity is returned,
102 * the provider will be left in a locked state. The caller MUST unlock the
103 * provider when finished with the entity.
105 * @param id the ID of the entity
106 * @param requireValidMetadata indicates whether the metadata for the entity must be valid/current
108 * @return the entity's metadata or NULL if there is no metadata or no valid metadata
110 virtual const EntityDescriptor* getEntityDescriptor(const char* id, bool requireValidMetadata=true) const=0;
113 * Gets the metadata for a given group of entities. If a valid group is returned,
114 * the resolver will be left in a locked state. The caller MUST unlock the
115 * resolver when finished with the group.
117 * @param name the name of the group
118 * @param requireValidMetadata indicates whether the metadata for the group must be valid/current
120 * @return the group's metadata or NULL if there is no metadata or no valid metadata
122 virtual const EntitiesDescriptor* getEntitiesDescriptor(const XMLCh* name, bool requireValidMetadata=true) const=0;
125 * Gets the metadata for a given group of entities. If a valid group is returned,
126 * the resolver will be left in a locked state. The caller MUST unlock the
127 * resolver when finished with the group.
129 * @param name the name of the group
130 * @param requireValidMetadata indicates whether the metadata for the group must be valid/current
132 * @return the group's metadata or NULL if there is no metadata or no valid metadata
134 virtual const EntitiesDescriptor* getEntitiesDescriptor(const char* name, bool requireValidMetadata=true) const=0;
137 MetadataFilter* m_filter;
141 * Registers MetadataProvider classes into the runtime.
143 void SAML_API registerMetadataProviders();
145 /** MetadataProvider based on local XML files */
146 #define FILESYSTEM_METADATA_PROVIDER "org.opensaml.saml2.metadata.provider.FilesystemMetadataProvider"
150 #endif /* __saml2_metadataprov_h__ */