Major revamp of credential and trust handling code, PKIX engine still needs work.
[shibboleth/cpp-opensaml.git] / saml / saml2 / binding / impl / SAML2SOAPEncoder.cpp
index 687cf9e..43ec706 100644 (file)
@@ -23,7 +23,7 @@
 #include "internal.h"
 #include "exceptions.h"
 #include "binding/HTTPResponse.h"
-#include "saml2/binding/SAML2SOAPEncoder.h"
+#include "binding/MessageEncoder.h"
 #include "saml2/core/Protocols.h"
 
 #include <sstream>
@@ -41,6 +41,23 @@ using namespace std;
 
 namespace opensaml {
     namespace saml2p {              
+        class SAML_DLLLOCAL SAML2SOAPEncoder : public MessageEncoder
+        {
+        public:
+            SAML2SOAPEncoder(const DOMElement* e);
+            virtual ~SAML2SOAPEncoder() {}
+            
+            long encode(
+                GenericResponse& genericResponse,
+                XMLObject* xmlObject,
+                const char* destination,
+                const char* recipientID=NULL,
+                const char* relayState=NULL,
+                const Credential* credential=NULL,
+                const XMLCh* sigAlgorithm=NULL
+                ) const;
+        };
+
         MessageEncoder* SAML_DLLLOCAL SAML2SOAPEncoderFactory(const DOMElement* const & e)
         {
             return new SAML2SOAPEncoder(e);
@@ -56,7 +73,7 @@ long SAML2SOAPEncoder::encode(
     const char* destination,
     const char* recipientID,
     const char* relayState,
-    const CredentialResolver* credResolver,
+    const Credential* credential,
     const XMLCh* sigAlgorithm
     ) const
 {
@@ -84,7 +101,7 @@ long SAML2SOAPEncoder::encode(
             Body* body = BodyBuilder::buildBody();
             env->setBody(body);
             body->getUnknownXMLObjects().push_back(response);
-            if (credResolver ) {
+            if (credential) {
                 if (response->getSignature()) {
                     log.debug("response already signed, skipping signature operation");
                     rootElement = env->marshall();
@@ -93,12 +110,14 @@ long SAML2SOAPEncoder::encode(
                     log.debug("signing and marshalling the response");
         
                     // Build a Signature.
-                    Signature* sig = buildSignature(credResolver, sigAlgorithm);
-                    response->setSignature(sig);
+                    Signature* sig = SignatureBuilder::buildSignature();
+                    response->setSignature(sig);    
+                    if (sigAlgorithm)
+                        sig->setSignatureAlgorithm(sigAlgorithm);
             
                     // Sign response while marshalling.
                     vector<Signature*> sigs(1,sig);
-                    rootElement = env->marshall((DOMDocument*)NULL,&sigs);
+                    rootElement = env->marshall((DOMDocument*)NULL,&sigs,credential);
                 }
             }
             else {