KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > security > forms > LogonForm


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.security.forms;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23
24 import org.apache.struts.action.ActionMapping;
25
26 import com.sslexplorer.boot.Util;
27 import com.sslexplorer.core.UserDatabaseManager;
28 import com.sslexplorer.core.forms.CoreForm;
29 import com.sslexplorer.security.Constants;
30 import com.sslexplorer.security.User;
31
32 public class LogonForm extends CoreForm {
33     
34     private String JavaDoc username;
35     private String JavaDoc password;
36     private boolean sessionLocked;
37     private boolean hasMoreAuthenticationSchemes;
38     private int currentModuleIndex;
39     private boolean obfuscatedMode = true;
40     private String JavaDoc realmName = UserDatabaseManager.DEFAULT_REALM_NAME;
41     
42
43     /**
44      * @return Returns the password.
45      */

46     public String JavaDoc getPassword() {
47         return password;
48     }
49
50     /**
51      * @param password The password to set.
52      */

53     public void setPassword(String JavaDoc password) {
54         this.password = password.trim();
55     }
56
57     /**
58      * @return Returns the username.
59      */

60     public String JavaDoc getUsername() {
61         return username;
62     }
63
64     /**
65      * @param username The username to set.
66      */

67     public void setUsername(String JavaDoc username) {
68         if(this.username == null && !Util.isNullOrTrimmedBlank(username)) {
69             this.username = username.trim();
70         }
71     }
72     
73     public void initUser() {
74         username = null;
75     }
76     
77     /* (non-Javadoc)
78      * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
79      */

80     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
81         User sessionLockUser = (User)request.getSession().getAttribute(Constants.SESSION_LOCKED);
82         sessionLocked = sessionLockUser != null;
83         username = sessionLocked ? sessionLockUser.getPrincipalName() : null;
84         password = null;
85         hasMoreAuthenticationSchemes = false;
86     }
87     
88     public boolean getUsernameRequired() {
89         if (obfuscatedMode){
90             return false;
91             
92         }
93         else{
94             return !getSessionLocked() && currentModuleIndex == 0;
95         }
96     }
97
98     /**
99      * @return Returns the sessionLocked.
100      */

101     public boolean getSessionLocked() {
102         return sessionLocked;
103     }
104
105     /**
106      * @param sessionLocked The sessionLocked to set.
107      */

108     public void setSessionLocked(boolean sessionLocked) {
109         this.sessionLocked = sessionLocked;
110     }
111
112     public boolean getHasMoreAuthenticationSchemes() {
113       return hasMoreAuthenticationSchemes;
114     }
115
116     public void setHasMoreAuthenticationSchemes(boolean hasMoreAuthenticationSchemes) {
117       this.hasMoreAuthenticationSchemes = hasMoreAuthenticationSchemes;
118     }
119
120     /**
121      * @param currentModuleIndex
122      */

123     public void setCurrentModuleIndex(int currentModuleIndex) {
124         this.currentModuleIndex = currentModuleIndex;
125     }
126
127     public String JavaDoc getRealmName() {
128         return realmName;
129 }
130     public void setRealmName(String JavaDoc domainName) {
131         this.realmName = domainName;
132     }
133 }
134
Popular Tags