2 * Copyright 2001-2007 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * ContentReference.cpp
20 * SAML-specific signature reference profile
24 #include "signature/ContentReference.h"
25 #include "signature/SignableObject.h"
27 #include <xmltooling/signature/Signature.h>
28 #include <xercesc/util/XMLUniDefs.hpp>
29 #include <xsec/dsig/DSIGReference.hpp>
30 #include <xsec/dsig/DSIGTransformC14n.hpp>
32 using namespace opensaml;
35 class _addprefix : public binary_function<DSIGTransformC14n*,string,void> {
37 void operator()(DSIGTransformC14n* t, const string& s) const {
39 t->addInclusiveNamespace("#default");
41 t->addInclusiveNamespace(s.c_str());
45 void ContentReference::createReferences(DSIGSignature* sig)
47 DSIGReference* ref=NULL;
48 const XMLCh* id=m_signableObject.getXMLID();
50 ref=sig->createReference(&chNull); // whole doc reference
52 XMLCh* buf=new XMLCh[XMLString::stringLen(id) + 2];
55 XMLString::catString(buf,id);
57 ref=sig->createReference(buf);
65 ref->appendEnvelopedSignatureTransform();
66 DSIGTransformC14n* c14n=ref->appendCanonicalizationTransform(CANON_C14NE_NOC);
67 for_each(m_prefixes.begin(), m_prefixes.end(), bind1st(_addprefix(),c14n));