231ae068818a89ceb1bbc5156090011bd2a6d748
[shibboleth/sp.git] / shibsp / security / SecurityPolicyProvider.h
1 /**
2  * Licensed to the University Corporation for Advanced Internet
3  * Development, Inc. (UCAID) under one or more contributor license
4  * agreements. See the NOTICE file distributed with this work for
5  * additional information regarding copyright ownership.
6  *
7  * UCAID licenses this file to you under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. You may obtain a copy of the
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the License.
19  */\r
20 \r
21 /**\r
22  * @file shibsp/security/SecurityPolicyProvider.h\r
23  * \r
24  * Interface to a source of security policy settings and rules.\r
25  */\r
26 \r
27 #ifndef __shibsp_policyfactory_h__\r
28 #define __shibsp_policyfactory_h__\r
29 \r
30 #ifndef SHIBSP_LITE\r
31 \r
32 #include <shibsp/base.h>\r
33 \r
34 #include <vector>\r
35 #include <xmltooling/Lockable.h>\r
36 #include <xmltooling/unicode.h>\r
37 \r
38 namespace xmltooling {\r
39     class XMLTOOL_API QName;\r
40 };\r
41 \r
42 namespace opensaml {\r
43     class SAML_API SecurityPolicyRule;\r
44 };\r
45 \r
46 namespace shibsp {\r
47 \r
48     class SHIBSP_API Application;\r
49     class SHIBSP_API PropertySet;\r
50     class SHIBSP_API SecurityPolicy;\r
51 \r
52     /**\r
53      * Interface to a source of security policy settings and rules.\r
54      */\r
55         class SHIBSP_API SecurityPolicyProvider : public virtual xmltooling::Lockable\r
56     {\r
57         MAKE_NONCOPYABLE(SecurityPolicyProvider);\r
58     protected:\r
59         SecurityPolicyProvider();\r
60     public:\r
61         virtual ~SecurityPolicyProvider();\r
62         \r
63         /**\r
64                  * Returns the security policy settings for an identified policy.\r
65          *\r
66                  * @param id    identifies the policy to return, or nullptr for default\r
67          * @return a PropertySet\r
68                  */\r
69         virtual const PropertySet* getPolicySettings(const char* id=nullptr) const=0;\r
70 \r
71         /**\r
72                  * Returns the security policy rules for an identified policy.\r
73          *\r
74                  * @param id    identifies the policy to return, or nullptr for default\r
75          * @return an array of policy rules\r
76                  */\r
77         virtual const std::vector<const opensaml::SecurityPolicyRule*>& getPolicyRules(const char* id=nullptr) const=0;\r
78 \r
79         /**\r
80          * Returns a set of XML Signature/Encryption algorithm identifiers to block.\r
81          *\r
82          * @return  an array of algorithm URIs to block\r
83          */\r
84         virtual const std::vector<xmltooling::xstring>& getAlgorithmBlacklist() const=0;\r
85 \r
86         /**\r
87          * Returns a set of XML Signature/Encryption algorithm identifiers to permit.\r
88          *\r
89          * @return  an array of algorithm URIs to permit\r
90          */\r
91         virtual const std::vector<xmltooling::xstring>& getAlgorithmWhitelist() const=0;\r
92 \r
93         /**\r
94          * Returns a SecurityPolicy applicable to an application and/or policy identifier.\r
95          *\r
96          * <p>The caller <strong>MUST</strong> lock the application's MetadataProvider for the life\r
97          * of the returned object.\r
98          *\r
99          * @param application   reference to application applying policy\r
100          * @param role          identifies the role (generally IdP or SP) of the policy peer\r
101          * @param policyId      identifies policy, defaults to the application's default\r
102          * @return  a new policy instance, which the caller is responsible for freeing\r
103          */\r
104         virtual SecurityPolicy* createSecurityPolicy(\r
105             const Application& application, const xmltooling::QName* role, const char* policyId=nullptr\r
106             ) const;\r
107     };\r
108 \r
109     /**\r
110      * Registers SecurityPolicyProvider classes into the runtime.\r
111      */\r
112     void SHIBSP_API registerSecurityPolicyProviders();\r
113 \r
114     /** SecurityPolicyProvider based on an XML configuration format. */\r
115     #define XML_SECURITYPOLICY_PROVIDER "XML"\r
116 };\r
117 \r
118 #endif\r
119 \r
120 #endif /* __shibsp_policyfactory_h__ */\r