X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-opensaml.git;a=blobdiff_plain;f=saml%2Fsaml2%2Fmetadata%2FMetadataProvider.h;h=05d2493f62f89d3f99cffaea9285d0b78731f11e;hp=beced6ed1f1a4feea510b76791354cbc0182c609;hb=208928133db000b055b99fcbabc245295adb0d48;hpb=003e73203da5cdf8c3d001a75a56b9e45ef6465b diff --git a/saml/saml2/metadata/MetadataProvider.h b/saml/saml2/metadata/MetadataProvider.h index beced6e..05d2493 100644 --- a/saml/saml2/metadata/MetadataProvider.h +++ b/saml/saml2/metadata/MetadataProvider.h @@ -1,22 +1,26 @@ -/* - * Copyright 2001-2007 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at +/** + * Licensed to the University Corporation for Advanced Internet + * Development, Inc. (UCAID) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. + * + * UCAID licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the + * License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. */ /** * @file saml/saml2/metadata/MetadataProvider.h - * + * * Supplies an individual source of metadata. */ @@ -24,12 +28,20 @@ #define __saml2_metadataprov_h__ #include + +#include +#include +#include #include -#include #include +namespace xmltooling { + class XMLTOOL_API QName; + class XMLTOOL_API XMLObject; +}; + namespace opensaml { - + class SAML_API SAMLArtifact; namespace saml2md { @@ -47,7 +59,7 @@ namespace opensaml { /** * Supplies an individual source of metadata. - * + * * The source can be a local file, remote service, or the result of a * dynamic lookup, can include local caching, etc. Providers * MUST be locked before any lookup operations. @@ -58,59 +70,56 @@ namespace opensaml { protected: /** * Constructor. - * + * * If a DOM is supplied, a set of default logic will be used to identify * and build MetadataFilter plugins and install them into the provider. - * + * * The following XML content is supported: - * + * *
    *
  • <MetadataFilter> elements with a type attribute and type-specific content *
  • <Exclude> elements representing a BlacklistMetadataFilter - *
  • <BlacklistMetadataFilter> element containing <Exclude> elements + *
  • <BlacklistMetadataFilter> element containing <Exclude> elements *
  • <Include> elements representing a WhitelistMetadataFilter - *
  • <SignatureMetadataFilter> element containing a <KeyResolver> element - *
  • <WhitelistMetadataFilter> element containing <Include> elements + *
  • <SignatureMetadataFilter> element containing a <KeyResolver> element + *
  • <WhitelistMetadataFilter> element containing <Include> elements *
