Policy rule redesign for factor out issuer handling.
[shibboleth/cpp-opensaml.git] / saml / saml1 / binding / impl / SAML1ArtifactDecoder.cpp
index 83cd7ba..23a9505 100644 (file)
@@ -50,9 +50,7 @@ namespace opensaml {
 
 SAML1ArtifactDecoder::SAML1ArtifactDecoder(const DOMElement* e) {}
 
-SAML1ArtifactDecoder::~SAML1ArtifactDecoder() {}
-
-Response* SAML1ArtifactDecoder::decode(
+XMLObject* SAML1ArtifactDecoder::decode(
     string& relayState,
     const GenericRequest& genericRequest,
     SecurityPolicy& policy
@@ -125,6 +123,12 @@ Response* SAML1ArtifactDecoder::decode(
         auto_ptr_char issuer(provider->getEntityID());
         log.debug("lookup succeeded, artifact issued by (%s)", issuer.get());
     }
+
+    // Mock up an Issuer object for the policy.
+    auto_ptr<saml2::Issuer> issuer(saml2::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::SAML11_PROTOCOL_ENUM);
@@ -133,23 +137,22 @@ Response* SAML1ArtifactDecoder::decode(
     if (!roledesc || !dynamic_cast<const IDPSSODescriptor*>(roledesc)) {
         log.error("unable to find compatible SAML role (%s) in metadata", policy.getRole()->toString().c_str());
         for_each(artifacts.begin(), artifacts.end(), xmltooling::cleanup<SAMLArtifact>());
-        BindingException ex("Unable to find compatible metadata role for artifact issuer.");
-        annotateException(&ex,provider); // throws it
+        throw BindingException("Unable to find compatible metadata role for artifact issuer.");
     }
+    policy.setIssuerMetadata(roledesc);
     
     try {
         auto_ptr<Response> response(
             m_artifactResolver->resolve(artifacts, dynamic_cast<const IDPSSODescriptor&>(*roledesc), policy)
             );
         
-        policy.evaluate(genericRequest, *(response.get()));
+        policy.evaluate(*(response.get()), &genericRequest);
         
         for_each(artifacts.begin(), artifacts.end(), xmltooling::cleanup<SAMLArtifact>());
         return response.release();
     }
-    catch (XMLToolingException& ex) {
+    catch (XMLToolingException&) {
         for_each(artifacts.begin(), artifacts.end(), xmltooling::cleanup<SAMLArtifact>());
-        annotateException(&ex,roledesc,false);
         throw;
     }
 }