01: /*
02: * Enhydra Java Application Server
03: * The Initial Developer of the Original Code is Lutris Technologies Inc.
04: * Portions created by Lutris are Copyright (C) 1997-2000 Lutris Technologies
05: * Inc.
06: * All Rights Reserved.
07: *
08: * The contents of this file are subject to the Enhydra Public License Version
09: * 1.0 (the "License"); you may not use this file except in compliance with the
10: * License. You may obtain a copy of the License at
11: * http://www.enhydra.org/software/license/epl.html
12: *
13: * Software distributed under the License is distributed on an "AS IS" basis,
14: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
15: * License for the specific language governing rights and limitations under the
16: * License.
17: *
18: *
19: */
20:
21: package golfShop.presentation.xmlc.login;
22:
23: import com.lutris.util.*;
24: import com.lutris.appserver.server.session.*;
25:
26: /**
27: * Login related data kept in the session. This is used to pass information
28: * between login-related pages instead of passing values in CGI args. This
29: * is a considerably easier approach, but can cause problems if the user
30: * is accessing the same set of screens from two different browser windows.
31: * In this case, this issues is not significant.
32: */
33: class LoginState implements java.io.Serializable {
34: /**
35: * Name for object in sessionData.
36: */
37: private static final String sessionDataName = "golfShop.login";
38:
39: /**
40: * Last error message. If null, there is no pending error.
41: */
42: public String lastError = null;
43:
44: /**
45: * The username that was last entered.
46: */
47: public String userName = null;
48:
49: /**
50: * Get the LoginState object from the session, creating one if
51: * if doesn't exist.
52: */
53: public static LoginState get(Session session) {
54: try {
55: LoginState obj = (LoginState) session.getSessionData().get(
56: sessionDataName);
57: if (obj == null) {
58: obj = new LoginState();
59: session.getSessionData().set(sessionDataName, obj);
60: }
61: return obj;
62: } catch (KeywordValueException except) {
63: throw new FatalExceptionError(except);
64: }
65: }
66:
67: }
|