- * + * * XML namespaces are ignored in the processing of these elements. - * + * * @param e DOM to supply configuration for provider */ - MetadataProvider(const xercesc::DOMElement* e=NULL); - + MetadataProvider(const xercesc::DOMElement* e=nullptr); + public: /** * Destructor will delete any installed filters. */ virtual ~MetadataProvider(); - + + /** + * Returns an identifier for the provider for logging/status purposes. + * + * @return an identifier, or null + */ + virtual const char* getId() const; + /** * Adds a metadata filter to apply to any resolved metadata. Will not be applied * to metadata that is already loaded. - * + * * @param newFilter metadata filter to add */ - virtual void addMetadataFilter(MetadataFilter* newFilter) { - m_filters.push_back(newFilter); - } + virtual void addMetadataFilter(MetadataFilter* newFilter); /** * Removes a metadata filter. The caller must delete the filter if necessary. - * + * * @param oldFilter metadata filter to remove * @return the old filter */ - virtual MetadataFilter* removeMetadataFilter(MetadataFilter* oldFilter) { - for (std::vector::iterator i=m_filters.begin(); i!=m_filters.end(); i++) { - if (oldFilter==(*i)) { - m_filters.erase(i); - return oldFilter; - } - } - return NULL; - } - + virtual MetadataFilter* removeMetadataFilter(MetadataFilter* oldFilter); + /** * Should be called after instantiating provider and adding filters, but before * performing any lookup operations. Allows the provider to defer initialization @@ -119,24 +128,32 @@ namespace opensaml { * this method so as to report/log any errors that would affect later processing. */ virtual void init()=0; - + + /** + * Generate an XML representation of the provider's status. The XML must be + * well-formed, but is otherwise arbitrary. + * + * @param os stream to write status information to + */ + virtual void outputStatus(std::ostream& os) const; + /** * Gets the entire metadata tree, after the registered filter has been applied. * The caller MUST unlock the provider when finished with the data. - * + * * @return the entire metadata tree */ virtual const xmltooling::XMLObject* getMetadata() const=0; - + /** * Gets the metadata for a given group of entities. If a valid group is returned, * the resolver will be left in a locked state. The caller MUST unlock the * resolver when finished with the group. - * + * * @param name the name of the group * @param requireValidMetadata indicates whether the metadata for the group must be valid/current - * - * @return the group's metadata or NULL if there is no metadata or no valid metadata + * + * @return the group's metadata or nullptr if there is no metadata or no valid metadata */ virtual const EntitiesDescriptor* getEntitiesDescriptor(const XMLCh* name, bool requireValidMetadata=true) const; @@ -144,11 +161,11 @@ namespace opensaml { * Gets the metadata for a given group of entities. If a valid group is returned, * the resolver will be left in a locked state. The caller MUST unlock the * resolver when finished with the group. - * + * * @param name the name of the group * @param requireValidMetadata indicates whether the metadata for the group must be valid/current - * - * @return the group's metadata or NULL if there is no metadata or no valid metadata + * + * @return the group's metadata or nullptr if there is no metadata or no valid metadata */ virtual const EntitiesDescriptor* getEntitiesDescriptor(const char* name, bool requireValidMetadata=true) const=0; @@ -159,47 +176,45 @@ namespace opensaml { /** * Default constructor. */ - Criteria() : entityID_unicode(NULL), entityID_ascii(NULL), artifact(NULL), role(NULL), protocol(NULL), protocol2(NULL), validOnly(true) { - } - + Criteria(); + /** * Constructor. - * + * * @param id entityID to lookup * @param q element/type of role, if any * @param prot protocol support constant, if any * @param valid true iff stale metadata should be ignored */ - Criteria(const XMLCh* id, const xmltooling::QName* q=NULL, const XMLCh* prot=NULL, bool valid=true) - : entityID_unicode(id), entityID_ascii(NULL), artifact(NULL), role(q), protocol(prot), protocol2(NULL), validOnly(valid) { - } - + Criteria(const XMLCh* id, const xmltooling::QName* q=nullptr, const XMLCh* prot=nullptr, bool valid=true); + /** * Constructor. - * + * * @param id entityID to lookup * @param q element/type of role, if any * @param prot protocol support constant, if any * @param valid true iff stale metadata should be ignored */ - Criteria(const char* id, const xmltooling::QName* q=NULL, const XMLCh* prot=NULL, bool valid=true) - : entityID_unicode(NULL), entityID_ascii(id), artifact(NULL), role(q), protocol(prot), protocol2(NULL), validOnly(valid) { - } + Criteria(const char* id, const xmltooling::QName* q=nullptr, const XMLCh* prot=nullptr, bool valid=true); /** * Constructor. - * + * * @param a artifact to lookup * @param q element/type of role, if any * @param prot protocol support constant, if any * @param valid true iff stale metadata should be ignored */ - Criteria(const SAMLArtifact* a, const xmltooling::QName* q=NULL, const XMLCh* prot=NULL, bool valid=true) - : entityID_unicode(NULL), entityID_ascii(NULL), artifact(a), role(q), protocol(prot), protocol2(NULL), validOnly(valid) { - } - - virtual ~Criteria() {} - + Criteria(const SAMLArtifact* a, const xmltooling::QName* q=nullptr, const XMLCh* prot=nullptr, bool valid=true); + + virtual ~Criteria(); + + /** + * Restores the object to its default state. + */ + virtual void reset(); + /** Unique ID of entity. */ const XMLCh* entityID_unicode; /** Unique ID of entity. */ @@ -215,28 +230,28 @@ namespace opensaml { /** Controls whether stale metadata is ignored. */ bool validOnly; }; - + /** * Gets entity metadata based on supplied criteria. If a valid entity is returned, * the provider will be left in a locked state. The caller MUST unlock the * provider when finished with the entity. - * + * * @param criteria lookup criteria - * - * @return the entity's metadata (and optionally a role) or NULL if there is no qualifying metadata + * + * @return the entity's metadata (and optionally a role) or nullptr if there is no qualifying metadata */ virtual std::pair getEntityDescriptor(const Criteria& criteria) const=0; protected: /** * Applies any installed filters to a metadata instance. - * + * * @param xmlObject the metadata to be filtered */ void doFilters(xmltooling::XMLObject& xmlObject) const; private: - std::vector m_filters; + boost::ptr_vector m_filters; }; #if defined (_MSC_VER) @@ -247,7 +262,7 @@ namespace opensaml { * Registers MetadataProvider classes into the runtime. */ void SAML_API registerMetadataProviders(); - + /** MetadataProvider based on local or remote XML file */ #define XML_METADATA_PROVIDER "XML" @@ -257,6 +272,9 @@ namespace opensaml { /** MetadataProvider that wraps a sequence of metadata providers. */ #define CHAINING_METADATA_PROVIDER "Chaining" + /** MetadataProvider that loads a directory of files. */ + #define FOLDER_METADATA_PROVIDER "Folder" + /** MetadataProvider that returns an empty "dummy" entity descriptor. */ #define NULL_METADATA_PROVIDER "Null"