Credential resolver plugin
[shibboleth/cpp-xmltooling.git] / xmltooling / signature / CredentialResolver.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 xmltooling/signature/CredentialResolver.h\r
19  * \r
20  * Resolves keys and certificates "owned" by an entity \r
21  */\r
22 \r
23 #if !defined(__xmltooling_credres_h__) && !defined(XMLTOOLING_NO_XMLSEC)\r
24 #define __xmltooling_credres_h__\r
25 \r
26 #include <xmltooling/Lockable.h>\r
27 \r
28 #include <vector>\r
29 #include <xsec/enc/XSECCryptoKey.hpp>\r
30 #include <xsec/enc/XSECCryptoX509.hpp>\r
31 \r
32 namespace xmlsignature {\r
33 \r
34     /**\r
35      * An API for resolving local/owned keys and certificates\r
36      */\r
37     class XMLTOOL_API CredentialResolver : public xmltooling::Lockable\r
38     {\r
39         MAKE_NONCOPYABLE(CredentialResolver);\r
40     protected:\r
41         CredentialResolver() {}\r
42         \r
43     public:\r
44         virtual ~CredentialResolver() {}\r
45         \r
46         /**\r
47          * Returns a secret or private key to use for signing operations.\r
48          * The caller is responsible for deleting the key when finished with it.\r
49          * \r
50          * @return  a secret or private key\r
51          */\r
52         virtual XSECCryptoKey* getKey() const=0;\r
53         \r
54         /**\r
55          * Returns a set of certificates to publish during signing operations.\r
56          * The certificates must be cloned if kept beyond the scope of a lock.\r
57          * \r
58          * @return  a set of certificates\r
59          */\r
60         virtual const std::vector<XSECCryptoX509*>& getCertificates() const=0;\r
61     };\r
62 \r
63     /**\r
64      * Registers CredentialResolver classes into the runtime.\r
65      */\r
66     void XMLTOOL_API registerCredentialResolvers();\r
67 \r
68     /** CredentialResolver based on local files */\r
69     #define FILESYSTEM_CREDENTIAL_RESOLVER  "org.opensaml.xmlooling.FilesystemCredentialResolver"\r
70 };\r
71 \r
72 #endif /* __xmltooling_credres_h__ */\r