Coverage Report - org.acegisecurity.intercept.web.AbstractFilterInvocationDefinitionSource
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractFilterInvocationDefinitionSource
83% 
100% 
1.667
 
 1  
 /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
 2  
  *
 3  
  * Licensed under the Apache License, Version 2.0 (the "License");
 4  
  * you may not use this file except in compliance with the License.
 5  
  * You may obtain a copy of the License at
 6  
  *
 7  
  *     http://www.apache.org/licenses/LICENSE-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing, software
 10  
  * distributed under the License is distributed on an "AS IS" BASIS,
 11  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
  * See the License for the specific language governing permissions and
 13  
  * limitations under the License.
 14  
  */
 15  
 
 16  
 package org.acegisecurity.intercept.web;
 17  
 
 18  
 import org.acegisecurity.ConfigAttributeDefinition;
 19  
 
 20  
 
 21  
 /**
 22  
  * Abstract implementation of <Code>FilterInvocationDefinitionSource</code>.
 23  
  *
 24  
  * @author Ben Alex
 25  
  * @version $Id: AbstractFilterInvocationDefinitionSource.java 1877 2007-05-25 05:33:06Z benalex $
 26  
  */
 27  63
 public abstract class AbstractFilterInvocationDefinitionSource implements FilterInvocationDefinitionSource {
 28  
 
 29  
     //~ Methods ========================================================================================================
 30  
 
 31  
     public ConfigAttributeDefinition getAttributes(Object object)
 32  
         throws IllegalArgumentException {
 33  16
         if ((object == null) || !this.supports(object.getClass())) {
 34  0
             throw new IllegalArgumentException("Object must be a FilterInvocation");
 35  
         }
 36  
 
 37  16
         String url = ((FilterInvocation) object).getRequestUrl();
 38  
 
 39  16
         return this.lookupAttributes(url);
 40  
     }
 41  
 
 42  
     /**
 43  
      * Performs the actual lookup of the relevant <code>ConfigAttributeDefinition</code> for the specified
 44  
      * <code>FilterInvocation</code>.
 45  
      * <p>Provided so subclasses need only to provide one basic method to properly interface with the
 46  
      * <code>FilterInvocationDefinitionSource</code>.
 47  
      * </p>
 48  
      * <p>Public visiblity so that tablibs or other view helper classes can access the
 49  
      * <code>ConfigAttributeDefinition</code> applying to a given URI pattern without needing to construct a mock
 50  
      * <code>FilterInvocation</code> and retrieving the attibutes via the {@link #getAttributes(Object)} method.</p>
 51  
      *
 52  
      * @param url the URI to retrieve configuration attributes for
 53  
      *
 54  
      * @return the <code>ConfigAttributeDefinition</code> that applies to the specified <code>FilterInvocation</code>
 55  
      */
 56  
     public abstract ConfigAttributeDefinition lookupAttributes(String url);
 57  
 
 58  
     public boolean supports(Class clazz) {
 59  23
         return FilterInvocation.class.isAssignableFrom(clazz);
 60  
     }
 61  
 }