Set fourth file version digit to signify rebuild.
[shibboleth/cpp-opensaml.git] / saml / binding / SecurityPolicyRule.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 saml/binding/SecurityPolicyRule.h
23  *
24  * Policy rules that secure and authenticate bindings.
25  */
26
27 #ifndef __saml_secrule_h__
28 #define __saml_secrule_h__
29
30 #include <saml/base.h>
31
32 namespace xmltooling {
33     class XMLTOOL_API GenericRequest;
34     class XMLTOOL_API XMLObject;
35 };
36
37 namespace opensaml {
38     class SAML_API SecurityPolicy;
39
40     /**
41      * A rule that a protocol request and message must meet in order to be valid and secure.
42      *
43      * <p>Rules must be stateless and thread-safe across evaluations. Evaluation should not
44      * result in an exception if the request/message properties do not apply to the rule
45      * (e.g. particular security mechanisms that are not present).
46      */
47     class SAML_API SecurityPolicyRule
48     {
49         MAKE_NONCOPYABLE(SecurityPolicyRule);
50     protected:
51         SecurityPolicyRule();
52     public:
53         virtual ~SecurityPolicyRule();
54
55         /**
56          * Returns the rule's class/type.
57          *
58          * @return  the class/type of the object
59          */
60         virtual const char* getType() const=0;
61
62         /**
63          * Evaluates the rule against the given request and message.
64          *
65          * <p>An exception will be raised if the message is fatally invalid according to
66          * a policy rule.
67          *
68          * <p>The return value is used to indicate whether a message was ignored or
69          * successfully processed. A false value signals that the rule wasn't successful
70          * because the rule was inapplicable to the message, but allows other rules to
71          * return an alternate result.
72          *
73          * @param message   the incoming message
74          * @param request   the protocol request
75          * @param policy    SecurityPolicy to provide various components and track message data
76          * @return  indicator as to whether a message was understood and processed
77          */
78         virtual bool evaluate(
79             const xmltooling::XMLObject& message,
80             const xmltooling::GenericRequest* request,
81             SecurityPolicy& policy
82             ) const=0;
83     };
84
85     /**
86      * Registers SecurityPolicyRule plugins into the runtime.
87      */
88     void SAML_API registerSecurityPolicyRules();
89
90     /**
91      * SecurityPolicyRule for evaluation of SAML AudienceRestriction Conditions.
92      */
93     #define AUDIENCE_POLICY_RULE        "Audience"
94
95     /**
96      * SecurityPolicyRule for evaluation of SAML DelegationRestriction Conditions.
97      */
98     #define DELEGATION_POLICY_RULE        "Delegation"
99
100     /**
101      * SecurityPolicyRule for TLS client certificate authentication.
102      *
103      * Evaluates client certificates against the issuer's metadata.
104      */
105     #define CLIENTCERTAUTH_POLICY_RULE  "ClientCertAuth"
106
107     /**
108      * SecurityPolicyRule for evaluation of SAML Conditions.
109      */
110     #define CONDITIONS_POLICY_RULE      "Conditions"
111
112     /**
113      * SecurityPolicyRule for ignoring a SAML Condition.
114      */
115     #define IGNORE_POLICY_RULE          "Ignore"
116
117     /**
118      * SecurityPolicyRule for replay detection and freshness checking.
119      *
120      * <p>A ReplayCache instance must be available from the runtime, unless
121      * a "checkReplay" XML attribute is set to "0" or "false" when instantiating
122      * the policy rule.
123      *
124      * <p>Messages must have been issued in the past, but no more than 60 seconds ago,
125      * or up to a number of seconds set by an "expires" XML attribute when
126      * instantiating the policy rule.
127      */
128     #define MESSAGEFLOW_POLICY_RULE     "MessageFlow"
129
130     /**
131      * SecurityPolicyRule for disabling security.
132      *
133      * Allows the message issuer to be authenticated regardless of the message or
134      * transport. Used mainly for debugging or in situations that I wouldn't care to
135      * comment on.
136      */
137     #define NULLSECURITY_POLICY_RULE    "NullSecurity"
138
139     /**
140      * SecurityPolicyRule for protocol message "blob" signing.
141      *
142      * Allows the message issuer to be authenticated using a non-XML digital signature
143      * over the message body. The transport layer is not considered.
144      */
145     #define SIMPLESIGNING_POLICY_RULE   "SimpleSigning"
146
147     /**
148      * SecurityPolicyRule for protocol message XML signing.
149      *
150      * Allows the message issuer to be authenticated using an XML digital signature
151      * over the message. The transport layer is not considered.
152      */
153     #define XMLSIGNING_POLICY_RULE      "XMLSigning"
154
155     /**
156      * SecurityPolicyRule for SAML 1.x Browser SSO profile validation.
157      *
158      * Enforces presence of time conditions and proper subject confirmation.
159      */
160     #define SAML1BROWSERSSO_POLICY_RULE "SAML1BrowserSSO"
161
162     /**
163      * SecurityPolicyRule for SAML 2.0 bearer SubjectConfirmation.
164      *
165      * <p>Optionally enforces message delivery requirements based on SubjectConfirmationData.
166      *
167      * <p>The XML attributes "checkValidity", "checkRecipient", and "checkCorrelation" can be set
168      * "false" to disable checks of NotBefore/NotOnOrAfter, Recipient, and InResponseTo confirmation
169      * data respectively.
170      */
171     #define BEARER_POLICY_RULE "Bearer"
172 };
173
174 #endif /* __saml_secrule_h__ */