    1   /* Copyright 2004 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  import org.acegisecurity.SecurityConfig;
    20
    21  import java.util.Iterator;
    22  import java.util.List;
    23  import java.util.Vector;
    24
    25
    26  /***
    27   * DOCUMENT ME!
    28   *
    29   * @author Ben Alex
    30   * @version $Id: MockFilterInvocationDefinitionSource.java,v 1.3 2005/11/17 00:55:50 benalex Exp $
    31   */
    32  public class MockFilterInvocationDefinitionSource
    33      extends AbstractFilterInvocationDefinitionSource {
    34      //~ Instance fields ========================================================
    35
    36      private List list;
    37      private boolean returnAnIterator;
    38
    39      //~ Constructors ===========================================================
    40
    41      public MockFilterInvocationDefinitionSource(
    42          boolean includeInvalidAttributes, boolean returnAnIteratorWhenRequested) {
    43          returnAnIterator = returnAnIteratorWhenRequested;
    44          list = new Vector();
    45
    46          ConfigAttributeDefinition def1 = new ConfigAttributeDefinition();
    47          def1.addConfigAttribute(new SecurityConfig("MOCK_LOWER"));
    48          list.add(def1);
    49
    50          if (includeInvalidAttributes) {
    51              ConfigAttributeDefinition def2 = new ConfigAttributeDefinition();
    52              def2.addConfigAttribute(new SecurityConfig("MOCK_LOWER"));
    53              def2.addConfigAttribute(new SecurityConfig("INVALID_ATTRIBUTE"));
    54              list.add(def2);
    55          }
    56
    57          ConfigAttributeDefinition def3 = new ConfigAttributeDefinition();
    58          def3.addConfigAttribute(new SecurityConfig("MOCK_UPPER"));
    59          def3.addConfigAttribute(new SecurityConfig("RUN_AS"));
    60          list.add(def3);
    61
    62          if (includeInvalidAttributes) {
    63              ConfigAttributeDefinition def4 = new ConfigAttributeDefinition();
    64              def4.addConfigAttribute(new SecurityConfig("MOCK_SOMETHING"));
    65              def4.addConfigAttribute(new SecurityConfig("ANOTHER_INVALID"));
    66              list.add(def4);
    67          }
    68      }
    69
    70      private MockFilterInvocationDefinitionSource() {
    71          super();
    72      }
    73
    74      //~ Methods ================================================================
    75
    76      public Iterator getConfigAttributeDefinitions() {
    77          if (returnAnIterator) {
    78              return list.iterator();
    79          } else {
    80              return null;
    81          }
    82      }
    83
    84      public ConfigAttributeDefinition lookupAttributes(String url) {
    85          throw new UnsupportedOperationException("mock method not implemented");
    86      }
    87  }