2 * Copyright 2001-2007 Internet2
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 * A function that evaluates whether an expressed criteria is met by the current filter context.
24 #include "attribute/filtering/MatchFunctor.h"
25 #include "util/SPConstants.h"
27 #include <xercesc/util/XMLUniDefs.hpp>
29 using namespace shibsp;
30 using namespace xmltooling;
33 #define DECL_FACTORY(name) \
34 SHIBSP_DLLLOCAL PluginManager< MatchFunctor,QName,pair<const FilterPolicyContext*,const DOMElement*> >::Factory name##Factory
36 #define DECL_BASIC_QNAME(name,lit) \
37 QName shibsp::name##Type(shibspconstants::SHIB2ATTRIBUTEFILTER_MF_BASIC_NS, lit)
39 #define REGISTER_FACTORY(name) \
40 mgr.registerFactory(name##Type, name##Factory)
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 DECL_FACTORY(AttributeValueString);
51 DECL_FACTORY(AttributeScopeString);
53 static const XMLCh ANY[] = UNICODE_LITERAL_3(A,N,Y);
54 static const XMLCh AND[] = UNICODE_LITERAL_3(A,N,D);
55 static const XMLCh OR[] = UNICODE_LITERAL_2(O,R);
56 static const XMLCh NOT[] = UNICODE_LITERAL_3(N,O,T);
57 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);
58 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);
59 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);
60 static const XMLCh AttributeValueString[] = UNICODE_LITERAL_20(A,t,t,r,i,b,u,t,e,V,a,l,u,e,S,t,r,i,n,g);
61 static const XMLCh AttributeScopeString[] = UNICODE_LITERAL_20(A,t,t,r,i,b,u,t,e,S,c,o,p,e,S,t,r,i,n,g);
64 DECL_BASIC_QNAME(AnyMatchFunctor, ANY);
65 DECL_BASIC_QNAME(AndMatchFunctor, AND);
66 DECL_BASIC_QNAME(OrMatchFunctor, OR);
67 DECL_BASIC_QNAME(NotMatchFunctor, NOT);
68 DECL_BASIC_QNAME(AttributeRequesterString, AttributeRequesterString);
69 DECL_BASIC_QNAME(AttributeIssuerString, AttributeIssuerString);
70 DECL_BASIC_QNAME(AuthenticationMethodString, AuthenticationMethodString);
71 DECL_BASIC_QNAME(AttributeValueString, AttributeValueString);
72 DECL_BASIC_QNAME(AttributeScopeString, AttributeScopeString);
74 void SHIBSP_API shibsp::registerMatchFunctors()
76 PluginManager< MatchFunctor,QName,pair<const FilterPolicyContext*,const DOMElement*> >& mgr =
77 SPConfig::getConfig().MatchFunctorManager;
78 REGISTER_FACTORY(AnyMatchFunctor);
79 REGISTER_FACTORY(AndMatchFunctor);
80 REGISTER_FACTORY(OrMatchFunctor);
81 REGISTER_FACTORY(NotMatchFunctor);
82 REGISTER_FACTORY(AttributeRequesterString);
83 REGISTER_FACTORY(AttributeIssuerString);
84 REGISTER_FACTORY(AuthenticationMethodString);
85 REGISTER_FACTORY(AttributeValueString);
86 REGISTER_FACTORY(AttributeScopeString);