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