KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > golfShop > presentation > xmlc > login > LoginState


1 /*
2  * Enhydra Java Application Server
3  * The Initial Developer of the Original Code is Lutris Technologies Inc.
4  * Portions created by Lutris are Copyright (C) 1997-2000 Lutris Technologies
5  * Inc.
6  * All Rights Reserved.
7  *
8  * The contents of this file are subject to the Enhydra Public License Version
9  * 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 JavaDoc {
34     /**
35      * Name for object in sessionData.
36      */

37     private static final String JavaDoc sessionDataName = "golfShop.login";
38
39     /**
40      * Last error message. If null, there is no pending error.
41      */

42     public String JavaDoc lastError = null;
43
44     /**
45      * The username that was last entered.
46      */

47     public String JavaDoc 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(sessionDataName);
56             if (obj == null) {
57                 obj = new LoginState();
58                 session.getSessionData().set(sessionDataName, obj);
59             }
60             return obj;
61         } catch (KeywordValueException except) {
62             throw new FatalExceptionError(except);
63         }
64     }
65
66
67 }
68
Popular Tags