/*
- * 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 "saml1/binding/SAML1SOAPEncoder.h"
+#include "binding/MessageEncoder.h"
+#include "signature/ContentReference.h"
#include "saml1/core/Protocols.h"
#include <sstream>
namespace opensaml {
namespace saml1p {
+ class SAML_DLLLOCAL SAML1SOAPEncoder : public MessageEncoder
+ {
+ public:
+ SAML1SOAPEncoder(const DOMElement* e) {}
+ virtual ~SAML1SOAPEncoder() {}
+
+ long encode(
+ GenericResponse& genericResponse,
+ XMLObject* xmlObject,
+ const char* destination,
+ const char* recipientID=NULL,
+ const char* relayState=NULL,
+ const Credential* credential=NULL,
+ const XMLCh* signatureAlg=NULL,
+ const XMLCh* digestAlg=NULL
+ ) const;
+ };
+
MessageEncoder* SAML_DLLLOCAL SAML1SOAPEncoderFactory(const DOMElement* const & e)
{
return new SAML1SOAPEncoder(e);
};
};
-SAML1SOAPEncoder::SAML1SOAPEncoder(const DOMElement* e) {}
-
long SAML1SOAPEncoder::encode(
GenericResponse& genericResponse,
XMLObject* xmlObject,
const char* destination,
const char* recipientID,
const char* relayState,
- const CredentialResolver* credResolver,
- const XMLCh* sigAlgorithm
+ const Credential* credential,
+ const XMLCh* signatureAlg,
+ const XMLCh* digestAlg
) const
{
#ifdef _DEBUG
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 (signatureAlg)
+ sig->setSignatureAlgorithm(signatureAlg);
+ if (digestAlg) {
+ opensaml::ContentReference* cr = dynamic_cast<opensaml::ContentReference*>(sig->getContentReference());
+ if (cr)
+ cr->setDigestAlgorithm(digestAlg);
+ }
// Sign response while marshalling.
vector<Signature*> sigs(1,sig);
- rootElement = env->marshall((DOMDocument*)NULL,&sigs);
+ rootElement = env->marshall((DOMDocument*)NULL,&sigs,credential);
}
}
else {