Missing () in if statement.
[shibboleth/opensaml2.git] / saml / saml2 / binding / impl / SAML2POSTDecoder.cpp
index 414e24b..14a06ae 100644 (file)
@@ -23,7 +23,7 @@
 #include "internal.h"
 #include "exceptions.h"
 #include "binding/HTTPRequest.h"
-#include "saml2/binding/SAML2POSTDecoder.h"
+#include "binding/MessageDecoder.h"
 #include "saml2/core/Protocols.h"
 #include "saml2/metadata/Metadata.h"
 #include "saml2/metadata/MetadataProvider.h"
@@ -43,6 +43,19 @@ using namespace std;
 
 namespace opensaml {
     namespace saml2p {              
+        class SAML_DLLLOCAL SAML2POSTDecoder : public MessageDecoder
+        {
+        public:
+            SAML2POSTDecoder(const DOMElement* e) {}
+            virtual ~SAML2POSTDecoder() {}
+            
+            xmltooling::XMLObject* decode(
+                std::string& relayState,
+                const GenericRequest& genericRequest,
+                SecurityPolicy& policy
+                ) const;
+        };                
+
         MessageDecoder* SAML_DLLLOCAL SAML2POSTDecoderFactory(const DOMElement* const & e)
         {
             return new SAML2POSTDecoder(e);
@@ -50,8 +63,6 @@ namespace opensaml {
     };
 };
 
-SAML2POSTDecoder::SAML2POSTDecoder(const DOMElement* e) {}
-
 XMLObject* SAML2POSTDecoder::decode(
     std::string& relayState,
     const GenericRequest& genericRequest,
@@ -92,7 +103,7 @@ XMLObject* SAML2POSTDecoder::decode(
     XMLString::release(&decoded);
     
     // Parse and bind the document into an XMLObject.
-    DOMDocument* doc = (m_validate ? XMLToolingConfig::getConfig().getValidatingParser()
+    DOMDocument* doc = (policy.getValidating() ? XMLToolingConfig::getConfig().getValidatingParser()
         : XMLToolingConfig::getConfig().getParser()).parse(is); 
     XercesJanitor<DOMDocument> janitor(doc);
     auto_ptr<XMLObject> xmlObject(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(), true));
@@ -111,13 +122,16 @@ XMLObject* SAML2POSTDecoder::decode(
         root = static_cast<saml2::RootObject*>(request);
     }
     
-    if (!m_validate)
+    if (!policy.getValidating())
         SchemaValidators.validate(xmlObject.get());
+
+    // Run through the policy.
+    policy.evaluate(*root, &genericRequest);
     
     // Check destination URL.
     auto_ptr_char dest(request ? request->getDestination() : response->getDestination());
     const char* dest2 = httpRequest->getRequestURL();
-    if ((root->getSignature() || httpRequest->getParameter("Signature")) && !dest.get() || !*(dest.get())) {
+    if ((root->getSignature() || httpRequest->getParameter("Signature")) && (!dest.get() || !*(dest.get()))) {
         log.error("signed SAML message missing Destination attribute");
         throw BindingException("Signed SAML message missing Destination attribute identifying intended destination.");
     }
@@ -126,7 +140,5 @@ XMLObject* SAML2POSTDecoder::decode(
         throw BindingException("SAML message delivered with POST to incorrect server URL.");
     }
     
-    // Run through the policy.
-    policy.evaluate(*root, &genericRequest);
     return xmlObject.release();
 }