First three string functors, added authn context to resolver/filter contexts.
[shibboleth/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 #define DECL_FACTORY(name) \
34     SHIBSP_DLLLOCAL PluginManager< MatchFunctor,QName,pair<const FilterPolicyContext*,const DOMElement*> >::Factory name##Factory
35
36 #define DECL_BASIC_QNAME(name,lit) \
37     QName shibsp::name##Type(shibspconstants::SHIB2ATTRIBUTEFILTER_MF_BASIC_NS, lit)
38
39 #define REGISTER_FACTORY(name) \
40     mgr.registerFactory(name##Type, name##Factory)
41
42 namespace shibsp {
43     DECL_FACTORY(AnyMatchFunctor);
44     DECL_FACTORY(AndMatchFunctor);
45     DECL_FACTORY(OrMatchFunctor);
46     DECL_FACTORY(NotMatchFunctor);
47     DECL_FACTORY(AttributeRequesterString);
48     DECL_FACTORY(AttributeIssuerString);
49     DECL_FACTORY(AuthenticationMethodString);
50
51     static const XMLCh ANY[] =                          UNICODE_LITERAL_3(A,N,Y);
52     static const XMLCh AND[] =                          UNICODE_LITERAL_3(A,N,D);
53     static const XMLCh OR[] =                           UNICODE_LITERAL_2(O,R);
54     static const XMLCh NOT[] =                          UNICODE_LITERAL_3(N,O,T);
55     static const XMLCh AttributeRequesterString[] =     UNICODE_LITERAL_24(A,t,t,r,i,b,u,t,e,R,e,q,u,e,s,t,e,r,S,t,r,i,n,g);
56     static const XMLCh AttributeIssuerString[] =        UNICODE_LITERAL_21(A,t,t,r,i,b,u,t,e,I,s,s,u,e,r,S,t,r,i,n,g);
57     static const XMLCh AuthenticationMethodString[] =   UNICODE_LITERAL_26(A,u,t,h,e,n,t,i,c,a,t,i,o,n,M,e,t,h,o,d,S,t,r,i,n,g);
58 };
59
60 DECL_BASIC_QNAME(AnyMatchFunctor, ANY);
61 DECL_BASIC_QNAME(AndMatchFunctor, AND);
62 DECL_BASIC_QNAME(OrMatchFunctor, OR);
63 DECL_BASIC_QNAME(NotMatchFunctor, NOT);
64 DECL_BASIC_QNAME(AttributeRequesterString, AttributeRequesterString);
65 DECL_BASIC_QNAME(AttributeIssuerString, AttributeIssuerString);
66 DECL_BASIC_QNAME(AuthenticationMethodString, AuthenticationMethodString);
67
68 void SHIBSP_API shibsp::registerMatchFunctors()
69 {
70     PluginManager< MatchFunctor,QName,pair<const FilterPolicyContext*,const DOMElement*> >& mgr =
71         SPConfig::getConfig().MatchFunctorManager;
72     REGISTER_FACTORY(AnyMatchFunctor);
73     REGISTER_FACTORY(AndMatchFunctor);
74     REGISTER_FACTORY(OrMatchFunctor);
75     REGISTER_FACTORY(NotMatchFunctor);
76     REGISTER_FACTORY(AttributeRequesterString);
77     REGISTER_FACTORY(AttributeIssuerString);
78     REGISTER_FACTORY(AuthenticationMethodString);
79 }