Added abstract metadata base, chaining trust and metadata plugins.
[shibboleth/cpp-opensaml.git] / saml / security / ChainingTrustEngine.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/ChainingTrustEngine.h\r
19  * \r
20  * X509TrustEngine that uses multiple engines in sequence.\r
21  */\r
22 \r
23 #ifndef __saml_chaintrust_h__\r
24 #define __saml_chaintrust_h__\r
25 \r
26 #include <saml/security/X509TrustEngine.h>\r
27 \r
28 namespace opensaml {\r
29 \r
30     /**\r
31      * X509TrustEngine that uses multiple engines in sequence.\r
32      */\r
33     class SAML_API ChainingTrustEngine : public X509TrustEngine {\r
34     public:\r
35         /**\r
36          * Constructor.\r
37          * \r
38          * If a DOM is supplied, the following XML content is supported:\r
39          * \r
40          * <ul>\r
41          *  <li>&lt;TrustEngine&gt; elements with a type attribute\r
42          * </ul>\r
43          * \r
44          * XML namespaces are ignored in the processing of this content.\r
45          * \r
46          * @param e DOM to supply configuration for provider\r
47          */\r
48         ChainingTrustEngine(const DOMElement* e=NULL);\r
49         \r
50         /**\r
51          * Destructor will delete any embedded engines.\r
52          */\r
53         virtual ~ChainingTrustEngine();\r
54 \r
55         /**\r
56          * Adds a trust engine for future calls.\r
57          * \r
58          * @param newEngine trust engine to add\r
59          */\r
60         void addTrustEngine(X509TrustEngine* newEngine) {\r
61             m_engines.push_back(newEngine);\r
62         }\r
63 \r
64         /**\r
65          * Removes a trust engine. The caller must delete the engine if necessary.\r
66          * \r
67          * @param oldEngine trust engine to remove\r
68          * @return  the old engine\r
69          */\r
70         X509TrustEngine* removeTrustEngine(X509TrustEngine* oldEngine) {\r
71             for (std::vector<X509TrustEngine*>::iterator i=m_engines.begin(); i!=m_engines.end(); i++) {\r
72                 if (oldEngine==(*i)) {\r
73                     m_engines.erase(i);\r
74                     return oldEngine;\r
75                 }\r
76             }\r
77             return NULL;\r
78         }\r
79 \r
80         virtual bool validate(\r
81             xmlsignature::Signature& sig,\r
82             const saml2md::RoleDescriptor& role,\r
83             const xmlsignature::KeyResolver* keyResolver=NULL\r
84             );\r
85         virtual bool validate(\r
86             XSECCryptoX509* certEE,\r
87             const std::vector<XSECCryptoX509*>& certChain,\r
88             const saml2md::RoleDescriptor& role,\r
89             bool checkName=true,\r
90             const xmlsignature::KeyResolver* keyResolver=NULL\r
91             );\r
92 \r
93     private:\r
94         std::vector<X509TrustEngine*> m_engines;\r
95     };\r
96     \r
97 };\r
98 \r
99 #endif /* __saml_chaintrust_h__ */\r