X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fbinding%2Fimpl%2FXMLSigningRule.cpp;h=6cc736d6a86f7fd28ea93b7c73db06e0ed498e73;hb=a30857e2c0f4bcd1817aa2939ffdc0856e93a533;hp=cad0e6d32631f5ca4215a9454a84354423dc3a71;hpb=9e5f5fd6b4d0dfd3cb062e98dcb087640bf82414;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/binding/impl/XMLSigningRule.cpp b/saml/binding/impl/XMLSigningRule.cpp index cad0e6d..6cc736d 100644 --- a/saml/binding/impl/XMLSigningRule.cpp +++ b/saml/binding/impl/XMLSigningRule.cpp @@ -22,14 +22,13 @@ #include "internal.h" #include "exceptions.h" -#include "RootObject.h" #include "binding/XMLSigningRule.h" #include "saml1/core/Assertions.h" #include "saml1/core/Protocols.h" #include "saml2/core/Protocols.h" #include "saml2/metadata/Metadata.h" #include "saml2/metadata/MetadataProvider.h" -#include "security/TrustEngine.h" +#include "signature/SignatureProfileValidator.h" #include #include @@ -48,12 +47,12 @@ namespace opensaml { } }; -pair XMLSigningRule::evaluate( +pair XMLSigningRule::evaluate( const GenericRequest& request, const XMLObject& message, const MetadataProvider* metadataProvider, const QName* role, - const opensaml::TrustEngine* trustEngine + const TrustEngine* trustEngine ) const { Category& log=Category::getInstance(SAML_LOGCAT".SecurityPolicyRule.XMLSigning"); @@ -67,12 +66,23 @@ pair XMLSigningRule::evaluate( } try { - const RootObject& root = dynamic_cast(message); - if (!root.getSignature()) { - log.debug("ignoring unsigned message"); + const SignableObject* signable = dynamic_cast(&message); + if (!signable || !signable->getSignature()) { + log.debug("ignoring unsigned or unrecognized message"); return ret; } + log.debug("validating signature profile"); + try { + SignatureProfileValidator sigval; + sigval.validate(signable->getSignature()); + } + catch (ValidationException& ve) { + log.error("signature profile failed to validate: %s", ve.what()); + return ret; + } + + log.debug("extracting issuer from message"); pair issuerInfo = getIssuerAndProtocol(message); @@ -91,14 +101,14 @@ pair 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 +169,6 @@ pair XMLSigningRule::getIssuerAndProtocol(const XML } } } - else if (XMLString::equals(ns, samlconstants::SAML1_NS)) { - // Should be a saml:Assertion. - const saml1::Assertion& a = dynamic_cast(message); - if (a.getIssuer()) { - issuer = saml2::IssuerBuilder::buildIssuer(); - issuer->setName(a.getIssuer()); - pair minor = a.getMinorVersion(); - return make_pair( - issuer, - (minor.first && minor.second==0) ? samlconstants::SAML10_PROTOCOL_ENUM : samlconstants::SAML11_PROTOCOL_ENUM - ); - } - } } return pair(NULL,NULL); }