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