Settable digest algorithm, enhanced prefix handling in signatures, pending xmlsec...
[shibboleth/cpp-opensaml.git] / saml / signature / ContentReference.h
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * @file saml/signature/ContentReference.h
19  * 
20  * SAML-specific signature reference profile 
21  */
22
23 #ifndef __saml_sigref_h__
24 #define __saml_sigref_h__
25
26 #include <saml/base.h>
27 #include <xmltooling/XMLObject.h>
28 #include <xmltooling/signature/ContentReference.h>
29
30 #include <set>
31 #include <string>
32
33 namespace opensaml {
34
35     class SAML_API SignableObject;
36
37     /**
38      * SAML-specific signature reference profile.
39      */
40     class SAML_API ContentReference : public virtual xmlsignature::ContentReference
41     {
42     public:
43         /**
44          * Constructor.
45          * 
46          * @param signableObject    reference to object being signed
47          */
48         ContentReference(const SignableObject& signableObject)
49             : m_signableObject(signableObject), m_digest(NULL), m_c14n(NULL) {
50         }
51     
52         virtual ~ContentReference() {}
53
54         /**
55          * Given a "blank" native signature, creates signature reference
56          * appropriate for the SAML object being signed.
57          * 
58          * @param sig   native signature interface
59          */
60         virtual void createReferences(DSIGSignature* sig);
61         
62         /**
63          * Adds a namespace prefix for "inclusive" processing by an
64          * Exclusive C14N Transform applied to the object.
65          * An empty string will be transformed into "#default".
66          * 
67          * @param prefix    the prefix to add 
68          */
69         void addInclusivePrefix(const XMLCh* prefix);
70         
71         /**
72          * Sets the digest algorithm for the signature reference,
73          * using a constant.
74          * 
75          * @param digest    the digest algorithm
76          */
77         void setDigestAlgorithm(const XMLCh* digest) {
78             m_digest = digest;
79         }
80
81         /**
82          * Sets the canonicalization method to include in the reference,
83          * using a constant.
84          * 
85          * @param c14n  the canonicalization method
86          */
87         void setCanonicalizationMethod(const XMLCh* c14n) {
88             m_c14n = c14n;
89         }
90         
91     private:
92         void addPrefixes(const std::set<xmltooling::Namespace>& namespaces);
93         void addPrefixes(const xmltooling::XMLObject& xmlObject);
94
95         const SignableObject& m_signableObject;
96 #ifdef HAVE_GOOD_STL
97         std::set<xmltooling::xstring> m_prefixes;
98 #else
99         std::set<std::string> m_prefixes;
100 #endif
101         const XMLCh* m_digest;
102         const XMLCh* m_c14n;
103     };
104
105 };
106
107 #endif /* __saml_sigref_h__ */