KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > airsent > presentation > admin > AdminLogin


1 /*
2  * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
3  * Reserved.
4  *
5  * This source code file is distributed by Lutris Technologies, Inc. for
6  * use only by licensed users of product(s) that include this source
7  * file. Use of this source file or the software that uses it is covered
8  * by the terms and conditions of the Lutris Enhydra Development License
9  * Agreement included with this product.
10  *
11  * This Software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
12  * ANY KIND, either express or implied. See the License for the specific terms
13  * governing rights and limitations under the License.
14  *
15  * Contributor(s):
16  *
17  * $Id: AdminLogin.java,v 1.1 2004/08/16 09:33:18 slobodan Exp $
18  */

19
20 package com.lutris.airsent.presentation.admin;
21
22 import com.lutris.airsent.presentation.BasePO;
23 import com.lutris.appserver.server.httpPresentation.*;
24 import com.lutris.appserver.server.session.*;
25 import com.lutris.util.*;
26 //import com.lutris.xml.xmlc.*;
27
//import com.lutris.xml.xmlc.html.*;
28
import org.w3c.dom.*;
29 import org.w3c.dom.html.*;
30 import org.enhydra.xml.xmlc.XMLObject;
31
32 import com.lutris.airsent.spec.AirSentException;
33
34 import com.lutris.airsent.presentation.AirSentPresentationException;
35 import com.lutris.airsent.presentation.AirSentConstants;
36 import java.util.*;
37 import com.lutris.airsent.spec.messenger.Messenger;
38 /**
39  * The login page for the Admin of the AirSent app
40  *
41  */

42 public class AdminLogin extends BasePO {
43
44     /**
45      * Constants
46      */

47     private static final int AUTH_LEVEL = AirSentConstants.UNAUTH_USER;
48
49     /**
50      * Superclass method override.
51      * returns the authorization level necessary to access this po.
52      *
53      * @return int required authorization level
54      */

55     public int getRequiredAuthLevel() {
56     return AUTH_LEVEL;
57     }
58
59     /**
60      * Default event. Just show the page.
61      */

62     public XMLObject handleDefault() throws HttpPresentationException {
63     return showPage(null);
64     }
65
66     /**
67      * Shows the AdminLogin page
68      * @param error messages
69      * @return page.
70      */

71     public XMLObject showPage(String JavaDoc errorMsg)
72         throws AirSentPresentationException {
73     AdminLoginHTML page =
74         (AdminLoginHTML) myComms.xmlcFactory.create(AdminLoginHTML.class);
75
76     try {
77         if (null != errorMsg
78         || null
79         != (errorMsg =
80             getSessionData().getAndClearUserMessage())) {
81         page.setTextErrorText(errorMsg);
82         } else {
83         page.getElementErrorText().getParentNode().removeChild(page.getElementErrorText());
84         }
85     } catch (Exception JavaDoc e) {
86         throw new AirSentPresentationException("Trouble showing page", e);
87     }
88
89     return page;
90     }
91
92     /**
93      * Handles the handleLogin event.
94      *
95      * @return error String
96      */

97     public XMLObject handleLogin() throws HttpPresentationException {
98     String JavaDoc login =
99         getComms().request.getParameter(AirSentConstants.LOGIN_NAME);
100     String JavaDoc password =
101         getComms().request.getParameter(AirSentConstants.PASSWORD_NAME);
102     Messenger messenger = null;
103
104     try {
105         if ((messenger =
106             getApplication().getHomeManager().getMessengerManager().validatePassword(login,
107             password)) == null) {
108         return showPage("Invalid username or password.");
109         } else {
110         getSessionData().setMessenger(messenger);
111         getSessionData().setUserAuth(AirSentConstants.ADMINISTRATOR_USER);
112
113         throw new ClientPageRedirectException(AirSentConstants.ADMIN_MAIN_PAGE);
114         }
115
116  //We need to allow AirSent_pres to be functional , response will be default HTML page
117
}catch(NullPointerException JavaDoc e){
118     // throw new ClientPageRedirectException(AirSentConstants.ADMIN_MAIN_PAGE);
119
AdminMainHTML defaultPage = (AdminMainHTML) myComms.xmlcFactory.create(AdminMainHTML.class);
120          defaultPage.setTextErrorText("This is a default HTML page");
121          return defaultPage;
122
123     } catch (Exception JavaDoc ex) {
124         throw new AirSentPresentationException("System error finding user",
125                            ex);
126     }
127     }
128
129 }
130
131
Popular Tags