X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=saml%2Fbinding%2Fimpl%2FSimpleSigningRule.cpp;h=91e53fa8e7af803cf247a0cdd2d99c234b1f4191;hb=f753e2293ab6a40575bc9b294490e134eac5db9e;hp=6ba58f893671bfd9a3ccc360309c578b5e4813df;hpb=b951e528ad7d0764ddc4ced037a8bd53bd3c9890;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/binding/impl/SimpleSigningRule.cpp b/saml/binding/impl/SimpleSigningRule.cpp index 6ba58f8..91e53fa 100644 --- a/saml/binding/impl/SimpleSigningRule.cpp +++ b/saml/binding/impl/SimpleSigningRule.cpp @@ -24,6 +24,7 @@ #include "exceptions.h" #include "binding/HTTPRequest.h" #include "binding/SimpleSigningRule.h" +#include "saml2/core/Protocols.h" #include "saml2/metadata/Metadata.h" #include "saml2/metadata/MetadataProvider.h" #include "security/TrustEngine.h" @@ -72,8 +73,7 @@ pair SimpleSigningRule::evaluate( const XMLObject& message, const MetadataProvider* metadataProvider, const QName* role, - const opensaml::TrustEngine* trustEngine, - const MessageExtractor& extractor + const opensaml::TrustEngine* trustEngine ) const { Category& log=Category::getInstance(SAML_LOGCAT".SecurityPolicyRule.SimpleSigning"); @@ -100,7 +100,7 @@ pair SimpleSigningRule::evaluate( try { log.debug("extracting issuer from message"); - pair issuerInfo = extractor.getIssuerAndProtocol(message); + pair issuerInfo = getIssuerAndProtocol(message); auto_ptr issuer(issuerInfo.first); if (!issuerInfo.first || !issuerInfo.second || @@ -193,3 +193,29 @@ pair SimpleSigningRule::evaluate( } return ret; } + +pair SimpleSigningRule::getIssuerAndProtocol(const XMLObject& message) const +{ + // We just let any bad casts throw here. + + // Shortcuts some of the casting. + const XMLCh* ns = message.getElementQName().getNamespaceURI(); + if (ns) { + if (XMLString::equals(ns, samlconstants::SAML20P_NS)) { + // 2.0 namespace should be castable to a specialized 2.0 root. + const saml2::RootObject& root = dynamic_cast(message); + saml2::Issuer* issuer = root.getIssuer(); + if (issuer && issuer->getName()) + return make_pair(issuer->cloneIssuer(), samlconstants::SAML20P_NS); + + // No issuer in the message, so we have to try the Response approach. + const vector& assertions = dynamic_cast(message).getAssertions(); + if (!assertions.empty()) { + issuer = assertions.front()->getIssuer(); + if (issuer && issuer->getName()) + return make_pair(issuer->cloneIssuer(), samlconstants::SAML20P_NS); + } + } + } + return pair(NULL,NULL); +}