X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fsaml2%2Fbinding%2Fimpl%2FSAML2SOAPEncoder.cpp;h=9eaac3f0cf71f437361712171b286d03ce169f95;hb=9fddf9054c76de6239295b98a559fcc75453effc;hp=7a5bfefb30be4c7fbd52e858c9221c0f2733de6b;hpb=f9aa9375e0908e119af283278d00468a9b2249f5;p=shibboleth%2Fopensaml2.git diff --git a/saml/saml2/binding/impl/SAML2SOAPEncoder.cpp b/saml/saml2/binding/impl/SAML2SOAPEncoder.cpp index 7a5bfef..9eaac3f 100644 --- a/saml/saml2/binding/impl/SAML2SOAPEncoder.cpp +++ b/saml/saml2/binding/impl/SAML2SOAPEncoder.cpp @@ -22,21 +22,23 @@ #include "internal.h" #include "exceptions.h" -#include "binding/HTTPResponse.h" #include "binding/MessageEncoder.h" +#include "signature/ContentReference.h" #include "saml2/core/Protocols.h" #include -#include +#include +#include #include #include 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, - xmltooling::XMLObject* xmlObject, + XMLObject* xmlObject, const char* destination, - const char* recipientID=NULL, + const EntityDescriptor* recipient=NULL, const char* relayState=NULL, - const xmltooling::CredentialResolver* credResolver=NULL, - const XMLCh* sigAlgorithm=NULL + const ArtifactGenerator* artifactGenerator=NULL, + const Credential* credential=NULL, + const XMLCh* signatureAlg=NULL, + const XMLCh* digestAlg=NULL ) const; }; - MessageEncoder* SAML_DLLLOCAL SAML2SOAPEncoderFactory(const DOMElement* const & e) + MessageEncoder* SAML_DLLLOCAL SAML2SOAPEncoderFactory(const pair& 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 CredentialResolver* credResolver, - const XMLCh* sigAlgorithm + const ArtifactGenerator* artifactGenerator, + const Credential* credential, + const XMLCh* signatureAlg, + const XMLCh* digestAlg ) const { #ifdef _DEBUG @@ -101,7 +109,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(); @@ -110,12 +118,19 @@ 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 (signatureAlg) + sig->setSignatureAlgorithm(signatureAlg); + if (digestAlg) { + opensaml::ContentReference* cr = dynamic_cast(sig->getContentReference()); + if (cr) + cr->setDigestAlgorithm(digestAlg); + } // Sign response while marshalling. vector sigs(1,sig); - rootElement = env->marshall((DOMDocument*)NULL,&sigs); + rootElement = env->marshall((DOMDocument*)NULL,&sigs,credential); } } else {