6c25ec46c12680a09423bf0b8fda7e452988a0bf
[shibboleth/cpp-xmltooling.git] / xmltooling / security / TrustEngine.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/TrustEngine.h
19  * 
20  * Evaluates the trustworthiness and validity of security information against
21  * implementation-specific requirements.
22  */
23
24 #if !defined(__xmltooling_trust_h__) && !defined(XMLTOOLING_NO_XMLSEC)
25 #define __xmltooling_trust_h__
26
27 #include <xmltooling/base.h>
28 #include <xercesc/dom/DOM.hpp>
29
30 namespace xmltooling {
31
32     class XMLTOOL_API KeyInfoResolver;
33
34     /**
35      * Evaluates the trustworthiness and validity of security information against
36      * implementation-specific requirements.
37      */
38     class XMLTOOL_API TrustEngine {
39         MAKE_NONCOPYABLE(TrustEngine);
40     protected:
41         /**
42          * Constructor.
43          * 
44          * If a DOM is supplied, the following XML content is supported:
45          * 
46          * <ul>
47          *  <li>&lt;KeyInfoResolver&gt; elements with a type attribute
48          * </ul>
49          * 
50          * XML namespaces are ignored in the processing of this content.
51          * 
52          * @param e DOM to supply configuration for provider
53          */
54         TrustEngine(const xercesc::DOMElement* e=nullptr);
55         
56         /** Custom KeyInfoResolver instance. */
57         KeyInfoResolver* m_keyInfoResolver;
58         
59     public:
60         virtual ~TrustEngine();
61
62         /**
63          * Supplies a KeyInfoResolver instance.
64          * <p>This method must be externally synchronized with any code that uses the object.
65          * Any previously set object is destroyed.
66          * 
67          * @param keyInfoResolver   new KeyInfoResolver instance to use
68          */
69         void setKeyInfoResolver(KeyInfoResolver* keyInfoResolver);
70     };
71
72     /**
73      * Registers TrustEngine classes into the runtime.
74      */
75     void XMLTOOL_API registerTrustEngines();
76
77     /** TrustEngine based on explicit knowledge of peer key information. */
78     #define EXPLICIT_KEY_TRUSTENGINE  "ExplicitKey"
79
80     /** TrustEngine based on PKIX evaluation against a static set of trust anchors. */
81     #define STATIC_PKIX_TRUSTENGINE  "StaticPKIX"
82
83     /** TrustEngine that tries multiple engines in sequence. */
84     #define CHAINING_TRUSTENGINE  "Chaining"
85     
86 };
87
88 #endif /* __xmltooling_trust_h__ */