0d45321d41a1a0b737b9f7b3b2740263c049c1b5
[shibboleth/cpp-xmltooling.git] / xmltooling / security / X509TrustEngine.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/X509TrustEngine.h
19  * 
20  * Extended TrustEngine interface that adds validation of X.509 credentials.
21  */
22
23 #if !defined(__xmltooling_x509trust_h__) && !defined(XMLTOOLING_NO_XMLSEC)
24 #define __xmltooling_x509trust_h__
25
26 #include <xmltooling/security/TrustEngine.h>
27
28 namespace xmltooling {
29
30     /**
31      * Extended TrustEngine interface that adds validation of X.509 credentials.
32      */
33     class XMLTOOL_API X509TrustEngine : public TrustEngine {
34     protected:
35         /**
36          * Constructor.
37          * 
38          * If a DOM is supplied, the following XML content is supported:
39          * 
40          * <ul>
41          *  <li>&lt;KeyInfoResolver&gt; elements with a type attribute
42          * </ul>
43          * 
44          * XML namespaces are ignored in the processing of this content.
45          * 
46          * @param e DOM to supply configuration for provider
47          */
48         X509TrustEngine(const xercesc::DOMElement* e=NULL) : TrustEngine(e) {}
49         
50     public:
51         virtual ~X509TrustEngine() {}
52
53         virtual bool validate(
54             xmlsignature::Signature& sig,
55             const CredentialResolver& credResolver,
56             CredentialCriteria* criteria=NULL
57             ) const=0;
58
59         virtual bool validate(
60             const XMLCh* sigAlgorithm,
61             const char* sig,
62             xmlsignature::KeyInfo* keyInfo,
63             const char* in,
64             unsigned int in_len,
65             const CredentialResolver& credResolver,
66             CredentialCriteria* criteria=NULL
67             ) const=0;
68
69         /**
70          * Determines whether an X.509 credential is valid with respect to the
71          * source of credentials supplied.
72          * 
73          * <p>It is the responsibility of the application to ensure that the credentials
74          * supplied are in fact associated with the peer who presented the credential.
75          * 
76          * <p>If criteria with a peer name are supplied, the "name" of the EE certificate
77          * may also be checked to ensure that it identifies the intended peer.
78          * The peer name itself or implementation-specific rules based on the content of the
79          * peer credentials may be applied. Implementations may omit this check if they
80          * deem it unnecessary.
81          * 
82          * @param certEE        end-entity certificate to validate
83          * @param certChain     the complete set of certificates presented for validation (includes certEE)
84          * @param credResolver  a locked resolver to supply trusted peer credentials to the TrustEngine
85          * @param criteria      criteria for selecting peer credentials
86          */
87         virtual bool validate(
88             XSECCryptoX509* certEE,
89             const std::vector<XSECCryptoX509*>& certChain,
90             const CredentialResolver& credResolver,
91             CredentialCriteria* criteria=NULL
92             ) const=0;
93     };
94     
95 };
96
97 #endif /* __xmltooling_x509trust_h__ */