001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)AuthenticatorType.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: /**
030: * AuthenticatorType.java
031: *
032: * SUN PROPRIETARY/CONFIDENTIAL.
033: * This software is the proprietary intypeion of Sun Microsystems, Inc.
034: * Use is subject to license terms.
035: *
036: * Created on February 8, 2005, 12:02 PM
037: */package com.sun.jbi.internal.security.auth;
038:
039: import java.util.Arrays;
040: import java.util.Collections;
041: import java.util.Iterator;
042: import java.util.List;
043:
044: /**
045: * Type Safe Enumeration of AuthenticatorTypes.
046: *
047: * @author Sun Microsystems, Inc.
048: */
049: public final class AuthenticatorType {
050: /** The only authentication type supported currently is JAAS. */
051:
052: /** JAAS. */
053: public static final AuthenticatorType JAAS = new AuthenticatorType(
054: "JAAS");
055:
056: /** JAAS. */
057: public static final AuthenticatorType SJSAS = new AuthenticatorType(
058: "SJSAS");
059:
060: /**
061: * The VALUES.
062: */
063: private static final AuthenticatorType[] VALUES = { JAAS, SJSAS };
064:
065: /**
066: * The allowed Values.
067: */
068: public static final List LIST = Collections.unmodifiableList(Arrays
069: .asList(VALUES));
070:
071: /** The type value. */
072: private String mValue;
073:
074: /**
075: * Creates a new instance of AuthenticatorType
076: *
077: * @param type is the type String
078: */
079: private AuthenticatorType(String type) {
080: mValue = type;
081: }
082:
083: /**
084: * Get the String type value.
085: *
086: * @return the type string.
087: */
088: public String getValue() {
089: return mValue;
090: }
091:
092: /**
093: * @return a AuthenticatorType based on the string value passed.
094: *
095: * @param typeStr is the type String.
096: */
097: public static AuthenticatorType valueOf(String typeStr) {
098: Iterator itr = LIST.iterator();
099: while (itr.hasNext()) {
100: AuthenticatorType type = (AuthenticatorType) itr.next();
101: if (typeStr.equals(type.getValue())) {
102: return type;
103: }
104: }
105: throw new IllegalArgumentException(typeStr);
106: }
107:
108: /**
109: * Equality check.
110: *
111: * @param type is the type to test with for equality.
112: * @return true if type is equal to this type.
113: */
114: public boolean equals(AuthenticatorType type) {
115: return (getValue().equals(type.getValue()));
116: }
117:
118: /**
119: * @return the HashCode for this Object.
120: */
121: public int hashCode() {
122: return getValue().hashCode();
123: }
124: }
|