b0b2cf8084b0924808fa6e812597f51e3ddeac8b
[shibboleth/cpp-xmltooling.git] / xmltooling / security / X509TrustEngine.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/security/X509TrustEngine.h\r
19  * \r
20  * Extended TrustEngine interface that adds validation of X.509 credentials.\r
21  */\r
22 \r
23 #if !defined(__xmltooling_x509trust_h__) && !defined(XMLTOOLING_NO_XMLSEC)\r
24 #define __xmltooling_x509trust_h__\r
25 \r
26 #include <xmltooling/security/TrustEngine.h>\r
27 \r
28 namespace xmltooling {\r
29 \r
30     /**\r
31      * Extended TrustEngine interface that adds validation of X.509 credentials.\r
32      */\r
33     class XMLTOOL_API X509TrustEngine : public TrustEngine {\r
34     protected:\r
35         /**\r
36          * Constructor.\r
37          * \r
38          * If a DOM is supplied, the following XML content is supported:\r
39          * \r
40          * <ul>\r
41          *  <li>&lt;KeyResolver&gt; elements with a type attribute\r
42          * </ul>\r
43          * \r
44          * XML namespaces are ignored in the processing of this content.\r
45          * \r
46          * @param e DOM to supply configuration for provider\r
47          */\r
48         X509TrustEngine(const DOMElement* e=NULL) : TrustEngine(e) {}\r
49         \r
50     public:\r
51         virtual ~X509TrustEngine() {}\r
52         \r
53         /**\r
54          * Determines whether an X.509 credential is valid with respect to the\r
55          * KeyInfo data supplied. It is the responsibility of the application to\r
56          * ensure that the KeyInfo information supplied is in fact associated with\r
57          * the peer who presented the signature. \r
58          * \r
59          * A custom KeyResolver can be supplied from outside the TrustEngine.\r
60          * Alternatively, one may be specified to the plugin constructor.\r
61          * A non-caching, inline resolver will be used as a fallback.\r
62          * \r
63          * @param certEE        end-entity certificate to validate\r
64          * @param certChain     the complete set of certificates presented for validation (includes certEE)\r
65          * @param keyInfoSource supplies KeyInfo objects to the TrustEngine\r
66          * @param checkName     true iff certificate subject/name checking has <b>NOT</b> already occurred\r
67          * @param keyResolver   optional externally supplied KeyResolver, or NULL\r
68          */\r
69         virtual bool validate(\r
70             XSECCryptoX509* certEE,\r
71             const std::vector<XSECCryptoX509*>& certChain,\r
72             TrustEngine::KeyInfoIterator& keyInfoSource,\r
73             bool checkName=true,\r
74             const xmlsignature::KeyResolver* keyResolver=NULL\r
75             ) const=0;\r
76     };\r
77     \r
78 };\r
79 \r
80 #endif /* __xmltooling_x509trust_h__ */\r