View Javadoc

    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;
    17
    18  /***
    19   * Stores a {@link ConfigAttribute} as a <code>String</code>.
    20   *
    21   * @author <A HREF="mailto:ben.alex@fremerx.com">Ben Alex</A>
    22   * @version $Id: SecurityConfig.java,v 1.4 2005/11/17 00:55:49 benalex Exp $
    23   */
    24  public class SecurityConfig implements ConfigAttribute {
    25      //~ Instance fields ========================================================
    26
    27      private String attrib;
    28
    29      //~ Constructors ===========================================================
    30
    31      public SecurityConfig(String config) {
    32          this.attrib = config;
    33      }
    34
    35      protected SecurityConfig() {
    36          throw new IllegalArgumentException("Cannot use default constructor");
    37      }
    38
    39      //~ Methods ================================================================
    40
    41      public String getAttribute() {
    42          return this.attrib;
    43      }
    44
    45      public boolean equals(Object obj) {
    46          if (obj instanceof String) {
    47              return obj.equals(this.attrib);
    48          }
    49
    50          if (obj instanceof ConfigAttribute) {
    51              ConfigAttribute attr = (ConfigAttribute) obj;
    52
    53              return this.attrib.equals(attr.getAttribute());
    54          }
    55
    56          return false;
    57      }
    58
    59      public int hashCode() {
    60          return this.attrib.hashCode();
    61      }
    62
    63      public String toString() {
    64          return this.attrib;
    65      }
    66  }