X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fsignature%2FContentReference.cpp;h=3f2674f344b0deaab830e3cf4a0bde96b44c4a12;hb=d1ad8c104a2641c55e0377417b793055efcc69e1;hp=452ee09fb145b09eea70b60d80ba9986ea1a9d1b;hpb=f3a43f14f9dd53428f9e879bb489d6a4cf2674a8;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/signature/ContentReference.cpp b/saml/signature/ContentReference.cpp index 452ee09..3f2674f 100644 --- a/saml/signature/ContentReference.cpp +++ b/saml/signature/ContentReference.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,18 +27,28 @@ #include #include #include +#include #include 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; @@ -57,7 +67,7 @@ void ContentReference::createReferences(DSIGSignature* sig) ref->appendEnvelopedSignatureTransform(); DSIGTransformC14n* c14n=ref->appendCanonicalizationTransform(m_c14n ? m_c14n : DSIGConstants::s_unicodeStrURIEXC_C14N_NOC); if (!m_c14n || m_c14n == DSIGConstants::s_unicodeStrURIEXC_C14N_NOC || m_c14n == DSIGConstants::s_unicodeStrURIEXC_C14N_COM) { - //addPrefixes(m_signableObject); + addPrefixes(m_signableObject); #ifdef HAVE_GOOD_STL xstring prefixes; for (set::const_iterator p = m_prefixes.begin(); p!=m_prefixes.end(); ++p) @@ -92,10 +102,23 @@ 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& namespaces) { - for (set::const_iterator n = namespaces.begin(); n!=namespaces.end(); ++n) - addInclusivePrefix(n->getNamespacePrefix()); + for (set::const_iterator n = namespaces.begin(); n!=namespaces.end(); ++n) { + // Check for xmlns:xml. + if (!XMLString::equals(n->getNamespacePrefix(), xmlconstants::XML_PREFIX) || !XMLString::equals(n->getNamespaceURI(), xmlconstants::XML_NS)) + addInclusivePrefix(n->getNamespacePrefix()); + } } void ContentReference::addPrefixes(const XMLObject& xmlObject)