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 metadata for a given entity. If a valid entity is returned,
82 * the provider will be left in a locked state. The caller MUST unlock the
83 * provider when finished with the entity.
85 * @param id the ID of the entity
86 * @param requireValidMetadata indicates whether the metadata for the entity must be valid/current
88 * @return the entity's metadata or NULL if there is no metadata or no valid metadata
90 virtual const EntityDescriptor* lookup(const XMLCh* id, bool requireValidMetadata=true) const=0;
93 * Gets the metadata for a given entity. If a valid entity is returned,
94 * the provider will be left in a locked state. The caller MUST unlock the
95 * provider when finished with the entity.
97 * @param id the ID of the entity
98 * @param requireValidMetadata indicates whether the metadata for the entity must be valid/current
100 * @return the entity's metadata or NULL if there is no metadata or no valid metadata
102 virtual const EntityDescriptor* lookup(const char* id, bool requireValidMetadata=true) const=0;
105 * Gets the metadata for a given group of entities. If a valid group is returned,
106 * the resolver will be left in a locked state. The caller MUST unlock the
107 * resolver when finished with the group.
109 * @param name the name of the group
110 * @param requireValidMetadata indicates whether the metadata for the group must be valid/current
112 * @return the group's metadata or NULL if there is no metadata or no valid metadata
114 virtual const EntitiesDescriptor* lookupGroup(const XMLCh* name, bool requireValidMetadata=true) const=0;
117 * Gets the metadata for a given group of entities. If a valid group is returned,
118 * the resolver will be left in a locked state. The caller MUST unlock the
119 * resolver when finished with the group.
121 * @param name the name of the group
122 * @param requireValidMetadata indicates whether the metadata for the group must be valid/current
124 * @return the group's metadata or NULL if there is no metadata or no valid metadata
126 virtual const EntitiesDescriptor* lookupGroup(const char* name, bool requireValidMetadata=true) const=0;
129 MetadataFilter* m_filter;
133 * Registers MetadataProvider classes into the runtime.
135 void SAML_API registerMetadataProviders();
137 /** MetadataProvider based on local XML files */
138 #define FILESYSTEM_METADATA_PROVIDER "org.opensaml.saml2.metadata.provider.FilesystemMetadataProvider"
142 #endif /* __saml2_metadataprov_h__ */