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