PKIX TrustEngine.
[shibboleth/cpp-opensaml.git] / saml / security / TrustEngine.h
1 /*\r
2  *  Copyright 2001-2006 Internet2\r
3  * \r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 /**\r
18  * @file saml/security/TrustEngine.h\r
19  * \r
20  * SAML-specific TrustEngine API\r
21  */\r
22 \r
23 #ifndef __saml_trust_h__\r
24 #define __saml_trust_h__\r
25 \r
26 #include <saml/base.h>\r
27 #include <saml/saml2/metadata/Metadata.h>\r
28 #include <xmltooling/signature/KeyResolver.h>\r
29 \r
30 namespace opensaml {\r
31 \r
32     /**\r
33      * Adapts SAML metadata as a source of KeyInfo for a TrustEngine\r
34      * and adds SAML-specific signature validation.\r
35      */\r
36     class SAML_API TrustEngine {\r
37         MAKE_NONCOPYABLE(TrustEngine);\r
38     protected:\r
39         /**\r
40          * Constructor.\r
41          * \r
42          * If a DOM is supplied, the following XML content is supported:\r
43          * \r
44          * <ul>\r
45          *  <li>&lt;KeyResolver&gt; elements with a type attribute\r
46          * </ul>\r
47          * \r
48          * XML namespaces are ignored in the processing of this content.\r
49          * \r
50          * @param e DOM to supply configuration for provider\r
51          */\r
52         TrustEngine(const DOMElement* e=NULL) {}\r
53         \r
54     public:\r
55         virtual ~TrustEngine() {}\r
56 \r
57         /**\r
58          * Determines whether a signed SAML object is correct and valid with respect\r
59          * to the information known about the issuer.\r
60          * \r
61          * A custom KeyResolver can be supplied from outside the TrustEngine.\r
62          * Alternatively, one may be specified to the plugin constructor.\r
63          * A non-caching, inline resolver will be used as a fallback.\r
64          * \r
65          * @param sig           reference to a signature object to validate\r
66          * @param role          metadata role supplying key information\r
67          * @param keyResolver   optional externally supplied KeyResolver, or NULL\r
68          */\r
69         virtual bool validate(\r
70             xmlsignature::Signature& sig,\r
71             const saml2md::RoleDescriptor& role,\r
72             const xmlsignature::KeyResolver* keyResolver=NULL\r
73             )=0;\r
74     };\r
75     \r
76 \r
77     /**\r
78      * Registers TrustEngine classes into the runtime.\r
79      */\r
80     void SAML_API registerTrustEngines();\r
81 \r
82     /** TrustEngine based on explicit key information resolved from metadata. */\r
83     #define EXPLICIT_KEY_SAMLTRUSTENGINE  "org.opensaml.security.ExplicitKeyTrustEngine"\r
84 };\r
85 \r
86 #endif /* __saml_trust_h__ */\r