Expose a "user agent present" property.
[shibboleth/cpp-opensaml.git] / saml / binding / MessageEncoder.h
index a0e212b..dcbd86d 100644 (file)
 #ifndef __saml_encoder_h__
 #define __saml_encoder_h__
 
-#include <saml/binding/GenericResponse.h>
+#include <saml/base.h>
 
 #include <istream>
 #include <xmltooling/XMLObject.h>
+#include <xmltooling/io/GenericResponse.h>
 #include <xmltooling/security/Credential.h>
 
 namespace opensaml {
@@ -35,6 +36,9 @@ namespace opensaml {
     namespace saml2p {
         class SAML_API SAML2Artifact;
     };
+    namespace saml2md {
+        class SAML_API EntityDescriptor;
+    };
 
     /**
      * Interface to SAML protocol binding message encoders.
@@ -46,6 +50,24 @@ namespace opensaml {
         virtual ~MessageEncoder() {}
 
         /**
+         * Indicates whether the encoding format requires that messages be as compact as possible.
+         *
+         * @return  true iff the encoding has size constraints
+         */
+        virtual bool isCompact() const {
+            return false;
+        }
+
+        /**
+         * Indicates whether a web browser or similar user agent will receive the message.
+         *
+         * @return true iff the message will be handled by a user agent
+         */
+        virtual bool isUserAgentPresent() const {
+            return true;
+        }
+
+        /**
          * Interface to caller-supplied artifact generation mechanism.
          * 
          * Generating an artifact for storage and retrieval requires knowledge of
@@ -68,7 +90,7 @@ namespace opensaml {
              * @param relyingParty  the party that will recieve the artifact
              * @return a SAML 1.x artifact with a random assertion handle
              */
-            virtual SAMLArtifact* generateSAML1Artifact(const char* relyingParty) const=0;
+            virtual SAMLArtifact* generateSAML1Artifact(const saml2md::EntityDescriptor* relyingParty) const=0;
 
             /**
              * Generate a SAML 2.0 artifact suitable for consumption by the relying party.
@@ -76,21 +98,10 @@ namespace opensaml {
              * @param relyingParty  the party that will recieve the artifact
              * @return a SAML 2.0 artifact with a random message handle
              */
-            virtual saml2p::SAML2Artifact* generateSAML2Artifact(const char* relyingParty) const=0;
+            virtual saml2p::SAML2Artifact* generateSAML2Artifact(const saml2md::EntityDescriptor* relyingParty) const=0;
         };
 
         /**
-         * Provides an ArtifactGenerator implementation for the MessageEncoder to use.
-         * The implementation's lifetime must be longer than the lifetime of this object. 
-         * This method must be externally synchronized. 
-         * 
-         * @param artifactGenerator   an ArtifactGenerator implementation to use
-         */
-        void setArtifactGenerator(ArtifactGenerator* artifactGenerator) {
-            m_artifactGenerator = artifactGenerator;
-        }
-        
-        /**
          * Encodes an XML object/message into a binding- and transport-specific response.
          * The XML content cannot have a parent object, and any existing references to
          * the content will be invalidated if the encode method returns successfully.
@@ -105,26 +116,27 @@ namespace opensaml {
          * @param genericResponse   reference to interface for sending transport response      
          * @param xmlObject         XML message to encode
          * @param destination       destination URL for message
-         * @param recipientID       optional entityID of message recipient
+         * @param recipient         optional message recipient
          * @param relayState        optional RelayState value to accompany message
+         * @param artifactGenerator optional interface for generation of artifacts
          * @param credential        optional Credential to supply signing key
-         * @param sigAlgorithm      optional signature algorithm identifier
+         * @param signatureAlg      optional signature algorithm identifier
+         * @param digestAlg         optional reference digest algorithm identifier
          */
         virtual long encode(
-            GenericResponse& genericResponse,
+            xmltooling::GenericResponse& genericResponse,
             xmltooling::XMLObject* xmlObject,
             const char* destination,
-            const char* recipientID=NULL,
+            const saml2md::EntityDescriptor* recipient=NULL,
             const char* relayState=NULL,
+            const ArtifactGenerator* artifactGenerator=NULL,
             const xmltooling::Credential* credential=NULL,
-            const XMLCh* sigAlgorithm=NULL
+            const XMLCh* signatureAlg=NULL,
+            const XMLCh* digestAlg=NULL
             ) const=0;
 
     protected:
-        MessageEncoder() : m_artifactGenerator(NULL) {}
-        
-        /** Pointer to an ArtifactGenerator implementation. */
-        const ArtifactGenerator* m_artifactGenerator;
+        MessageEncoder() {}
     };
 
     /**