View Javadoc

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.springframework.security;
17  
18  import org.springframework.util.Assert;
19  
20  /**
21   * Stores a {@link ConfigAttribute} as a <code>String</code>.
22   *
23   * @author Ben Alex
24   * @version $Id: SecurityConfig.java 2771 2008-03-21 02:15:47Z benalex $
25   */
26  public class SecurityConfig implements ConfigAttribute {
27      //~ Instance fields ================================================================================================
28  
29      private String attrib;
30  
31      //~ Constructors ===================================================================================================
32  
33      public SecurityConfig(String config) {
34          Assert.hasText(config, "You must provide a configuration attribute");
35          this.attrib = config;
36      }
37  
38      //~ Methods ========================================================================================================
39  
40      public boolean equals(Object obj) {
41          if (obj instanceof ConfigAttribute) {
42              ConfigAttribute attr = (ConfigAttribute) obj;
43  
44              return this.attrib.equals(attr.getAttribute());
45          }
46  
47          return false;
48      }
49  
50      public String getAttribute() {
51          return this.attrib;
52      }
53  
54      public int hashCode() {
55          return this.attrib.hashCode();
56      }
57  
58      public String toString() {
59          return this.attrib;
60      }
61  }