Merge branch '1.x' of ssh://authdev.it.ohio-state.edu/~scantor/git/cpp-xmltooling...
[shibboleth/cpp-xmltooling.git] / xmltooling / security / X509TrustEngine.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/X509TrustEngine.h
23  * 
24  * TrustEngine interface that adds validation of X.509 credentials.
25  */
26
27 #if !defined(__xmltooling_x509trust_h__) && !defined(XMLTOOLING_NO_XMLSEC)
28 #define __xmltooling_x509trust_h__
29
30 #include <xmltooling/security/TrustEngine.h>
31
32 #include <vector>
33
34 class XSECCryptoX509;
35
36 namespace xmltooling {
37
38     class XMLTOOL_API CredentialCriteria;
39     class XMLTOOL_API CredentialResolver;
40
41     /**
42      * TrustEngine interface that adds validation of X.509 credentials.
43      */
44     class XMLTOOL_API X509TrustEngine : public virtual TrustEngine {
45     protected:
46         /**
47          * Constructor.
48          * 
49          * @param e DOM to supply configuration for provider
50          */
51         X509TrustEngine(const xercesc::DOMElement* e=nullptr);
52         
53     public:
54         virtual ~X509TrustEngine();
55
56         /**
57          * Determines whether an X.509 credential is valid with respect to the
58          * source of credentials supplied.
59          * 
60          * <p>It is the responsibility of the application to ensure that the credentials
61          * supplied are in fact associated with the peer who presented the credential.
62          * 
63          * <p>If criteria with a peer name are supplied, the "name" of the EE certificate
64          * may also be checked to ensure that it identifies the intended peer.
65          * The peer name itself or implementation-specific rules based on the content of the
66          * peer credentials may be applied. Implementations may omit this check if they
67          * deem it unnecessary.
68          * 
69          * @param certEE        end-entity certificate to validate
70          * @param certChain     the complete set of certificates presented for validation (includes certEE)
71          * @param credResolver  a locked resolver to supply trusted peer credentials to the TrustEngine
72          * @param criteria      criteria for selecting peer credentials
73          */
74         virtual bool validate(
75             XSECCryptoX509* certEE,
76             const std::vector<XSECCryptoX509*>& certChain,
77             const CredentialResolver& credResolver,
78             CredentialCriteria* criteria=nullptr
79             ) const=0;
80     };
81     
82 };
83
84 #endif /* __xmltooling_x509trust_h__ */