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