X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fsaml1%2Fbinding%2Fimpl%2FSAML1SOAPDecoder.cpp;h=d60dcedc81a8f7ec195468b2c0b73e1ce0e8d65e;hb=30060a96ad3a0a97d8a51328c92faa64f4302049;hp=d759507b2ae628df05d8b02a93b6e9cf421139ae;hpb=0e738d39ba71958fe55692498c91fc6e6d402604;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/saml1/binding/impl/SAML1SOAPDecoder.cpp b/saml/saml1/binding/impl/SAML1SOAPDecoder.cpp index d759507..d60dced 100644 --- a/saml/saml1/binding/impl/SAML1SOAPDecoder.cpp +++ b/saml/saml1/binding/impl/SAML1SOAPDecoder.cpp @@ -22,10 +22,10 @@ #include "internal.h" #include "exceptions.h" -#include "binding/MessageDecoder.h" +#include "saml1/binding/SAML1MessageDecoder.h" #include "saml1/core/Protocols.h" -#include +#include #include #include #include @@ -33,18 +33,22 @@ using namespace opensaml::saml1p; using namespace opensaml; using namespace soap11; +using namespace xmltooling::logging; using namespace xmltooling; -using namespace log4cpp; using namespace std; namespace opensaml { namespace saml1p { - class SAML_DLLLOCAL SAML1SOAPDecoder : public MessageDecoder + class SAML_DLLLOCAL SAML1SOAPDecoder : public SAML1MessageDecoder { public: - SAML1SOAPDecoder(const DOMElement* e) {} + SAML1SOAPDecoder() {} virtual ~SAML1SOAPDecoder() {} - + + bool isUserAgentPresent() const { + return false; + } + xmltooling::XMLObject* decode( std::string& relayState, const GenericRequest& genericRequest, @@ -52,9 +56,9 @@ namespace opensaml { ) const; }; - MessageDecoder* SAML_DLLLOCAL SAML1SOAPDecoderFactory(const DOMElement* const & e) + MessageDecoder* SAML_DLLLOCAL SAML1SOAPDecoderFactory(const pair& p) { - return new SAML1SOAPDecoder(e); + return new SAML1SOAPDecoder(); } }; }; @@ -74,14 +78,13 @@ XMLObject* SAML1SOAPDecoder::decode( string s = genericRequest.getContentType(); if (s.find("text/xml") == string::npos) { log.warn("ignoring incorrect content type (%s)", s.c_str() ? s.c_str() : "none"); - return NULL; + throw BindingException("Invalid content type for SOAP message."); } const char* data = genericRequest.getRequestBody(); - if (!data) { - log.warn("empty request body"); - return NULL; - } + if (!data) + throw BindingException("SOAP message had an empty request body."); + log.debug("received message:\n%s", data); istringstream is(data); // Parse and bind the document into an XMLObject. @@ -103,8 +106,24 @@ XMLObject* SAML1SOAPDecoder::decode( Request* request = dynamic_cast(body->getUnknownXMLObjects().front()); if (request) { // Run through the policy at two layers. - policy.evaluate(*env, &genericRequest); - policy.evaluate(*request, &genericRequest); + pair minor = request->getMinorVersion(); + extractMessageDetails( + *env, + genericRequest, + (minor.first && minor.second==0) ? samlconstants::SAML10_PROTOCOL_ENUM : samlconstants::SAML11_PROTOCOL_ENUM, + policy + ); + policy.evaluate(*env,&genericRequest); + + // Reset, extract, and run again. + policy.reset(true); + extractMessageDetails( + *request, + genericRequest, + (minor.first && minor.second==0) ? samlconstants::SAML10_PROTOCOL_ENUM : samlconstants::SAML11_PROTOCOL_ENUM, + policy + ); + policy.evaluate(*request,&genericRequest); xmlObject.release(); body->detach(); // frees Envelope request->detach(); // frees Body @@ -112,5 +131,5 @@ XMLObject* SAML1SOAPDecoder::decode( } } - throw BindingException("SOAP Envelope did not contain a SAML Request."); + throw BindingException("SOAP Envelope did not contain a SAML 1.x Request."); }