Coverage Report - org.acegisecurity.intercept.web.FilterInvocationDefinitionDecorator
 
Classes in this File Line Coverage Branch Coverage Complexity
FilterInvocationDefinitionDecorator
78% 
100% 
1.333
 
 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 java.util.Iterator;
 19  
 import java.util.List;
 20  
 
 21  
 import org.acegisecurity.ConfigAttributeDefinition;
 22  
 import org.acegisecurity.SecurityConfig;
 23  
 
 24  
 /**
 25  
  * <p>
 26  
  * Decorator of {@link FilterInvocationDefinition} for easier configuration,
 27  
  * using {@link FilterInvocationDefinitionSourceMapping}.
 28  
  * </p>
 29  
  * 
 30  
  * <p>
 31  
  * Delegates all calls to decorated object set in constructor
 32  
  * {@link #FilterInvocationDefinitionDecorator(FilterInvocationDefinition)} or
 33  
  * by calling {@link #setDecorated(FilterInvocationDefinition)}
 34  
  * </p>
 35  
  * 
 36  
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
 37  
  * @version $Id: FilterInvocationDefinitionDecorator.java 1570 2006-07-06 17:05:08Z carlossg $
 38  
  * @since 1.1
 39  
  */
 40  
 public class FilterInvocationDefinitionDecorator implements FilterInvocationDefinition {
 41  
 
 42  
     private FilterInvocationDefinition decorated;
 43  
 
 44  
     private List mappings;
 45  
 
 46  43
     public FilterInvocationDefinitionDecorator() {
 47  43
     }
 48  
 
 49  1
     public FilterInvocationDefinitionDecorator(FilterInvocationDefinition decorated) {
 50  1
         this.setDecorated(decorated);
 51  1
     }
 52  
 
 53  
     /**
 54  
      * Set the decorated object
 55  
      * 
 56  
      * @param decorated
 57  
      *            the decorated {@link FilterInvocationDefinition}
 58  
      */
 59  
     public void setDecorated(FilterInvocationDefinition decorated) {
 60  44
         this.decorated = decorated;
 61  44
     }
 62  
 
 63  
     /**
 64  
      * Get decorated object
 65  
      * 
 66  
      * @return the decorated {@link FilterInvocationDefinition}
 67  
      */
 68  
     public FilterInvocationDefinition getDecorated() {
 69  185
         return decorated;
 70  
     }
 71  
 
 72  
     /**
 73  
      * Configures the decorated {@link FilterInvocationDefinitionMap} easier,
 74  
      * using {@link FilterInvocationDefinitionSourceMapping}.
 75  
      * 
 76  
      * @param mappings
 77  
      *            {@link List} of
 78  
      *            {@link FilterInvocationDefinitionSourceMapping} objects.
 79  
      */
 80  
     public void setMappings(List mappings) {
 81  
 
 82  37
         if (decorated == null) {
 83  0
             throw new IllegalStateException("decorated object has not been set");
 84  
         }
 85  
 
 86  37
         this.mappings = mappings;
 87  37
         Iterator it = mappings.iterator();
 88  117
         while (it.hasNext()) {
 89  81
             FilterInvocationDefinitionSourceMapping mapping = (FilterInvocationDefinitionSourceMapping) it.next();
 90  81
             ConfigAttributeDefinition configDefinition = new ConfigAttributeDefinition();
 91  
 
 92  81
             Iterator configAttributesIt = mapping.getConfigAttributes().iterator();
 93  185
             while (configAttributesIt.hasNext()) {
 94  104
                 String s = (String) configAttributesIt.next();
 95  104
                 configDefinition.addConfigAttribute(new SecurityConfig(s));
 96  104
             }
 97  
 
 98  81
             decorated.addSecureUrl(mapping.getUrl(), configDefinition);
 99  80
         }
 100  36
     }
 101  
 
 102  
     /**
 103  
      * Get the mappings used for configuration.
 104  
      * 
 105  
      * @return {@link List} of {@link FilterInvocationDefinitionSourceMapping}
 106  
      *         objects.
 107  
      */
 108  
     public List getMappings() {
 109  0
         return mappings;
 110  
     }
 111  
 
 112  
     /**
 113  
      * Delegate to decorated object
 114  
      */
 115  
     public void addSecureUrl(String expression, ConfigAttributeDefinition attr) {
 116  0
         getDecorated().addSecureUrl(expression, attr);
 117  0
     }
 118  
 
 119  
     /**
 120  
      * Delegate to decorated object
 121  
      */
 122  
     public boolean isConvertUrlToLowercaseBeforeComparison() {
 123  81
         return getDecorated().isConvertUrlToLowercaseBeforeComparison();
 124  
     }
 125  
 
 126  
     /**
 127  
      * Delegate to decorated object
 128  
      */
 129  
     public void setConvertUrlToLowercaseBeforeComparison(boolean convertUrlToLowercaseBeforeComparison) {
 130  20
         getDecorated().setConvertUrlToLowercaseBeforeComparison(convertUrlToLowercaseBeforeComparison);
 131  20
     }
 132  
 
 133  
     /**
 134  
      * Delegate to decorated object
 135  
      */
 136  
     public ConfigAttributeDefinition getAttributes(Object object) throws IllegalArgumentException {
 137  0
         return getDecorated().getAttributes(object);
 138  
     }
 139  
 
 140  
     /**
 141  
      * Delegate to decorated object
 142  
      */
 143  
     public Iterator getConfigAttributeDefinitions() {
 144  0
         return getDecorated().getConfigAttributeDefinitions();
 145  
     }
 146  
 
 147  
     /**
 148  
      * Delegate to decorated object
 149  
      */
 150  
     public boolean supports(Class clazz) {
 151  0
         return getDecorated().supports(clazz);
 152  
     }
 153  
 }