https://bugs.internet2.edu/jira/browse/SSPCPP-320
[shibboleth/sp.git] / shibsp / attribute / filtering / MatchFunctor.h
1 /*
2  *  Copyright 2001-2010 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file shibsp/attribute/filtering/MatchFunctor.h
19  * 
20  * A function that evaluates whether an expressed criteria is met by the current filter context.
21  */
22
23 #ifndef __shibsp_matchfunc_h__
24 #define __shibsp_matchfunc_h__
25
26 #include <shibsp/base.h>
27
28 namespace shibsp {
29
30     class SHIBSP_API Attribute;
31     class SHIBSP_API FilteringContext;
32
33     /**
34      * A function that evaluates whether an expressed criteria is met by the current filter context.
35      */
36     class SHIBSP_API MatchFunctor
37     {
38         MAKE_NONCOPYABLE(MatchFunctor);
39     protected:
40         MatchFunctor();
41     public:
42         virtual ~MatchFunctor();
43
44         /**
45          * Evaluates this matching criteria. This evaluation is used when a filtering engine determines policy
46          * applicability.
47          * 
48          * @param filterContext current filtering context
49          * @return true if the criteria for this matching function are met
50          * @throws AttributeFilteringException thrown if the function can not be evaluated
51          */
52         virtual bool evaluatePolicyRequirement(const FilteringContext& filterContext) const=0;
53
54         /**
55          * Evaluates this matching criteria. This evaluation is used when a filtering engine is filtering attribute
56          * values.
57          * 
58          * @param filterContext the current filtering context
59          * @param attribute     the attribute being evaluated
60          * @param index         the index of the attribute value being evaluated
61          * @return true if the criteria for this matching function are met
62          * @throws AttributeFilteringException thrown if the function can not be evaluated
63          */
64         virtual bool evaluatePermitValue(const FilteringContext& filterContext, const Attribute& attribute, size_t index) const=0;
65     };
66
67     /** Always evaluates to true. */
68     extern SHIBSP_API xmltooling::QName AnyMatchFunctorType;
69
70     /** Conjunction MatchFunctor. */
71     extern SHIBSP_API xmltooling::QName AndMatchFunctorType;
72
73     /** Disjunction MatchFunctor. */
74     extern SHIBSP_API xmltooling::QName OrMatchFunctorType;
75
76     /** Negating MatchFunctor. */
77     extern SHIBSP_API xmltooling::QName NotMatchFunctorType;
78
79     /** Matches the issuing entity's name. */
80     extern SHIBSP_API xmltooling::QName AttributeIssuerStringType;
81
82     /** Matches the requesting entity's name. */
83     extern SHIBSP_API xmltooling::QName AttributeRequesterStringType;
84
85     /** Matches the principal's authentication method/class or context reference. */
86     extern SHIBSP_API xmltooling::QName AuthenticationMethodStringType;
87
88     /** Matches an attribute's string value. */
89     extern SHIBSP_API xmltooling::QName AttributeValueStringType;
90
91     /** Matches an attribute's "scope". */
92     extern SHIBSP_API xmltooling::QName AttributeScopeStringType;
93
94     /** Matches the issuing entity's name. */
95     extern SHIBSP_API xmltooling::QName AttributeIssuerRegexType;
96
97     /** Matches the requesting entity's name. */
98     extern SHIBSP_API xmltooling::QName AttributeRequesterRegexType;
99
100     /** Matches the principal's authentication method/class or context reference. */
101     extern SHIBSP_API xmltooling::QName AuthenticationMethodRegexType;
102
103     /** Matches an attribute's string value. */
104     extern SHIBSP_API xmltooling::QName AttributeValueRegexType;
105
106     /** Matches an attribute's "scope". */
107     extern SHIBSP_API xmltooling::QName AttributeScopeRegexType;
108
109     /** Matches based on the number of values. */
110     extern SHIBSP_API xmltooling::QName NumberOfAttributeValuesType;
111
112     /** Matches based on metadata groups of issuer. */
113     extern SHIBSP_API xmltooling::QName AttributeIssuerInEntityGroupType;
114
115     /** Matches based on metadata groups of requester. */
116     extern SHIBSP_API xmltooling::QName AttributeRequesterInEntityGroupType;
117
118     /** Matches based on metadata Scope extensions. */
119     extern SHIBSP_API xmltooling::QName AttributeScopeMatchesShibMDScopeType;
120
121     /** Matches based on NameID NameQualifiers. */
122     extern SHIBSP_API xmltooling::QName NameIDQualifierStringType;
123
124     /**
125      * Registers MatchFunctor classes into the runtime.
126      */
127     void SHIBSP_API registerMatchFunctors();
128 };
129
130 #endif /* __shibsp_matchfunc_h__ */