SSPCPP-697 - Align the filter schema(s) and functor types where feasible.
[shibboleth/cpp-sp.git] / shibsp / attribute / filtering / MatchFunctor.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/attribute/filtering/MatchFunctor.h
23  * 
24  * A function that evaluates whether an expressed criteria is met by the current filter context.
25  */
26
27 #ifndef __shibsp_matchfunc_h__
28 #define __shibsp_matchfunc_h__
29
30 #include <shibsp/base.h>
31
32 namespace shibsp {
33
34     class SHIBSP_API Attribute;
35     class SHIBSP_API FilteringContext;
36
37     /**
38      * A function that evaluates whether an expressed criteria is met by the current filter context.
39      */
40     class SHIBSP_API MatchFunctor
41     {
42         MAKE_NONCOPYABLE(MatchFunctor);
43     protected:
44         MatchFunctor();
45     public:
46         virtual ~MatchFunctor();
47
48         /**
49          * Evaluates this matching criteria. This evaluation is used when a filtering engine determines policy
50          * applicability.
51          * 
52          * @param filterContext current filtering context
53          * @return true if the criteria for this matching function are met
54          * @throws AttributeFilteringException thrown if the function can not be evaluated
55          */
56         virtual bool evaluatePolicyRequirement(const FilteringContext& filterContext) const=0;
57
58         /**
59          * Evaluates this matching criteria. This evaluation is used when a filtering engine is filtering attribute
60          * values.
61          * 
62          * @param filterContext the current filtering context
63          * @param attribute     the attribute being evaluated
64          * @param index         the index of the attribute value being evaluated
65          * @return true if the criteria for this matching function are met
66          * @throws AttributeFilteringException thrown if the function can not be evaluated
67          */
68         virtual bool evaluatePermitValue(const FilteringContext& filterContext, const Attribute& attribute, size_t index) const=0;
69     };
70
71     /** Always evaluates to true. */
72     extern SHIBSP_API xmltooling::QName AnyMatchFunctorType;
73
74     /** Conjunction MatchFunctor. */
75     extern SHIBSP_API xmltooling::QName AndMatchFunctorType;
76
77     /** Disjunction MatchFunctor. */
78     extern SHIBSP_API xmltooling::QName OrMatchFunctorType;
79
80     /** Negating MatchFunctor. */
81     extern SHIBSP_API xmltooling::QName NotMatchFunctorType;
82
83     /** Matches the issuing entity's name. */
84     extern SHIBSP_API xmltooling::QName AttributeIssuerStringType;
85
86     /** Matches the requesting entity's name. */
87     extern SHIBSP_API xmltooling::QName AttributeRequesterStringType;
88
89     /** Matches the principal's authentication method/class or context reference. */
90     extern SHIBSP_API xmltooling::QName AuthenticationMethodStringType;
91
92     /** Matches an attribute's string value. */
93     extern SHIBSP_API xmltooling::QName AttributeValueStringType;
94
95     /** Matches an attribute's "scope". */
96     extern SHIBSP_API xmltooling::QName AttributeScopeStringType;
97
98     /** Matches the issuing entity's name. */
99     extern SHIBSP_API xmltooling::QName AttributeIssuerRegexType;
100
101     /** Matches the requesting entity's name. */
102     extern SHIBSP_API xmltooling::QName AttributeRequesterRegexType;
103
104     /** Matches the principal's authentication method/class or context reference. */
105     extern SHIBSP_API xmltooling::QName AuthenticationMethodRegexType;
106
107     /** Matches an attribute's string value. */
108     extern SHIBSP_API xmltooling::QName AttributeValueRegexType;
109
110     /** Matches an attribute's "scope". */
111     extern SHIBSP_API xmltooling::QName AttributeScopeRegexType;
112
113     /** Matches based on the number of values. */
114     extern SHIBSP_API xmltooling::QName NumberOfAttributeValuesType;
115
116     /** Matches based on metadata groups of issuer. */
117     extern SHIBSP_API xmltooling::QName AttributeIssuerInEntityGroupType;
118
119     /** Matches based on metadata groups of requester. */
120     extern SHIBSP_API xmltooling::QName AttributeRequesterInEntityGroupType;
121
122     /** Matches based on metadata groups of requester. */
123     extern SHIBSP_API xmltooling::QName InEntityGroupType;
124
125     /** Matches based on entity attributes of issuer. */
126     extern SHIBSP_API xmltooling::QName AttributeIssuerEntityAttributeExactMatchType;
127
128     /** Matches based on entity attributes of requester. */
129     extern SHIBSP_API xmltooling::QName AttributeRequesterEntityAttributeExactMatchType;
130
131     /** Matches based on entity attributes of requester. */
132     extern SHIBSP_API xmltooling::QName EntityAttributeExactMatchType;
133
134     /** Matches based on entity attributes of issuer and a regex. */
135     extern SHIBSP_API xmltooling::QName AttributeIssuerEntityAttributeRegexMatchType;
136
137     /** Matches based on entity attributes of requester and a regex. */
138     extern SHIBSP_API xmltooling::QName AttributeRequesterEntityAttributeRegexMatchType;
139
140     /** Matches based on entity attributes of requester and a regex. */
141     extern SHIBSP_API xmltooling::QName EntityAttributeRegexMatchType;
142
143     /** Matches based on issuer and pluggable criteria. */
144     extern SHIBSP_API xmltooling::QName AttributeIssuerEntityMatcherType;
145
146     /** Matches based on requester and pluggable criteria. */
147     extern SHIBSP_API xmltooling::QName AttributeRequesterEntityMatcherType;
148
149     /** Matches based on metadata Scope extensions. */
150     extern SHIBSP_API xmltooling::QName AttributeScopeMatchesShibMDScopeType;
151
152     /** Matches based on NameID NameQualifiers. */
153     extern SHIBSP_API xmltooling::QName NameIDQualifierStringType;
154
155     /** Matches based on RegistrationAuthority extension in issuer's metadata. */
156     extern SHIBSP_API xmltooling::QName AttributeIssuerRegistrationAuthorityType;
157
158     /** Matches based on RegistrationAuthority extension in requester's metadata. */
159     extern SHIBSP_API xmltooling::QName RegistrationAuthorityType;
160
161     /**
162      * Registers MatchFunctor classes into the runtime.
163      */
164     void SHIBSP_API registerMatchFunctors();
165 };
166
167 #endif /* __shibsp_matchfunc_h__ */