Boolean match functors, policy context to manage lifetime and references.
[shibboleth/cpp-sp.git] / shibsp / attribute / filtering / impl / MatchFunctor.cpp
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  * MatchFunctor.cpp
19  * 
20  * A function that evaluates whether an expressed criteria is met by the current filter context.
21  */
22
23 #include "internal.h"
24 #include "attribute/filtering/MatchFunctor.h"
25 #include "util/SPConstants.h"
26
27 #include <xercesc/util/XMLUniDefs.hpp>
28
29 using namespace shibsp;
30 using namespace xmltooling;
31 using namespace std;
32
33 namespace shibsp {
34     SHIBSP_DLLLOCAL PluginManager< MatchFunctor,QName,pair<const FilterPolicyContext*,const DOMElement*> >::Factory AnyFunctorFactory;
35     SHIBSP_DLLLOCAL PluginManager< MatchFunctor,QName,pair<const FilterPolicyContext*,const DOMElement*> >::Factory AndFunctorFactory;
36     SHIBSP_DLLLOCAL PluginManager< MatchFunctor,QName,pair<const FilterPolicyContext*,const DOMElement*> >::Factory OrFunctorFactory;
37     SHIBSP_DLLLOCAL PluginManager< MatchFunctor,QName,pair<const FilterPolicyContext*,const DOMElement*> >::Factory NotFunctorFactory;
38
39     static const XMLCh ANY[] =                  UNICODE_LITERAL_3(A,N,Y);
40     static const XMLCh AND[] =                  UNICODE_LITERAL_3(A,N,D);
41     static const XMLCh OR[] =                   UNICODE_LITERAL_2(O,R);
42     static const XMLCh NOT[] =                  UNICODE_LITERAL_3(N,O,T);
43 };
44
45 QName shibsp::AnyMatchFunctorType(shibspconstants::SHIB2ATTRIBUTEFILTER_MF_BASIC_NS, ANY);
46 QName shibsp::AndMatchFunctorType(shibspconstants::SHIB2ATTRIBUTEFILTER_MF_BASIC_NS, AND);
47 QName shibsp::OrMatchFunctorType(shibspconstants::SHIB2ATTRIBUTEFILTER_MF_BASIC_NS, OR);
48 QName shibsp::NotMatchFunctorType(shibspconstants::SHIB2ATTRIBUTEFILTER_MF_BASIC_NS, NOT);
49
50 void SHIBSP_API shibsp::registerMatchFunctors()
51 {
52     SPConfig& conf = SPConfig::getConfig();
53     conf.MatchFunctorManager.registerFactory(AnyMatchFunctorType, AnyFunctorFactory);
54     conf.MatchFunctorManager.registerFactory(AndMatchFunctorType, AndFunctorFactory);
55     conf.MatchFunctorManager.registerFactory(OrMatchFunctorType, OrFunctorFactory);
56     conf.MatchFunctorManager.registerFactory(NotMatchFunctorType, NotFunctorFactory);
57 }