X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fsaml2%2Fmetadata%2FMetadataProvider.h;h=483d05c7587c1481f6e8b244722a6262c5b23d14;hb=17b312daa349580f67cc07fc190125224146cf14;hp=bc3f164684ee26c4f91fd19e7b1b8c472dbad10b;hpb=01fe9dc618b7e57645b71a23757657102e9ac380;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/saml2/metadata/MetadataProvider.h b/saml/saml2/metadata/MetadataProvider.h index bc3f164..483d05c 100644 --- a/saml/saml2/metadata/MetadataProvider.h +++ b/saml/saml2/metadata/MetadataProvider.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006 Internet2 + * 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. @@ -23,10 +23,10 @@ #ifndef __saml2_metadataprov_h__ #define __saml2_metadataprov_h__ -#include - -#include -#include +#include +#include +#include +#include namespace opensaml { @@ -36,7 +36,15 @@ namespace opensaml { class SAML_API EntityDescriptor; class SAML_API EntitiesDescriptor; - + class SAML_API RoleDescriptor; + class SAML_API MetadataCredentialResolver; + class SAML_API MetadataFilter; + +#if defined (_MSC_VER) + #pragma warning( push ) + #pragma warning( disable : 4251 ) +#endif + /** * Supplies an individual source of metadata. * @@ -44,22 +52,19 @@ namespace opensaml { * dynamic lookup, can include local caching, etc. Providers * MUST be locked before any lookup operations. */ - class SAML_API MetadataProvider : public virtual xmltooling::Lockable + class SAML_API MetadataProvider : public virtual xmltooling::CredentialResolver { MAKE_NONCOPYABLE(MetadataProvider); - 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. - * A KeyResolver can also be supplied, or a default resolver will be used. * * The following XML content is supported: * *
    - *
  • <KeyResolver> elements with a type attribute *
  • <MetadataFilter> elements with a type attribute and type-specific content *
  • <Exclude> elements representing a BlacklistMetadataFilter *
  • <BlacklistMetadataFilter> element containing <Exclude> elements @@ -72,7 +77,7 @@ namespace opensaml { * * @param e DOM to supply configuration for provider */ - MetadataProvider(const DOMElement* e=NULL); + MetadataProvider(const xercesc::DOMElement* e=NULL); public: /** @@ -116,15 +121,6 @@ namespace opensaml { virtual void init()=0; /** - * Returns a KeyResolver associated with this metadata provider, if any. - * - * @return an associated KeyResolver, or NULL - */ - virtual const xmlsignature::KeyResolver* getKeyResolver() const { - return m_resolver; - } - - /** * Gets the entire metadata tree, after the registered filter has been applied. * The caller MUST unlock the provider when finished with the data. * @@ -133,41 +129,6 @@ namespace opensaml { virtual const xmltooling::XMLObject* getMetadata() const=0; /** - * Gets the metadata for a given entity. 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 id the ID of the entity - * @param requireValidMetadata indicates whether the metadata for the entity must be valid/current - * - * @return the entity's metadata or NULL if there is no metadata or no valid metadata - */ - virtual const EntityDescriptor* getEntityDescriptor(const XMLCh* id, bool requireValidMetadata=true) const; - - /** - * Gets the metadata for a given entity. 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 id the ID of the entity - * @param requireValidMetadata indicates whether the metadata for the entity must be valid/current - * - * @return the entity's metadata or NULL if there is no metadata or no valid metadata - */ - virtual const EntityDescriptor* getEntityDescriptor(const char* id, bool requireValidMetadata=true) const; - - /** - * Gets the metadata for an entity that issued a SAML artifact. 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 artifact a SAML artifact to find the issuer of - * - * @return the entity's metadata or NULL if there is no valid metadata - */ - virtual const EntityDescriptor* getEntityDescriptor(const SAMLArtifact* artifact) const; - - /** * 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. @@ -189,58 +150,106 @@ namespace opensaml { * * @return the group's metadata or NULL if there is no metadata or no valid metadata */ - virtual const EntitiesDescriptor* getEntitiesDescriptor(const char* name, bool requireValidMetadata=true) const; - - protected: - /** Embedded KeyResolver instance. */ - xmlsignature::KeyResolver* m_resolver; + virtual const EntitiesDescriptor* getEntitiesDescriptor(const char* name, bool requireValidMetadata=true) const=0; /** - * Applies any installed filters to a metadata instance. - * - * @param xmlObject the metadata to be filtered + * Batches up criteria for entity lookup. */ - void doFilters(xmltooling::XMLObject& xmlObject) const; + struct 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) { + } + + /** + * 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) { + } + /** + * 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) { + } + + /** Unique ID of entity. */ + const XMLCh* entityID_unicode; + /** Unique ID of entity. */ + const char* entityID_ascii; + /** SAML artifact */ + const SAMLArtifact* artifact; + /** Element or schema type QName of metadata role. */ + const xmltooling::QName* role; + /** Protocol support constant. */ + const XMLCh* protocol; + /** Backup protocol support constant. */ + const XMLCh* protocol2; + /** Controls whether stale metadata is ignored. */ + bool validOnly; + }; + /** - * Loads an entity into the cache for faster lookup. This includes - * processing known reverse lookup strategies for artifacts. + * 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 * - * @param site entity definition - * @param validUntil expiration time of the entity definition + * @return the entity's metadata (and optionally a role) or NULL if there is no qualifying metadata */ - virtual void index(EntityDescriptor* site, time_t validUntil); + virtual std::pair getEntityDescriptor(const Criteria& criteria) const=0; + protected: /** - * Loads a group of entities into the cache for faster lookup. + * Applies any installed filters to a metadata instance. * - * @param group group definition - * @param validUntil expiration time of the group definition - */ - virtual void index(EntitiesDescriptor* group, time_t validUntil); - - /** - * Clear the cache of known entities and groups. + * @param xmlObject the metadata to be filtered */ - virtual void clearDescriptorIndex(); - + void doFilters(xmltooling::XMLObject& xmlObject) const; + private: std::vector m_filters; - - typedef std::multimap sitemap_t; - typedef std::multimap groupmap_t; - sitemap_t m_sites; - sitemap_t m_sources; - groupmap_t m_groups; }; - + +#if defined (_MSC_VER) + #pragma warning( pop ) +#endif + /** * Registers MetadataProvider classes into the runtime. */ void SAML_API registerMetadataProviders(); - /** MetadataProvider based on local XML files */ - #define FILESYSTEM_METADATA_PROVIDER "org.opensaml.saml2.metadata.provider.FilesystemMetadataProvider" + /** MetadataProvider based on local or remote XML file */ + #define XML_METADATA_PROVIDER "XML" + + /** MetadataProvider based on dynamic resolution */ + #define DYNAMIC_METADATA_PROVIDER "Dynamic" + + /** MetadataProvider that wraps a sequence of metadata providers. */ + #define CHAINING_METADATA_PROVIDER "Chaining" + + DECL_XMLTOOLING_EXCEPTION(MetadataException,SAML_EXCEPTIONAPI(SAML_API),opensaml::saml2md,xmltooling::XMLToolingException,Exceptions related to metadata use); }; };