/*
- * 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/HTTPResponse.h"
-#include "saml2/binding/SAML2SOAPEncoder.h"
+#include "binding/MessageEncoder.h"
#include "saml2/core/Protocols.h"
#include <sstream>
namespace opensaml {
namespace saml2p {
+ class SAML_DLLLOCAL SAML2SOAPEncoder : public MessageEncoder
+ {
+ public:
+ SAML2SOAPEncoder(const DOMElement* e);
+ virtual ~SAML2SOAPEncoder() {}
+
+ long encode(
+ GenericResponse& genericResponse,
+ XMLObject* xmlObject,
+ const char* destination,
+ const char* recipientID=NULL,
+ const char* relayState=NULL,
+ const Credential* credential=NULL,
+ const XMLCh* sigAlgorithm=NULL
+ ) const;
+ };
+
MessageEncoder* SAML_DLLLOCAL SAML2SOAPEncoderFactory(const DOMElement* const & e)
{
return new SAML2SOAPEncoder(e);
const char* destination,
const char* recipientID,
const char* relayState,
- const CredentialResolver* credResolver,
+ const Credential* credential,
const XMLCh* sigAlgorithm
) const
{
#ifdef _DEBUG
xmltooling::NDC ndc("encode");
#endif
- Category& log = Category::getInstance(SAML_LOGCAT".MessageEncoder.SAML1SOAP");
+ Category& log = Category::getInstance(SAML_LOGCAT".MessageEncoder.SAML2SOAP");
log.debug("validating input");
if (xmlObject->getParent())
genericResponse.setContentType("text/xml");
HTTPResponse* httpResponse = dynamic_cast<HTTPResponse*>(&genericResponse);
if (httpResponse) {
- httpResponse->setHeader("Cache-Control", "no-cache, no-store, must-revalidate, private");
- httpResponse->setHeader("Pragma", "no-cache");
+ httpResponse->setResponseHeader("Cache-Control", "no-cache, no-store, must-revalidate, private");
+ httpResponse->setResponseHeader("Pragma", "no-cache");
}
DOMElement* rootElement = NULL;
Body* body = BodyBuilder::buildBody();
env->setBody(body);
body->getUnknownXMLObjects().push_back(response);
- if (credResolver ) {
+ if (credential) {
if (response->getSignature()) {
log.debug("response already signed, skipping signature operation");
rootElement = env->marshall();
log.debug("signing and marshalling the response");
// Build a Signature.
- Signature* sig = buildSignature(credResolver, sigAlgorithm);
- response->setSignature(sig);
+ Signature* sig = SignatureBuilder::buildSignature();
+ response->setSignature(sig);
+ if (sigAlgorithm)
+ sig->setSignatureAlgorithm(sigAlgorithm);
// Sign response while marshalling.
vector<Signature*> sigs(1,sig);
- rootElement = env->marshall((DOMDocument*)NULL,&sigs);
+ rootElement = env->marshall((DOMDocument*)NULL,&sigs,credential);
}
}
else {