Merge branch '1.x' of ssh://authdev.it.ohio-state.edu/~scantor/git/cpp-xmltooling...
[shibboleth/cpp-xmltooling.git] / xmltooling / security / OpenSSLTrustEngine.h
1 /**
2  * Licensed to the University Corporation for Advanced Internet
3  * Development, Inc. (UCAID) under one or more contributor license
4  * agreements. See the NOTICE file distributed with this work for
5  * additional information regarding copyright ownership.
6  *
7  * UCAID licenses this file to you under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. You may obtain a copy of the
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the License.
19  */
20
21 /**
22  * @file xmltooling/security/OpenSSLTrustEngine.h
23  * 
24  * Extended TrustEngine interface that adds validation of X.509 credentials
25  * using OpenSSL data types directly for efficiency.
26  */
27
28 #if !defined(__xmltooling_openssltrust_h__) && !defined(XMLTOOLING_NO_XMLSEC)
29 #define __xmltooling_openssltrust_h__
30
31 #include <xmltooling/security/X509TrustEngine.h>
32
33 #include <openssl/x509.h>
34
35 namespace xmltooling {
36
37     /**
38      * Extended TrustEngine interface that adds validation of X.509 credentials
39      * using OpenSSL data types directly for efficiency.
40      */
41     class XMLTOOL_API OpenSSLTrustEngine : public X509TrustEngine {
42     protected:
43         /**
44          * Constructor.
45          * 
46          * @param e DOM to supply configuration for provider
47          */
48         OpenSSLTrustEngine(const xercesc::DOMElement* e=nullptr);
49         
50     public:
51         virtual ~OpenSSLTrustEngine();
52
53         using X509TrustEngine::validate;
54
55         /**
56          * Determines whether an X.509 credential is valid with respect to the
57          * source of credentials supplied.
58          * 
59          * <p>It is the responsibility of the application to ensure that the credentials
60          * supplied are in fact associated with the peer who presented the credential.
61          * 
62          * <p>If criteria with a peer name are supplied, the "name" of the EE certificate
63          * may also be checked to ensure that it identifies the intended peer.
64          * The peer name itself or implementation-specific rules based on the content of the
65          * peer credentials may be applied. Implementations may omit this check if they
66          * deem it unnecessary.
67          * 
68          * @param certEE        end-entity certificate to validate
69          * @param certChain     the complete set of certificates presented for validation (includes certEE)
70          * @param credResolver  a locked resolver to supply trusted peer credentials to the TrustEngine
71          * @param criteria      criteria for selecting peer credentials
72          */
73         virtual bool validate(
74             X509* certEE, STACK_OF(X509)* certChain,
75             const CredentialResolver& credResolver,
76             CredentialCriteria* criteria=nullptr
77             ) const=0;
78     };
79     
80 };
81
82 #endif /* __xmltooling_openssltrust_h__ */