b275c28a934cf3c81c9ecd350b8e36ff233b0e95
[shibboleth/cpp-xmltooling.git] / xmltooling / signature / SignatureValidator.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 xmltooling/signature/SignatureValidator.h
19  * 
20  * Validator for signatures based on an externally-supplied key.
21  */
22
23 #if !defined(__xmltooling_sigval_h__) && !defined(XMLTOOLING_NO_XMLSEC)
24 #define __xmltooling_sigval_h__
25
26 #include <xmltooling/validation/Validator.h>
27
28 class XSECCryptoKey;
29
30 namespace xmltooling {
31     class XMLTOOL_API Credential;
32 };
33
34 namespace xmlsignature {
35
36     class XMLTOOL_API Signature;
37
38     /**
39      * Validator for signatures based on a Credential
40      */
41     class XMLTOOL_API SignatureValidator : public xmltooling::Validator
42     {
43     public:
44         /**
45          * Constructor using a key
46          * 
47          * @param key the key to use
48          */
49         SignatureValidator(XSECCryptoKey* key=nullptr);
50
51         /**
52          * Constructor using a Credential
53          * 
54          * @param credential the credential to use
55          */
56         SignatureValidator(const xmltooling::Credential* credential);
57
58         virtual ~SignatureValidator();
59
60         void validate(const xmltooling::XMLObject* xmlObject) const;
61
62         /**
63          * Type-safe validator.
64          * 
65          * @param signature object to validate
66          */
67         virtual void validate(const Signature* signature) const;
68         
69         /**
70          * Replace the current key, if any, with a new one.
71          * 
72          * @param key  the key to attach 
73          */
74         void setKey(XSECCryptoKey* key);
75
76         /**
77          * Replace the current Credential, if any, with a new one.
78          * 
79          * @param credential  the Credential to attach 
80          */
81         void setCredential(const xmltooling::Credential* credential);
82     
83     protected:
84         /** Verification key. */
85         XSECCryptoKey* m_key;
86
87         /** Verification credential. */
88         const xmltooling::Credential* m_credential;
89     };
90
91 };
92
93 #endif /* __xmltooling_sigval_h__ */