Merged issuer/protocol extraction back into rules.
[shibboleth/cpp-opensaml.git] / saml / binding / impl / XMLSigningRule.cpp
index cad0e6d..d667cfd 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "internal.h"
 #include "exceptions.h"
-#include "RootObject.h"
 #include "binding/XMLSigningRule.h"
 #include "saml1/core/Assertions.h"
 #include "saml1/core/Protocols.h"
@@ -48,7 +47,7 @@ namespace opensaml {
     }
 };
 
-pair<saml2::Issuer*,const saml2md::RoleDescriptor*> XMLSigningRule::evaluate(
+pair<saml2::Issuer*,const RoleDescriptor*> XMLSigningRule::evaluate(
     const GenericRequest& request,
     const XMLObject& message,
     const MetadataProvider* metadataProvider,
@@ -67,9 +66,9 @@ pair<saml2::Issuer*,const saml2md::RoleDescriptor*> XMLSigningRule::evaluate(
     }
     
     try {
-        const RootObject& root = dynamic_cast<const RootObject&>(message);
-        if (!root.getSignature()) {
-            log.debug("ignoring unsigned message");
+        const SignableObject* signable = dynamic_cast<const SignableObject*>(&message);
+        if (!signable || !signable->getSignature()) {
+            log.debug("ignoring unsigned or unrecognized message");
             return ret;
         }
         
@@ -91,14 +90,14 @@ pair<saml2::Issuer*,const saml2md::RoleDescriptor*> XMLSigningRule::evaluate(
             return ret;
         }
 
-        log.debug("matched assertion issuer against metadata, searching for applicable role...");
+        log.debug("matched message issuer against metadata, searching for applicable role...");
         const RoleDescriptor* roledesc=entity->getRoleDescriptor(*role, issuerInfo.second);
         if (!roledesc) {
             log.warn("unable to find compatible role (%s) in metadata", role->toString().c_str());
             return ret;
         }
 
-        if (!trustEngine->validate(*(root.getSignature()), *roledesc, metadataProvider->getKeyResolver())) {
+        if (!trustEngine->validate(*(signable->getSignature()), *roledesc, metadataProvider->getKeyResolver())) {
             log.error("unable to verify signature on message with supplied trust engine");
             return ret;
         }
@@ -159,19 +158,6 @@ pair<saml2::Issuer*,const XMLCh*> XMLSigningRule::getIssuerAndProtocol(const XML
                 }
             }
         }
-        else if (XMLString::equals(ns, samlconstants::SAML1_NS)) {
-            // Should be a saml:Assertion.
-            const saml1::Assertion& a = dynamic_cast<const saml1::Assertion&>(message);
-            if (a.getIssuer()) {
-                issuer = saml2::IssuerBuilder::buildIssuer();
-                issuer->setName(a.getIssuer());
-                pair<bool,int> minor = a.getMinorVersion();
-                return make_pair(
-                    issuer,
-                    (minor.first && minor.second==0) ? samlconstants::SAML10_PROTOCOL_ENUM : samlconstants::SAML11_PROTOCOL_ENUM
-                    );
-            }
-        }
     }
     return pair<saml2::Issuer*,const XMLCh*>(NULL,NULL);
 }