Moved key/cred resolution classes out of xmlsig namespace.
[shibboleth/cpp-opensaml.git] / saml / saml2 / metadata / MetadataProvider.h
index 4e24bd7..7c927a1 100644 (file)
@@ -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.
 #ifndef __saml2_metadataprov_h__
 #define __saml2_metadataprov_h__
 
-#include <xmltooling/Lockable.h>
 #include <saml/saml2/metadata/MetadataFilter.h>
 
+#include <xmltooling/Lockable.h>
+#include <xmltooling/security/KeyResolver.h>
+
 namespace opensaml {
+    
+    class SAML_API SAMLArtifact;
 
     namespace saml2md {
+
+        class SAML_API EntityDescriptor;
+        class SAML_API EntitiesDescriptor;
         
         /**
          * 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.
+         * dynamic lookup, can include local caching, etc. Providers
+         * <strong>MUST</strong> be locked before any lookup operations.
          */
         class SAML_API MetadataProvider : public virtual xmltooling::Lockable
         {
@@ -42,15 +50,19 @@ 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:
+             * 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:
              * 
              * <ul>
-             *  <li>&lt;MetadataFilter&gt; elements with a type attribute
+             *  <li>&lt;MetadataFilter&gt; elements with a type attribute and type-specific content
              *  <li>&lt;Exclude&gt; elements representing a BlacklistMetadataFilter
              *  <li>&lt;BlacklistMetadataFilter&gt; element containing &lt;Exclude&gt; elements 
              *  <li>&lt;Include&gt; elements representing a WhitelistMetadataFilter
+             *  <li>&lt;SignatureMetadataFilter&gt; element containing a &lt;KeyResolver&gt; element 
              *  <li>&lt;WhitelistMetadataFilter&gt; element containing &lt;Include&gt; elements 
              * </ul>
              * 
@@ -102,6 +114,13 @@ namespace opensaml {
             virtual void init()=0;
             
             /**
+             * Returns a KeyResolver associated with this metadata provider, if any.
+             * 
+             * @return an associated KeyResolver, or NULL
+             */
+            virtual const xmltooling::KeyResolver* getKeyResolver() const=0;
+            
+            /**
              * Gets the entire metadata tree, after the registered filter has been applied.
              * The caller MUST unlock the provider when finished with the data.
              * 
@@ -119,7 +138,7 @@ namespace opensaml {
              * 
              * @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=0;
+            virtual const EntityDescriptor* getEntityDescriptor(const XMLCh* id, bool requireValidMetadata=true) const;
 
             /**
              * Gets the metadata for a given entity. If a valid entity is returned,
@@ -134,6 +153,17 @@ namespace opensaml {
             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.
@@ -143,7 +173,7 @@ namespace opensaml {
              * 
              * @return the group's metadata or NULL if there is no metadata or no valid metadata
              */
-            virtual const EntitiesDescriptor* getEntitiesDescriptor(const XMLCh* name, bool requireValidMetadata=true) const=0;
+            virtual const EntitiesDescriptor* getEntitiesDescriptor(const XMLCh* name, bool requireValidMetadata=true) const;
 
             /**
              * Gets the metadata for a given group of entities. If a valid group is returned,
@@ -164,7 +194,7 @@ namespace opensaml {
              * @param xmlObject the metadata to be filtered
              */
             void doFilters(xmltooling::XMLObject& xmlObject) const;
-        
+
         private:
             std::vector<MetadataFilter*> m_filters;
         };
@@ -174,8 +204,11 @@ namespace opensaml {
          */
         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 that wraps a sequence of metadata providers. */
+        #define CHAINING_METADATA_PROVIDER  "Chaining"
     };
 };