/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springframework.security.openid;

import java.io.ObjectStreamException;
import java.io.Serializable;


/**
 * Based on JanRain status codes
 *
 * @author JanRain Inc.
 * @author Robin Bramley, Opsera Ltd
 */
public class OpenIDAuthenticationStatus implements Serializable {
    //~ Static fields/initializers =====================================================================================

    private static final long serialVersionUID = -998877665544332211L;
    private static int nextOrdinal = 0;

    /** This code indicates a successful authentication request */
    public static final OpenIDAuthenticationStatus SUCCESS = new OpenIDAuthenticationStatus("success");

    /** This code indicates a failed authentication request */
    public static final OpenIDAuthenticationStatus FAILURE = new OpenIDAuthenticationStatus("failure");

    /** This code indicates the server reported an error */
    public static final OpenIDAuthenticationStatus ERROR = new OpenIDAuthenticationStatus("error");

    /** This code indicates that the user needs to do additional work to prove their identity */
    public static final OpenIDAuthenticationStatus SETUP_NEEDED = new OpenIDAuthenticationStatus("setup needed");

    /** This code indicates that the user cancelled their login request */
    public static final OpenIDAuthenticationStatus CANCELLED = new OpenIDAuthenticationStatus("cancelled");
    private static final OpenIDAuthenticationStatus[] PRIVATE_VALUES = {SUCCESS, FAILURE, ERROR, SETUP_NEEDED, CANCELLED};

    //~ Instance fields ================================================================================================

    private final String name;
    private final int ordinal = nextOrdinal++;

    //~ Constructors ===================================================================================================

    private OpenIDAuthenticationStatus(String name) {
        this.name = name;
    }

    //~ Methods ========================================================================================================

    private Object readResolve() throws ObjectStreamException {
        return PRIVATE_VALUES[ordinal];
    }

    public String toString() {
        return name;
    }
}

@@ -664,85 +664,45 @@
 d;%0A%0A
-import java.io.ObjectStreamException;%0Aimport java.io.Serializable;%0A%0A%0A/**%0A * B
+/**%0A * Authentication status codes, b
 ased
@@ -790,16 +790,39 @@
 era Ltd%0A
+ * @author Luke Taylor%0A
  */%0Apubl
@@ -828,13 +828,12 @@
 lic 
-class
+enum
  Ope
@@ -860,426 +860,89 @@
 tus 
-implements Serializable %7B%0A    //~ Static fields/initializers =====================================================================================%0A%0A    private static final long serialVersionUID = -998877665544332211L;%0A    private static int nextOrdinal = 0;%0A%0A    /** This code indicates a successful authentication request */%0A    public static final OpenIDAuthenticationStatus SUCCESS = new OpenIDAuthenticationStatus
+%7B%0A%0A    /** This code indicates a successful authentication request */%0A    SUCCESS
 (%22su
@@ -948,17 +948,17 @@
 uccess%22)
-;
+,
 %0A%0A    /*
@@ -1022,95 +1022,15 @@
     
-public static final OpenIDAuthenticationStatus FAILURE = new OpenIDAuthenticationStatus
+FAILURE
 (%22fa
@@ -1036,17 +1036,17 @@
 ailure%22)
-;
+,
 %0A%0A    /*
@@ -1107,93 +1107,13 @@
     
-public static final OpenIDAuthenticationStatus ERROR = new OpenIDAuthenticationStatus
+ERROR
 (%22er
@@ -1117,17 +1117,17 @@
 %22error%22)
-;
+,
 %0A%0A    /*
@@ -1225,100 +1225,20 @@
     
-public static final OpenIDAuthenticationStatus SETUP_NEEDED = new OpenIDAuthenticationStatus
+SETUP_NEEDED
 (%22se
@@ -1249,17 +1249,17 @@
 needed%22)
-;
+,
 %0A%0A    /*
@@ -1335,870 +1335,265 @@
     
-public static final OpenIDAuthenticationStatus CANCELLED = new OpenIDAuthenticationStatus(%22cancelled%22);%0A    private static final OpenIDAuthenticationStatus%5B%5D PRIVATE_VALUES = %7BSUCCESS, FAILURE, ERROR, SETUP_NEEDED, CANCELLED%7D;%0A%0A    //~ Instance fields ================================================================================================%0A%0A    private final String name;%0A    private final int ordinal = nextOrdinal++;%0A%0A    //~ Constructors ===================================================================================================%0A%0A    private OpenIDAuthenticationStatus(String name) %7B%0A        this.name = name;%0A    %7D%0A%0A    //~ Methods ========================================================================================================%0A%0A    private Object readResolve() throws ObjectStreamException %7B%0A        return PRIVATE_VALUES%5Bordinal%5D
+CANCELLED(%22cancelled%22);%0A%0A    private final String name;%0A%0A    //~ Constructors ===================================================================================================%0A%0A    private OpenIDAuthenticationStatus(String name) %7B%0A        this.name = name
 ;%0A  

Convert OpenIDAuthenticationStatus to an enum.