c688f71d491d2417ca79e1ffcc027fc74de16bcb
[shibboleth/cpp-opensaml.git] / saml / signature / ContentReference.h
1 /*
2  *  Copyright 2001-2010 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
28 #include <set>
29 #include <string>
30 #include <xmltooling/unicode.h>
31 #include <xmltooling/signature/ContentReference.h>
32
33 namespace xmltooling {
34     class XMLTOOL_API Namespace;
35     class XMLTOOL_API XMLObject;
36 };
37
38 namespace opensaml {
39
40     class SAML_API SignableObject;
41
42 #if defined (_MSC_VER)
43     #pragma warning( push )
44     #pragma warning( disable : 4251 )
45 #endif
46
47     /**
48      * SAML-specific signature reference profile.
49      */
50     class SAML_API ContentReference : public virtual xmlsignature::ContentReference
51     {
52     public:
53         /**
54          * Constructor.
55          * 
56          * @param signableObject    reference to object being signed
57          */
58         ContentReference(const SignableObject& signableObject);
59     
60         virtual ~ContentReference();
61
62         /**
63          * Given a "blank" native signature, creates signature reference
64          * appropriate for the SAML object being signed.
65          * 
66          * @param sig   native signature interface
67          */
68         virtual void createReferences(DSIGSignature* sig);
69         
70         /**
71          * Adds a namespace prefix for "inclusive" processing by an
72          * Exclusive C14N Transform applied to the object.
73          * An empty string will be transformed into "#default".
74          * 
75          * @param prefix    the prefix to add 
76          */
77         void addInclusivePrefix(const XMLCh* prefix);
78         
79         /**
80          * Sets the digest algorithm for the signature reference,
81          * using a constant.
82          * 
83          * @param digest    the digest algorithm
84          */
85         void setDigestAlgorithm(const XMLCh* digest);
86
87         /**
88          * Sets the canonicalization method to include in the reference,
89          * using a constant.
90          * 
91          * @param c14n  the canonicalization method
92          */
93         void setCanonicalizationMethod(const XMLCh* c14n);
94         
95     private:
96         const SignableObject& m_signableObject;
97         std::set<xmltooling::xstring> m_prefixes;
98         const XMLCh* m_digest;
99         const XMLCh* m_c14n;
100     };
101
102 #if defined (_MSC_VER)
103     #pragma warning( pop )
104 #endif
105 };
106
107 #endif /* __saml_sigref_h__ */