https://issues.shibboleth.net/jira/browse/CPPOST-36
[shibboleth/cpp-opensaml.git] / saml / signature / ContentReference.cpp
index ffc7708..3f2674f 100644 (file)
 #include <xmltooling/signature/Signature.h>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xsec/dsig/DSIGReference.hpp>
+#include <xsec/dsig/DSIGSignature.hpp>
 #include <xsec/dsig/DSIGTransformC14n.hpp>
 
 using namespace opensaml;
 using namespace xmltooling;
 using namespace std;
 
+ContentReference::ContentReference(const SignableObject& signableObject)
+    : m_signableObject(signableObject), m_digest(NULL), m_c14n(NULL)
+{
+}
+
+ContentReference::~ContentReference()
+{
+}
+
 void ContentReference::createReferences(DSIGSignature* sig)
 {
     DSIGReference* ref=NULL;
     const XMLCh* id=m_signableObject.getXMLID();
     if (!id || !*id)
-        ref=sig->createReference(&chNull);  // whole doc reference
+        ref=sig->createReference(&chNull, m_digest ? m_digest : DSIGConstants::s_unicodeStrURISHA1);  // whole doc reference
     else {
         XMLCh* buf=new XMLCh[XMLString::stringLen(id) + 2];
         buf[0]=chPound;
@@ -92,6 +102,16 @@ void ContentReference::addInclusivePrefix(const XMLCh* prefix)
 #endif
 }
 
+void ContentReference::setDigestAlgorithm(const XMLCh* digest)
+{
+    m_digest = digest;
+}
+
+void ContentReference::setCanonicalizationMethod(const XMLCh* c14n)
+{
+    m_c14n = c14n;
+}
+
 void ContentReference::addPrefixes(const std::set<Namespace>& namespaces)
 {
     for (set<Namespace>::const_iterator n = namespaces.begin(); n!=namespaces.end(); ++n) {