f04b724c8b0b390a252bd20759de44b9964703ca
[shibboleth/cpp-xmltooling.git] / xmltooling / signature / SigningContext.h
1 /*\r
2  *  Copyright 2001-2006 Internet2\r
3  * \r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 /**\r
18  * @file SigningContext.h\r
19  * \r
20  * Interface to signing process supplied by a signing application \r
21  */\r
22 \r
23 #if !defined(__xmltooling_signctx_h__) && !defined(XMLTOOLING_NO_XMLSEC)\r
24 #define __xmltooling_signctx_h__\r
25 \r
26 #include <xmltooling/signature/KeyInfo.h>\r
27 #include <xmltooling/util/CredentialResolver.h>\r
28 \r
29 #include <vector>\r
30 #include <xsec/dsig/DSIGSignature.hpp>\r
31 \r
32 #if defined (_MSC_VER)\r
33     #pragma warning( push )\r
34     #pragma warning( disable : 4250 4251 )\r
35 #endif\r
36 \r
37 namespace xmlsignature {\r
38 \r
39     /**\r
40      * Interface to signing process supplied by a signing application\r
41      */\r
42     class XMLTOOL_API SigningContext\r
43     {\r
44         MAKE_NONCOPYABLE(SigningContext);\r
45     public:\r
46         virtual ~SigningContext() {}\r
47 \r
48         /**\r
49          * Given a "blank" native signature, asks the context to define the\r
50          * appropriate signature transforms, references, etc. The context\r
51          * should return true iff the necessary ds:KeyInfo information was\r
52          * also attached.\r
53          * \r
54          * @param sig   native signature interface\r
55          * @return      indicator whether ds:KeyInfo was created by context\r
56          */\r
57         virtual bool createSignature(DSIGSignature* sig)=0;\r
58         \r
59         /**\r
60          * Gets a reference to a credential resolver.\r
61          * The resolver's certificates will be included in the signature only\r
62          * if the context returns false when creating the signature and returns\r
63          * NULL from the getKeyInfo() method.\r
64          * \r
65          * \r
66          * @return  a resolver to the credentials to sign with\r
67          */\r
68         virtual xmltooling::CredentialResolver& getCredentialResolver()=0;\r
69 \r
70         /**\r
71          * Gets a KeyInfo structure to embed.\r
72          * Ownership of the object MUST be transferred to the caller.\r
73          * \r
74          * @return  pointer to a KeyInfo structure, will be freed by caller\r
75          */\r
76         virtual KeyInfo* getKeyInfo()=0;\r
77 \r
78     protected:\r
79         SigningContext() {}\r
80     };\r
81 \r
82 };\r
83 \r
84 #if defined (_MSC_VER)\r
85     #pragma warning( pop )\r
86 #endif\r
87 \r
88 #endif /* __xmltooling_signctx_h__ */\r