Attribute filtering code.
[shibboleth/sp.git] / shibsp / attribute / filtering / MatchFunctor.h
1 /*
2  *  Copyright 2001-2007 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         /**\r
45          * Evaluates this matching criteria. This evaluation is used when a filtering engine determines policy\r
46          * applicability.\r
47          * \r
48          * @param filterContext current filtering context\r
49          * @return true if the criteria for this matching function are met\r
50          * @throws AttributeFilteringException thrown if the function can not be evaluated\r
51          */\r
52         virtual bool evaluatePolicyRequirement(const FilteringContext& filterContext) const=0;\r
53 \r
54         /**\r
55          * Evaluates this matching criteria. This evaluation is used when a filtering engine is filtering attribute\r
56          * values.\r
57          * \r
58          * @param filterContext the current filtering context\r
59          * @param attribute     the attribute being evaluated\r
60          * @param index         the index of the attribute value being evaluated\r
61          * @return true if the criteria for this matching function are met\r
62          * @throws AttributeFilteringException thrown if the function can not be evaluated\r
63          */\r
64         virtual bool evaluatePermitValue(const FilteringContext& filterContext, const Attribute& attribute, size_t index) const=0;\r
65     };
66
67     /**
68      * Registers MatchFunctor classes into the runtime.
69      */
70     void SHIBSP_API registerMatchFunctors();
71 };
72
73 #endif /* __shibsp_matchfunc_h__ */