Multi-line svn commit, see body.
[shibboleth/cpp-opensaml.git] / saml / saml2 / binding / impl / SAML2ArtifactDecoder.cpp
index c5f8c6f..1bb7af2 100644 (file)
 
 #include "internal.h"
 #include "exceptions.h"
-#include "binding/MessageDecoder.h"
 #include "saml2/binding/SAML2Artifact.h"
+#include "saml2/binding/SAML2MessageDecoder.h"
 #include "saml2/core/Protocols.h"
 #include "saml2/metadata/Metadata.h"
 #include "saml2/metadata/MetadataProvider.h"
 
-#include <log4cpp/Category.hh>
+#include <xmltooling/logging.h>
 #include <xmltooling/io/HTTPRequest.h>
 #include <xmltooling/util/NDC.h>
 #include <xmltooling/util/ReplayCache.h>
@@ -37,13 +37,13 @@ using namespace opensaml::saml2md;
 using namespace opensaml::saml2p;
 using namespace opensaml::saml2;
 using namespace opensaml;
+using namespace xmltooling::logging;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 namespace opensaml {
     namespace saml2p {              
-        class SAML_DLLLOCAL SAML2ArtifactDecoder : public MessageDecoder
+        class SAML_DLLLOCAL SAML2ArtifactDecoder : public SAML2MessageDecoder
         {
         public:
             SAML2ArtifactDecoder() {}
@@ -133,18 +133,14 @@ XMLObject* SAML2ArtifactDecoder::decode(
         log.debug("lookup succeeded, artifact issued by (%s)", issuer.get());
     }
 
-    // Mock up an Issuer object for the policy.
-    auto_ptr<Issuer> issuer(IssuerBuilder::buildIssuer());
-    issuer->setName(provider->getEntityID());
-    policy.setIssuer(issuer.get());
-    issuer.release();   // owned by policy now
-    
     log.debug("attempting to find artifact issuing role...");
     const RoleDescriptor* roledesc=provider->getRoleDescriptor(*(policy.getRole()), samlconstants::SAML20P_NS);
     if (!roledesc || !dynamic_cast<const SSODescriptorType*>(roledesc)) {
         log.error("unable to find compatible SAML role (%s) in metadata", policy.getRole()->toString().c_str());
         throw BindingException("Unable to find compatible metadata role for artifact issuer.");
     }
+    // Set issuer into policy.
+    policy.setIssuer(provider->getEntityID());
     policy.setIssuerMetadata(roledesc);
     
     log.debug("calling ArtifactResolver...");
@@ -152,10 +148,13 @@ XMLObject* SAML2ArtifactDecoder::decode(
         m_artifactResolver->resolve(*(artifact2.get()), dynamic_cast<const SSODescriptorType&>(*roledesc), policy)
         );
     
-    // The policy should be enforced against the ArtifactResponse by the resolve step. 
+    // The policy should be enforced against the ArtifactResponse by the resolve step.
+    // Reset only the message state.
+    policy.reset(true);
 
-    // Extract payload and check that message.
+    // Now extract details from the payload and check that message.
     XMLObject* payload = response->getPayload();
+    extractMessageDetails(*payload, genericRequest, samlconstants::SAML20P_NS, policy);
     policy.evaluate(*payload, &genericRequest);
 
     // Return the payload only.