Parameterize config namespace for message plugins.
[shibboleth/cpp-opensaml.git] / saml / saml1 / binding / impl / SAML1ArtifactDecoder.cpp
index cb60c7d..4ff0dfe 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "internal.h"
 #include "exceptions.h"
-#include "binding/HTTPRequest.h"
 #include "binding/MessageDecoder.h"
 #include "binding/SAMLArtifact.h"
 #include "saml1/core/Protocols.h"
@@ -30,6 +29,7 @@
 #include "saml2/metadata/MetadataProvider.h"
 
 #include <log4cpp/Category.hh>
+#include <xmltooling/io/HTTPRequest.h>
 #include <xmltooling/util/NDC.h>
 #include <xmltooling/util/ReplayCache.h>
 
@@ -45,7 +45,7 @@ namespace opensaml {
         class SAML_DLLLOCAL SAML1ArtifactDecoder : public MessageDecoder
         {
         public:
-            SAML1ArtifactDecoder(const DOMElement* e) {}
+            SAML1ArtifactDecoder() {}
             virtual ~SAML1ArtifactDecoder() {}
             
             xmltooling::XMLObject* decode(
@@ -55,9 +55,9 @@ namespace opensaml {
                 ) const;
         };                
 
-        MessageDecoder* SAML_DLLLOCAL SAML1ArtifactDecoderFactory(const DOMElement* const & e)
+        MessageDecoder* SAML_DLLLOCAL SAML1ArtifactDecoderFactory(const pair<const DOMElement*,const XMLCh*>& p)
         {
-            return new SAML1ArtifactDecoder(e);
+            return new SAML1ArtifactDecoder();
         }
     };
 };
@@ -75,16 +75,14 @@ XMLObject* SAML1ArtifactDecoder::decode(
 
     log.debug("validating input");
     const HTTPRequest* httpRequest=dynamic_cast<const HTTPRequest*>(&genericRequest);
-    if (!httpRequest) {
-        log.error("unable to cast request to HTTPRequest type");
-        return NULL;
-    }
+    if (!httpRequest)
+        throw BindingException("Unable to cast request object to HTTPRequest type.");
     if (strcmp(httpRequest->getMethod(),"GET"))
-        return NULL;
+        throw BindingException("Invalid HTTP method ($1).", params(1, httpRequest->getMethod()));
     vector<const char*> SAMLart;
     const char* TARGET = httpRequest->getParameter("TARGET");
     if (httpRequest->getParameters("SAMLart", SAMLart)==0 || !TARGET)
-        return NULL;
+        throw BindingException("Request missing SAMLart or TARGET parameters.");
     relayState = TARGET;
 
     if (!m_artifactResolver || !policy.getMetadataProvider() || !policy.getRole())