X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-opensaml.git;a=blobdiff_plain;f=saml%2Fsaml2%2Fmetadata%2FMetadataProvider.h;h=beced6ed1f1a4feea510b76791354cbc0182c609;hp=6e2c6d4168e97f6977a33e841ff84921c37380b0;hb=003e73203da5cdf8c3d001a75a56b9e45ef6465b;hpb=3e12b03ef5f4ad38074b127845f7b08c834cd3cc diff --git a/saml/saml2/metadata/MetadataProvider.h b/saml/saml2/metadata/MetadataProvider.h index 6e2c6d4..beced6e 100644 --- a/saml/saml2/metadata/MetadataProvider.h +++ b/saml/saml2/metadata/MetadataProvider.h @@ -129,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=0; - - /** - * 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=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. @@ -187,6 +152,81 @@ namespace opensaml { */ virtual const EntitiesDescriptor* getEntitiesDescriptor(const char* name, bool requireValidMetadata=true) const=0; + /** + * Batches up criteria for entity lookup. + */ + struct SAML_API Criteria { + /** + * Default constructor. + */ + Criteria() : entityID_unicode(NULL), entityID_ascii(NULL), artifact(NULL), role(NULL), protocol(NULL), protocol2(NULL), validOnly(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 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) { + } + + virtual ~Criteria() {} + + /** 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; + }; + + /** + * 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 + */ + virtual std::pair getEntityDescriptor(const Criteria& criteria) const=0; + protected: /** * Applies any installed filters to a metadata instance. @@ -211,9 +251,15 @@ namespace opensaml { /** 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" + /** MetadataProvider that returns an empty "dummy" entity descriptor. */ + #define NULL_METADATA_PROVIDER "Null" + DECL_XMLTOOLING_EXCEPTION(MetadataException,SAML_EXCEPTIONAPI(SAML_API),opensaml::saml2md,xmltooling::XMLToolingException,Exceptions related to metadata use); }; };