f7fb4b8dace49ac676bcc353614f2e3f7aba1735
[shibboleth/cpp-xmltooling.git] / xmltooling / security / OpenSSLTrustEngine.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/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          * @param e DOM to supply configuration for provider
43          */
44         OpenSSLTrustEngine(const xercesc::DOMElement* e=nullptr);
45         
46     public:
47         virtual ~OpenSSLTrustEngine();
48
49         using X509TrustEngine::validate;
50
51         /**
52          * Determines whether an X.509 credential is valid with respect to the
53          * source of credentials supplied.
54          * 
55          * <p>It is the responsibility of the application to ensure that the credentials
56          * supplied are in fact associated with the peer who presented the credential.
57          * 
58          * <p>If criteria with a peer name are supplied, the "name" of the EE certificate
59          * may also be checked to ensure that it identifies the intended peer.
60          * The peer name itself or implementation-specific rules based on the content of the
61          * peer credentials may be applied. Implementations may omit this check if they
62          * deem it unnecessary.
63          * 
64          * @param certEE        end-entity certificate to validate
65          * @param certChain     the complete set of certificates presented for validation (includes certEE)
66          * @param credResolver  a locked resolver to supply trusted peer credentials to the TrustEngine
67          * @param criteria      criteria for selecting peer credentials
68          */
69         virtual bool validate(
70             X509* certEE, STACK_OF(X509)* certChain,
71             const CredentialResolver& credResolver,
72             CredentialCriteria* criteria=nullptr
73             ) const=0;
74     };
75     
76 };
77
78 #endif /* __xmltooling_openssltrust_h__ */