/*
- * Copyright 2001-2006 Internet2
+ * Copyright 2001-2007 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "internal.h"
#include "exceptions.h"
#include "binding/ArtifactMap.h"
+#include "binding/HTTPResponse.h"
+#include "binding/MessageEncoder.h"
#include "binding/SAMLArtifact.h"
-#include "binding/URLEncoder.h"
-#include "saml1/binding/SAML1ArtifactEncoder.h"
#include "saml1/core/Assertions.h"
+#include "saml1/core/Protocols.h"
#include <log4cpp/Category.hh>
+#include <xmltooling/XMLToolingConfig.h>
#include <xmltooling/util/NDC.h>
+#include <xmltooling/util/URLEncoder.h>
using namespace opensaml::saml1;
using namespace opensaml::saml1p;
namespace opensaml {
namespace saml1p {
+ class SAML_DLLLOCAL SAML1ArtifactEncoder : public MessageEncoder
+ {
+ public:
+ SAML1ArtifactEncoder(const DOMElement* e) {}
+ virtual ~SAML1ArtifactEncoder() {}
+
+ long encode(
+ GenericResponse& genericResponse,
+ xmltooling::XMLObject* xmlObject,
+ const char* destination,
+ const char* recipientID=NULL,
+ const char* relayState=NULL,
+ const xmltooling::CredentialResolver* credResolver=NULL,
+ const XMLCh* sigAlgorithm=NULL
+ ) const;
+ };
+
MessageEncoder* SAML_DLLLOCAL SAML1ArtifactEncoderFactory(const DOMElement* const & e)
{
return new SAML1ArtifactEncoder(e);
};
};
-SAML1ArtifactEncoder::SAML1ArtifactEncoder(const DOMElement* e) {}
-
-SAML1ArtifactEncoder::~SAML1ArtifactEncoder() {}
-
long SAML1ArtifactEncoder::encode(
- HTTPResponse& httpResponse,
+ GenericResponse& genericResponse,
XMLObject* xmlObject,
const char* destination,
const char* recipientID,
xmltooling::NDC ndc("encode");
#endif
Category& log = Category::getInstance(SAML_LOGCAT".MessageEncoder.SAML1Artifact");
+
log.debug("validating input");
-
+ HTTPResponse* httpResponse=dynamic_cast<HTTPResponse*>(&genericResponse);
+ if (!httpResponse)
+ throw BindingException("Unable to cast response interface to HTTPResponse type.");
if (xmlObject->getParent())
throw BindingException("Cannot encode XML content with parent.");
Assertion* assertion = dynamic_cast<Assertion*>(xmlObject);
// Generate redirect.
string loc = destination;
loc += (strchr(destination,'?') ? '&' : '?');
- URLEncoder* escaper = SAMLConfig::getConfig().getURLEncoder();
+ const URLEncoder* escaper = XMLToolingConfig::getConfig().getURLEncoder();
loc = loc + "SAMLart=" + escaper->encode(artifact->encode().c_str()) + "&TARGET=" + escaper->encode(relayState);
log.debug("message encoded, sending redirect to client");
- return httpResponse.sendRedirect(loc.c_str());
+ return httpResponse->sendRedirect(loc.c_str());
}