Clarify error messages.
[shibboleth/opensaml2.git] / saml / saml2 / binding / impl / SAML2POSTDecoder.cpp
index cdb8060..1898c4b 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "internal.h"
 #include "exceptions.h"
-#include "binding/MessageDecoder.h"
+#include "saml2/binding/SAML2MessageDecoder.h"
 #include "saml2/core/Protocols.h"
 #include "saml2/metadata/Metadata.h"
 #include "saml2/metadata/MetadataProvider.h"
@@ -43,7 +43,7 @@ using namespace std;
 
 namespace opensaml {
     namespace saml2p {              
-        class SAML_DLLLOCAL SAML2POSTDecoder : public MessageDecoder
+        class SAML_DLLLOCAL SAML2POSTDecoder : public SAML2MessageDecoder
         {
         public:
             SAML2POSTDecoder() {}
@@ -84,7 +84,7 @@ XMLObject* SAML2POSTDecoder::decode(
     if (!msg)
         msg = httpRequest->getParameter("SAMLRequest");
     if (!msg)
-        throw BindingException("Request missing SAMLRequest or SAMLResponse parameter.");
+        throw BindingException("Request missing SAMLRequest or SAMLResponse form parameter.");
     const char* state = httpRequest->getParameter("RelayState");
     if (state)
         relayState = state;
@@ -121,9 +121,10 @@ XMLObject* SAML2POSTDecoder::decode(
     }
     
     if (!policy.getValidating())
-        SchemaValidators.validate(xmlObject.get());
+        SchemaValidators.validate(root);
 
     // Run through the policy.
+    extractMessageDetails(*root, genericRequest, samlconstants::SAML20P_NS, policy);
     policy.evaluate(*root, &genericRequest);
     
     // Check destination URL.
@@ -134,7 +135,7 @@ XMLObject* SAML2POSTDecoder::decode(
         log.error("signed SAML message missing Destination attribute");
         throw BindingException("Signed SAML message missing Destination attribute identifying intended destination.");
     }
-    else if ((delim && strncmp(dest.get(), dest2, delim - dest2)) || (!delim && strcmp(dest.get(),dest2))) {
+    else if (dest.get() && *dest.get() && ((delim && strncmp(dest.get(), dest2, delim - dest2)) || (!delim && strcmp(dest.get(),dest2)))) {
         log.error("POST targeted at (%s), but delivered to (%s)", dest.get(), dest2);
         throw BindingException("SAML message delivered with POST to incorrect server URL.");
     }