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(AttributeIssuerString);
48 DECL_FACTORY(AttributeRequesterString);
49 DECL_FACTORY(AuthenticationMethodString);
50 DECL_FACTORY(AttributeValueString);
51 DECL_FACTORY(AttributeScopeString);
52 DECL_FACTORY(AttributeIssuerRegex);
53 DECL_FACTORY(AttributeRequesterRegex);
54 DECL_FACTORY(AuthenticationMethodRegex);
55 DECL_FACTORY(AttributeValueRegex);
56 DECL_FACTORY(AttributeScopeRegex);
57 DECL_FACTORY(NumberOfAttributeValues);
59 static const XMLCh ANY[] = UNICODE_LITERAL_3(A,N,Y);
60 static const XMLCh AND[] = UNICODE_LITERAL_3(A,N,D);
61 static const XMLCh OR[] = UNICODE_LITERAL_2(O,R);
62 static const XMLCh NOT[] = UNICODE_LITERAL_3(N,O,T);
63 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);
64 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);
65 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);
66 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);
67 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);
68 static const XMLCh AttributeIssuerRegex[] = UNICODE_LITERAL_20(A,t,t,r,i,b,u,t,e,I,s,s,u,e,r,R,e,g,e,x);
69 static const XMLCh AttributeRequesterRegex[] = UNICODE_LITERAL_23(A,t,t,r,i,b,u,t,e,R,e,q,u,e,s,t,e,r,R,e,g,e,x);
70 static const XMLCh AuthenticationMethodRegex[] = UNICODE_LITERAL_25(A,u,t,h,e,n,t,i,c,a,t,i,o,n,M,e,t,h,o,d,R,e,g,e,x);
71 static const XMLCh AttributeValueRegex[] = UNICODE_LITERAL_19(A,t,t,r,i,b,u,t,e,V,a,l,u,e,R,e,g,e,x);
72 static const XMLCh AttributeScopeRegex[] = UNICODE_LITERAL_19(A,t,t,r,i,b,u,t,e,S,c,o,p,e,R,e,g,e,x);
73 static const XMLCh NumberOfAttributeValues[] = UNICODE_LITERAL_23(N,u,m,b,e,r,O,f,A,t,t,r,i,b,u,t,e,V,a,l,u,e,s);
76 DECL_BASIC_QNAME(AnyMatchFunctor, ANY);
77 DECL_BASIC_QNAME(AndMatchFunctor, AND);
78 DECL_BASIC_QNAME(OrMatchFunctor, OR);
79 DECL_BASIC_QNAME(NotMatchFunctor, NOT);
80 DECL_BASIC_QNAME(AttributeIssuerString, AttributeIssuerString);
81 DECL_BASIC_QNAME(AttributeRequesterString, AttributeRequesterString);
82 DECL_BASIC_QNAME(AuthenticationMethodString, AuthenticationMethodString);
83 DECL_BASIC_QNAME(AttributeValueString, AttributeValueString);
84 DECL_BASIC_QNAME(AttributeScopeString, AttributeScopeString);
85 DECL_BASIC_QNAME(AttributeIssuerRegex, AttributeIssuerRegex);
86 DECL_BASIC_QNAME(AttributeRequesterRegex, AttributeRequesterRegex);
87 DECL_BASIC_QNAME(AuthenticationMethodRegex, AuthenticationMethodRegex);
88 DECL_BASIC_QNAME(AttributeValueRegex, AttributeValueRegex);
89 DECL_BASIC_QNAME(AttributeScopeRegex, AttributeScopeRegex);
90 DECL_BASIC_QNAME(NumberOfAttributeValues, NumberOfAttributeValues);
92 void SHIBSP_API shibsp::registerMatchFunctors()
94 PluginManager< MatchFunctor,QName,pair<const FilterPolicyContext*,const DOMElement*> >& mgr =
95 SPConfig::getConfig().MatchFunctorManager;
96 REGISTER_FACTORY(AnyMatchFunctor);
97 REGISTER_FACTORY(AndMatchFunctor);
98 REGISTER_FACTORY(OrMatchFunctor);
99 REGISTER_FACTORY(NotMatchFunctor);
100 REGISTER_FACTORY(AttributeIssuerString);
101 REGISTER_FACTORY(AttributeRequesterString);
102 REGISTER_FACTORY(AuthenticationMethodString);
103 REGISTER_FACTORY(AttributeValueString);
104 REGISTER_FACTORY(AttributeScopeString);
105 REGISTER_FACTORY(AttributeIssuerRegex);
106 REGISTER_FACTORY(AttributeRequesterRegex);
107 REGISTER_FACTORY(AuthenticationMethodRegex);
108 REGISTER_FACTORY(AttributeValueRegex);
109 REGISTER_FACTORY(AttributeScopeRegex);
110 REGISTER_FACTORY(NumberOfAttributeValues);