01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * 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: package org.acegisecurity.providers.openid;
16:
17: import java.io.ObjectStreamException;
18: import java.io.Serializable;
19:
20: /**
21: * Based on JanRain status codes
22: *
23: * @author JanRain Inc.
24: * @author Robin Bramley, Opsera Ltd
25: */
26: public class OpenIDAuthenticationStatus implements Serializable {
27: //~ Static fields/initializers =====================================================================================
28:
29: private static final long serialVersionUID = -998877665544332211L;
30: private static int nextOrdinal = 0;
31:
32: /** This code indicates a successful authentication request */
33: public static final OpenIDAuthenticationStatus SUCCESS = new OpenIDAuthenticationStatus(
34: "success");
35:
36: /** This code indicates a failed authentication request */
37: public static final OpenIDAuthenticationStatus FAILURE = new OpenIDAuthenticationStatus(
38: "failure");
39:
40: /** This code indicates the server reported an error */
41: public static final OpenIDAuthenticationStatus ERROR = new OpenIDAuthenticationStatus(
42: "error");
43:
44: /** This code indicates that the user needs to do additional work to prove their identity */
45: public static final OpenIDAuthenticationStatus SETUP_NEEDED = new OpenIDAuthenticationStatus(
46: "setup needed");
47:
48: /** This code indicates that the user cancelled their login request */
49: public static final OpenIDAuthenticationStatus CANCELLED = new OpenIDAuthenticationStatus(
50: "cancelled");
51: private static final OpenIDAuthenticationStatus[] PRIVATE_VALUES = {
52: SUCCESS, FAILURE, ERROR, SETUP_NEEDED, CANCELLED };
53:
54: //~ Instance fields ================================================================================================
55:
56: private String name;
57: private final int ordinal = nextOrdinal++;
58:
59: //~ Constructors ===================================================================================================
60:
61: private OpenIDAuthenticationStatus(String name) {
62: this .name = name;
63: }
64:
65: //~ Methods ========================================================================================================
66:
67: private Object readResolve() throws ObjectStreamException {
68: return PRIVATE_VALUES[ordinal];
69: }
70:
71: public String toString() {
72: return name;
73: }
74: }
|