View Javadoc

1   /*
2    * Copyright 2007 University Corporation for Advanced Internet Development, Inc.
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  package edu.internet2.middleware.shibboleth.common.attribute.filtering.provider.match.basic;
18  
19  import edu.internet2.middleware.shibboleth.common.attribute.filtering.provider.FilterProcessingException;
20  import edu.internet2.middleware.shibboleth.common.attribute.filtering.provider.MatchFunctor;
21  import edu.internet2.middleware.shibboleth.common.attribute.filtering.provider.ShibbolethFilteringContext;
22  
23  /**
24   * Base class for {@link MatchFunctor}s that delegate the evaluation and negate the result if necessary.
25   * 
26   * This class provides an extension point for functionality across all match functors.
27   */
28  public abstract class AbstractMatchFunctor implements MatchFunctor {
29  
30      /** {@inheritDoc} */
31      public boolean evaluatePolicyRequirement(ShibbolethFilteringContext filterContext) throws FilterProcessingException {
32          return doEvaluatePolicyRequirement(filterContext);
33      }
34  
35      /** {@inheritDoc} */
36      public boolean evaluatePermitValue(ShibbolethFilteringContext filterContext, String attributeId,
37              Object attributeValue) throws FilterProcessingException {
38          return doEvaluateValue(filterContext, attributeId, attributeValue);
39      }
40  
41      /** {@inheritDoc} */
42      public boolean evaluateDenyRule(ShibbolethFilteringContext filterContext, String attributeId, Object attributeValue)
43              throws FilterProcessingException {
44          return evaluatePermitValue(filterContext, attributeId, attributeValue);
45      }
46  
47      /**
48       * Evaluates this matching criteria. This evaluation is used while the filtering engine determines policy
49       * applicability.
50       * 
51       * @param filterContext current filtering context
52       * 
53       * @return true if the criteria for this matching function are meant
54       * 
55       * @throws FilterProcessingException thrown if the function can not be evaluated
56       */
57      protected abstract boolean doEvaluatePolicyRequirement(ShibbolethFilteringContext filterContext)
58              throws FilterProcessingException;
59  
60      /**
61       * Evaluates this matching criteria. This evaluation is used while the filtering engine is evaluating either a deny
62       * or permit value rule.
63       * 
64       * @param filterContext the current filtering context
65       * @param attributeId ID of the attribute being evaluated
66       * @param attributeValue value of the attribute being evaluated
67       * 
68       * @return true if the criteria for this matching function are meant
69       * 
70       * @throws FilterProcessingException thrown if the function can not be evaluated
71       */
72      protected abstract boolean doEvaluateValue(ShibbolethFilteringContext filterContext, String attributeId,
73              Object attributeValue) throws FilterProcessingException;
74  }