Convert logging to log4shib via compile time switch.
[shibboleth/opensaml2.git] / saml / saml2 / binding / impl / SAML2SOAPEncoder.cpp
index 43ec706..9eaac3f 100644 (file)
 
 #include "internal.h"
 #include "exceptions.h"
-#include "binding/HTTPResponse.h"
 #include "binding/MessageEncoder.h"
+#include "signature/ContentReference.h"
 #include "saml2/core/Protocols.h"
 
 #include <sstream>
-#include <log4cpp/Category.hh>
+#include <xmltooling/logging.h>
+#include <xmltooling/io/HTTPResponse.h>
 #include <xmltooling/util/NDC.h>
 #include <xmltooling/soap/SOAP.h>
 
 using namespace opensaml::saml2p;
+using namespace opensaml::saml2md;
 using namespace opensaml;
 using namespace xmlsignature;
 using namespace soap11;
+using namespace xmltooling::logging;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 namespace opensaml {
@@ -44,37 +46,43 @@ namespace opensaml {
         class SAML_DLLLOCAL SAML2SOAPEncoder : public MessageEncoder
         {
         public:
-            SAML2SOAPEncoder(const DOMElement* e);
+            SAML2SOAPEncoder() {}
             virtual ~SAML2SOAPEncoder() {}
-            
+
+            bool isUserAgentPresent() const {
+                return false;
+            }
+
             long encode(
                 GenericResponse& genericResponse,
                 XMLObject* xmlObject,
                 const char* destination,
-                const char* recipientID=NULL,
+                const EntityDescriptor* recipient=NULL,
                 const char* relayState=NULL,
+                const ArtifactGenerator* artifactGenerator=NULL,
                 const Credential* credential=NULL,
-                const XMLCh* sigAlgorithm=NULL
+                const XMLCh* signatureAlg=NULL,
+                const XMLCh* digestAlg=NULL
                 ) const;
         };
 
-        MessageEncoder* SAML_DLLLOCAL SAML2SOAPEncoderFactory(const DOMElement* const & e)
+        MessageEncoder* SAML_DLLLOCAL SAML2SOAPEncoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
         {
-            return new SAML2SOAPEncoder(e);
+            return new SAML2SOAPEncoder();
         }
     };
 };
 
-SAML2SOAPEncoder::SAML2SOAPEncoder(const DOMElement* e) {}
-
 long SAML2SOAPEncoder::encode(
     GenericResponse& genericResponse,
     XMLObject* xmlObject,
     const char* destination,
-    const char* recipientID,
+    const EntityDescriptor* recipient,
     const char* relayState,
+    const ArtifactGenerator* artifactGenerator,
     const Credential* credential,
-    const XMLCh* sigAlgorithm
+    const XMLCh* signatureAlg,
+    const XMLCh* digestAlg
     ) const
 {
 #ifdef _DEBUG
@@ -112,8 +120,13 @@ long SAML2SOAPEncoder::encode(
                     // Build a Signature.
                     Signature* sig = SignatureBuilder::buildSignature();
                     response->setSignature(sig);    
-                    if (sigAlgorithm)
-                        sig->setSignatureAlgorithm(sigAlgorithm);
+                    if (signatureAlg)
+                        sig->setSignatureAlgorithm(signatureAlg);
+                    if (digestAlg) {
+                        opensaml::ContentReference* cr = dynamic_cast<opensaml::ContentReference*>(sig->getContentReference());
+                        if (cr)
+                            cr->setDigestAlgorithm(digestAlg);
+                    }
             
                     // Sign response while marshalling.
                     vector<Signature*> sigs(1,sig);