X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fsaml1%2Fbinding%2Fimpl%2FSAML1ArtifactDecoder.cpp;h=4ff0dfe764452ccf482a7f6df4cbbcd99344a64f;hb=c2f3cb788f744ebb8d89b22e0676b68737abfa9f;hp=71932a055296c7634a75964abbbec647cb3bc257;hpb=2cf60ce131535beae932489d2d1e3d2355799061;p=shibboleth%2Fopensaml2.git diff --git a/saml/saml1/binding/impl/SAML1ArtifactDecoder.cpp b/saml/saml1/binding/impl/SAML1ArtifactDecoder.cpp index 71932a0..4ff0dfe 100644 --- a/saml/saml1/binding/impl/SAML1ArtifactDecoder.cpp +++ b/saml/saml1/binding/impl/SAML1ArtifactDecoder.cpp @@ -22,13 +22,14 @@ #include "internal.h" #include "exceptions.h" -#include "binding/HTTPRequest.h" -#include "saml/binding/SAMLArtifact.h" -#include "saml1/binding/SAML1ArtifactDecoder.h" +#include "binding/MessageDecoder.h" +#include "binding/SAMLArtifact.h" +#include "saml1/core/Protocols.h" #include "saml2/metadata/Metadata.h" #include "saml2/metadata/MetadataProvider.h" #include +#include #include #include @@ -41,15 +42,26 @@ using namespace std; namespace opensaml { namespace saml1p { - MessageDecoder* SAML_DLLLOCAL SAML1ArtifactDecoderFactory(const DOMElement* const & e) + class SAML_DLLLOCAL SAML1ArtifactDecoder : public MessageDecoder { - return new SAML1ArtifactDecoder(e); + public: + SAML1ArtifactDecoder() {} + virtual ~SAML1ArtifactDecoder() {} + + xmltooling::XMLObject* decode( + std::string& relayState, + const GenericRequest& genericRequest, + SecurityPolicy& policy + ) const; + }; + + MessageDecoder* SAML_DLLLOCAL SAML1ArtifactDecoderFactory(const pair& p) + { + return new SAML1ArtifactDecoder(); } }; }; -SAML1ArtifactDecoder::SAML1ArtifactDecoder(const DOMElement* e) {} - XMLObject* SAML1ArtifactDecoder::decode( string& relayState, const GenericRequest& genericRequest, @@ -63,16 +75,14 @@ XMLObject* SAML1ArtifactDecoder::decode( log.debug("validating input"); const HTTPRequest* httpRequest=dynamic_cast(&genericRequest); - if (!httpRequest) { - log.error("unable to cast request to HTTPRequest type"); - return NULL; - } + if (!httpRequest) + throw BindingException("Unable to cast request object to HTTPRequest type."); if (strcmp(httpRequest->getMethod(),"GET")) - return NULL; + throw BindingException("Invalid HTTP method ($1).", params(1, httpRequest->getMethod())); vector SAMLart; const char* TARGET = httpRequest->getParameter("TARGET"); if (httpRequest->getParameters("SAMLart", SAMLart)==0 || !TARGET) - return NULL; + throw BindingException("Request missing SAMLart or TARGET parameters."); relayState = TARGET; if (!m_artifactResolver || !policy.getMetadataProvider() || !policy.getRole()) @@ -142,6 +152,7 @@ XMLObject* SAML1ArtifactDecoder::decode( policy.setIssuerMetadata(roledesc); try { + log.debug("calling ArtifactResolver..."); auto_ptr response( m_artifactResolver->resolve(artifacts, dynamic_cast(*roledesc), policy) );