1 19 20 package com.sslexplorer.security.forms; 21 22 import javax.servlet.http.HttpServletRequest ; 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 username; 35 private String password; 36 private boolean sessionLocked; 37 private boolean hasMoreAuthenticationSchemes; 38 private int currentModuleIndex; 39 private boolean obfuscatedMode = true; 40 private String realmName = UserDatabaseManager.DEFAULT_REALM_NAME; 41 42 43 46 public String getPassword() { 47 return password; 48 } 49 50 53 public void setPassword(String password) { 54 this.password = password.trim(); 55 } 56 57 60 public String getUsername() { 61 return username; 62 } 63 64 67 public void setUsername(String 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 80 public void reset(ActionMapping mapping, HttpServletRequest 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 101 public boolean getSessionLocked() { 102 return sessionLocked; 103 } 104 105 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 123 public void setCurrentModuleIndex(int currentModuleIndex) { 124 this.currentModuleIndex = currentModuleIndex; 125 } 126 127 public String getRealmName() { 128 return realmName; 129 } 130 public void setRealmName(String domainName) { 131 this.realmName = domainName; 132 } 133 } 134 | Popular Tags |