SSPCPP-616 - clean up concatenated string literals
[shibboleth/cpp-opensaml.git] / saml / saml2 / binding / impl / SAML2ArtifactDecoder.cpp
index 336ddab..46ec815 100644 (file)
@@ -33,6 +33,7 @@
 #include "saml2/metadata/Metadata.h"
 #include "saml2/metadata/MetadataProvider.h"
 
+#include <boost/scoped_ptr.hpp>
 #include <xmltooling/logging.h>
 #include <xmltooling/XMLToolingConfig.h>
 #include <xmltooling/io/HTTPRequest.h>
@@ -45,6 +46,7 @@ using namespace opensaml::saml2;
 using namespace opensaml;
 using namespace xmltooling::logging;
 using namespace xmltooling;
+using namespace boost;
 using namespace std;
 
 namespace opensaml {
@@ -78,7 +80,7 @@ XMLObject* SAML2ArtifactDecoder::decode(
 #ifdef _DEBUG
     xmltooling::NDC ndc("decode");
 #endif
-    Category& log = Category::getInstance(SAML_LOGCAT".MessageDecoder.SAML2Artifact");
+    Category& log = Category::getInstance(SAML_LOGCAT ".MessageDecoder.SAML2Artifact");
 
     log.debug("validating input");
     const HTTPRequest* httpRequest=dynamic_cast<const HTTPRequest*>(&genericRequest);
@@ -95,7 +97,7 @@ XMLObject* SAML2ArtifactDecoder::decode(
         throw BindingException("Artifact binding requires ArtifactResolver and MetadataProvider implementations be supplied.");
 
     // Import the artifact.
-    SAMLArtifact* artifact=nullptr;
+    scoped_ptr<SAMLArtifact> artifact;
     try {
         log.debug("processing encoded artifact (%s)", SAMLart);
 
@@ -110,7 +112,7 @@ XMLObject* SAML2ArtifactDecoder::decode(
         else
             log.warn("replay cache was not provided, this is a serious security risk!");
 
-        artifact = SAMLArtifact::parse(SAMLart);
+        artifact.reset(SAMLArtifact::parse(SAMLart));
     }
     catch (ArtifactException&) {
         log.error("error parsing artifact (%s)", SAMLart);
@@ -118,16 +120,15 @@ XMLObject* SAML2ArtifactDecoder::decode(
     }
 
     // Check the type.
-    auto_ptr<SAML2Artifact> artifact2(dynamic_cast<SAML2Artifact*>(artifact));
-    if (!artifact2.get()) {
-        delete artifact;
+    SAML2Artifact* artifact2 = dynamic_cast<SAML2Artifact*>(artifact.get());
+    if (!artifact2) {
         log.error("wrong artifact type");
         throw BindingException("Artifact binding requires SAML 2.0 artifact.");
     }
 
     log.debug("attempting to determine source of artifact...");
     MetadataProvider::Criteria& mc = policy.getMetadataProviderCriteria();
-    mc.artifact = artifact;
+    mc.artifact = artifact.get();
     mc.role = policy.getRole();
     mc.protocol = samlconstants::SAML20P_NS;
     pair<const EntityDescriptor*,const RoleDescriptor*> provider=policy.getMetadataProvider()->getEntityDescriptor(mc);
@@ -154,7 +155,7 @@ XMLObject* SAML2ArtifactDecoder::decode(
 
     log.debug("calling ArtifactResolver...");
     auto_ptr<ArtifactResponse> response(
-        m_artifactResolver->resolve(*(artifact2.get()), dynamic_cast<const SSODescriptorType&>(*provider.second), policy)
+        m_artifactResolver->resolve(*artifact2, dynamic_cast<const SSODescriptorType&>(*provider.second), policy)
         );
 
     // The policy should be enforced against the ArtifactResponse by the resolve step.