2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
22 * AttributeRequesterStringFunctor.cpp
24 * A match function that matches the attribute requester's name against the specified value.
28 #include "exceptions.h"
29 #include "attribute/filtering/FilteringContext.h"
30 #include "attribute/filtering/FilterPolicyContext.h"
31 #include "attribute/filtering/MatchFunctor.h"
33 #include <xmltooling/util/XMLHelper.h>
34 using xmltooling::XMLHelper;
38 static const XMLCh value[] = UNICODE_LITERAL_5(v,a,l,u,e);
39 static const XMLCh ignoreCase[] = UNICODE_LITERAL_10(i,g,n,o,r,e,C,a,s,e);
42 * A match function that matches the attribute requester's name against the specified value.
44 class SHIBSP_DLLLOCAL AttributeRequesterStringFunctor : public MatchFunctor
49 AttributeRequesterStringFunctor(const DOMElement* e) : m_value(nullptr), m_ignoreCase(XMLHelper::getAttrBool(e, false, ignoreCase)) {
50 m_value = e ? e->getAttributeNS(nullptr,value) : nullptr;
51 if (!m_value || !*m_value)
52 throw ConfigurationException("AttributeRequesterString MatchFunctor requires non-empty value attribute.");
55 bool evaluatePolicyRequirement(const FilteringContext& filterContext) const {
57 return (XMLString::compareIString(m_value, filterContext.getAttributeRequester()) == 0);
59 return XMLString::equals(m_value, filterContext.getAttributeRequester());
62 bool evaluatePermitValue(const FilteringContext& filterContext, const Attribute& attribute, size_t index) const {
63 return evaluatePolicyRequirement(filterContext);
67 MatchFunctor* SHIBSP_DLLLOCAL AttributeRequesterStringFactory(const std::pair<const FilterPolicyContext*,const DOMElement*>& p)
69 return new AttributeRequesterStringFunctor(p.second);