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 DECL_SAML_QNAME(name,lit) \
40 QName shibsp::name##Type(shibspconstants::SHIB2ATTRIBUTEFILTER_MF_SAML_NS, lit)
42 #define REGISTER_FACTORY(name) \
43 mgr.registerFactory(name##Type, name##Factory)
46 DECL_FACTORY(AnyMatchFunctor);
47 DECL_FACTORY(AndMatchFunctor);
48 DECL_FACTORY(OrMatchFunctor);
49 DECL_FACTORY(NotMatchFunctor);
50 DECL_FACTORY(AttributeIssuerString);
51 DECL_FACTORY(AttributeRequesterString);
52 DECL_FACTORY(AuthenticationMethodString);
53 DECL_FACTORY(AttributeValueString);
54 DECL_FACTORY(AttributeScopeString);
55 DECL_FACTORY(AttributeIssuerRegex);
56 DECL_FACTORY(AttributeRequesterRegex);
57 DECL_FACTORY(AuthenticationMethodRegex);
58 DECL_FACTORY(AttributeValueRegex);
59 DECL_FACTORY(AttributeScopeRegex);
60 DECL_FACTORY(NumberOfAttributeValues);
61 DECL_FACTORY(AttributeIssuerInEntityGroup);
62 DECL_FACTORY(AttributeRequesterInEntityGroup);
63 DECL_FACTORY(AttributeScopeMatchesShibMDScope);
66 static const XMLCh ANY[] = UNICODE_LITERAL_3(A,N,Y);
67 static const XMLCh AND[] = UNICODE_LITERAL_3(A,N,D);
68 static const XMLCh OR[] = UNICODE_LITERAL_2(O,R);
69 static const XMLCh NOT[] = UNICODE_LITERAL_3(N,O,T);
70 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);
71 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);
72 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);
73 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);
74 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);
75 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);
76 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);
77 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);
78 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);
79 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);
80 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);
81 static const XMLCh AttributeIssuerInEntityGroup[] = UNICODE_LITERAL_28(A,t,t,r,i,b,u,t,e,I,s,s,u,e,r,I,n,E,n,t,i,t,y,G,r,o,u,p);
82 static const XMLCh AttributeRequesterInEntityGroup[] = UNICODE_LITERAL_31(A,t,t,r,i,b,u,t,e,R,e,q,u,e,s,t,e,r,I,n,E,n,t,i,t,y,G,r,o,u,p);
83 static const XMLCh AttributeScopeMatchesShibMDScope[] = UNICODE_LITERAL_32(A,t,t,r,i,b,u,t,e,S,c,o,p,e,M,a,t,c,h,e,s,S,h,i,b,M,D,S,c,o,p,e);
86 DECL_BASIC_QNAME(AnyMatchFunctor, ANY);
87 DECL_BASIC_QNAME(AndMatchFunctor, AND);
88 DECL_BASIC_QNAME(OrMatchFunctor, OR);
89 DECL_BASIC_QNAME(NotMatchFunctor, NOT);
90 DECL_BASIC_QNAME(AttributeIssuerString, AttributeIssuerString);
91 DECL_BASIC_QNAME(AttributeRequesterString, AttributeRequesterString);
92 DECL_BASIC_QNAME(AuthenticationMethodString, AuthenticationMethodString);
93 DECL_BASIC_QNAME(AttributeValueString, AttributeValueString);
94 DECL_BASIC_QNAME(AttributeScopeString, AttributeScopeString);
95 DECL_BASIC_QNAME(AttributeIssuerRegex, AttributeIssuerRegex);
96 DECL_BASIC_QNAME(AttributeRequesterRegex, AttributeRequesterRegex);
97 DECL_BASIC_QNAME(AuthenticationMethodRegex, AuthenticationMethodRegex);
98 DECL_BASIC_QNAME(AttributeValueRegex, AttributeValueRegex);
99 DECL_BASIC_QNAME(AttributeScopeRegex, AttributeScopeRegex);
100 DECL_BASIC_QNAME(NumberOfAttributeValues, NumberOfAttributeValues);
101 DECL_SAML_QNAME(AttributeIssuerInEntityGroup, AttributeIssuerInEntityGroup);
102 DECL_SAML_QNAME(AttributeRequesterInEntityGroup, AttributeRequesterInEntityGroup);
103 DECL_SAML_QNAME(AttributeScopeMatchesShibMDScope, AttributeScopeMatchesShibMDScope);
105 void SHIBSP_API shibsp::registerMatchFunctors()
107 PluginManager< MatchFunctor,QName,pair<const FilterPolicyContext*,const DOMElement*> >& mgr =
108 SPConfig::getConfig().MatchFunctorManager;
109 REGISTER_FACTORY(AnyMatchFunctor);
110 REGISTER_FACTORY(AndMatchFunctor);
111 REGISTER_FACTORY(OrMatchFunctor);
112 REGISTER_FACTORY(NotMatchFunctor);
113 REGISTER_FACTORY(AttributeIssuerString);
114 REGISTER_FACTORY(AttributeRequesterString);
115 REGISTER_FACTORY(AuthenticationMethodString);
116 REGISTER_FACTORY(AttributeValueString);
117 REGISTER_FACTORY(AttributeScopeString);
118 REGISTER_FACTORY(AttributeIssuerRegex);
119 REGISTER_FACTORY(AttributeRequesterRegex);
120 REGISTER_FACTORY(AuthenticationMethodRegex);
121 REGISTER_FACTORY(AttributeValueRegex);
122 REGISTER_FACTORY(AttributeScopeRegex);
123 REGISTER_FACTORY(NumberOfAttributeValues);
124 REGISTER_FACTORY(AttributeIssuerInEntityGroup);
125 REGISTER_FACTORY(AttributeRequesterInEntityGroup);
126 REGISTER_FACTORY(AttributeScopeMatchesShibMDScope);