65f5bdf4cb61cf5a37bbc8d4804c82775f86d240
[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  */
20
21 /**
22  * @file shibsp/security/SecurityPolicyProvider.h
23  * 
24  * Interface to a source of security policy settings and rules.
25  */
26
27 #ifndef __shibsp_policyfactory_h__
28 #define __shibsp_policyfactory_h__
29
30 #ifndef SHIBSP_LITE
31
32 #include <shibsp/base.h>
33
34 #include <vector>
35 #include <xmltooling/Lockable.h>
36 #include <xmltooling/unicode.h>
37
38 namespace xmltooling {
39     class XMLTOOL_API QName;
40 };
41
42 namespace opensaml {
43     class SAML_API SecurityPolicyRule;
44 };
45
46 namespace shibsp {
47
48     class SHIBSP_API Application;
49     class SHIBSP_API PropertySet;
50     class SHIBSP_API SecurityPolicy;
51
52     /**
53      * Interface to a source of security policy settings and rules.
54      */
55         class SHIBSP_API SecurityPolicyProvider : public virtual xmltooling::Lockable
56     {
57         MAKE_NONCOPYABLE(SecurityPolicyProvider);
58     protected:
59         SecurityPolicyProvider();
60     public:
61         virtual ~SecurityPolicyProvider();
62         
63         /**
64                  * Returns the security policy settings for an identified policy.
65          *
66                  * @param id    identifies the policy to return, or nullptr for default
67          * @return a PropertySet
68                  */
69         virtual const PropertySet* getPolicySettings(const char* id=nullptr) const=0;
70
71         /**
72                  * Returns the security policy rules for an identified policy.
73          *
74                  * @param id    identifies the policy to return, or nullptr for default
75          * @return an array of policy rules
76                  */
77         virtual const std::vector<const opensaml::SecurityPolicyRule*>& getPolicyRules(const char* id=nullptr) const=0;
78
79         /**
80          * Returns a set of XML Signature/Encryption algorithm identifiers to block.
81          *
82          * @return  an array of algorithm URIs to block
83          */
84         virtual const std::vector<xmltooling::xstring>& getAlgorithmBlacklist() const=0;
85
86         /**
87          * Returns a set of XML Signature/Encryption algorithm identifiers to permit.
88          *
89          * @return  an array of algorithm URIs to permit
90          */
91         virtual const std::vector<xmltooling::xstring>& getAlgorithmWhitelist() const=0;
92
93         /**
94          * Returns a SecurityPolicy applicable to an application and/or policy identifier.
95          *
96          * <p>The caller <strong>MUST</strong> lock the application's MetadataProvider for the life
97          * of the returned object.
98          *
99          * @param application   reference to application applying policy
100          * @param role          identifies the role (generally IdP or SP) of the policy peer
101          * @param policyId      identifies policy, defaults to the application's default
102          * @return  a new policy instance, which the caller is responsible for freeing
103          */
104         virtual SecurityPolicy* createSecurityPolicy(
105             const Application& application, const xmltooling::QName* role, const char* policyId=nullptr
106             ) const;
107     };
108
109     /**
110      * Registers SecurityPolicyProvider classes into the runtime.
111      */
112     void SHIBSP_API registerSecurityPolicyProviders();
113
114     /** SecurityPolicyProvider based on an XML configuration format. */
115     #define XML_SECURITYPOLICY_PROVIDER "XML"
116 };
117
118 #endif
119
120 #endif /* __shibsp_policyfactory_h__ */