NIHVIVO-736 Removed unused code and little-used code from the LoginFormBean
This commit is contained in:
parent
3300b7cda7
commit
57cbc5f1e0
2 changed files with 14 additions and 91 deletions
|
@ -2,8 +2,6 @@
|
|||
|
||||
package edu.cornell.mannlib.vedit.beans;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
|
@ -14,83 +12,30 @@ import javax.servlet.http.HttpSession;
|
|||
*/
|
||||
public class LoginFormBean {
|
||||
public static final int ANYBODY = 0;
|
||||
|
||||
public int getAnybody() {
|
||||
return ANYBODY;
|
||||
}
|
||||
|
||||
public static final int NON_EDITOR = 1;
|
||||
|
||||
public int getNonEditor() {
|
||||
return NON_EDITOR;
|
||||
}
|
||||
|
||||
public static final int EDITOR = 4;
|
||||
|
||||
public int getEditor() {
|
||||
return EDITOR;
|
||||
}
|
||||
|
||||
public static final int CURATOR = 5;
|
||||
|
||||
public int getCurator() {
|
||||
return CURATOR;
|
||||
}
|
||||
|
||||
public static final int DBA = 50;
|
||||
|
||||
public int getDba() {
|
||||
return DBA;
|
||||
}
|
||||
|
||||
public boolean getBla() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private String userURI;
|
||||
private String sessionId;
|
||||
private String loginBrowser;
|
||||
private String loginRemoteAddr;
|
||||
private String loginName;
|
||||
private String loginPassword;
|
||||
private String loginStatus;
|
||||
private int loginUserId;
|
||||
private String loginRole;
|
||||
private String duplicatePassword;
|
||||
private String emailAddress;
|
||||
private Hashtable<String, String> errors;
|
||||
|
||||
public boolean validateLoginForm() {
|
||||
boolean allOk = true;
|
||||
|
||||
if (loginName.equals("")) {
|
||||
errors.put("loginName", "Please enter your Vivo user name");
|
||||
loginName = "";
|
||||
allOk = false;
|
||||
}
|
||||
|
||||
if (loginPassword.equals("")) {
|
||||
errors.put("loginPassword", "Please enter your Vivo password");
|
||||
loginPassword = "";
|
||||
allOk = false;
|
||||
}
|
||||
|
||||
return allOk;
|
||||
}
|
||||
|
||||
public LoginFormBean() {
|
||||
sessionId = "";
|
||||
loginBrowser = "";
|
||||
loginRemoteAddr = "";
|
||||
loginName = "";
|
||||
loginPassword = "";
|
||||
loginStatus = "none";
|
||||
loginUserId = 0;
|
||||
loginRole = "1";
|
||||
duplicatePassword = "";
|
||||
emailAddress = "";
|
||||
|
||||
errors = new Hashtable<String, String>();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
@ -124,14 +69,17 @@ public class LoginFormBean {
|
|||
}
|
||||
|
||||
public static boolean loggedIn(HttpServletRequest request, int minLevel) {
|
||||
if (request == null)
|
||||
if (request == null) {
|
||||
return false;
|
||||
}
|
||||
HttpSession sess = request.getSession(false);
|
||||
if (sess == null)
|
||||
if (sess == null) {
|
||||
return false;
|
||||
}
|
||||
Object obj = sess.getAttribute("loginHandler");
|
||||
if (obj == null || !(obj instanceof LoginFormBean))
|
||||
if (!(obj instanceof LoginFormBean)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LoginFormBean lfb = (LoginFormBean) obj;
|
||||
return ("authenticated".equals(lfb.loginStatus) && Integer
|
||||
|
@ -160,10 +108,6 @@ public class LoginFormBean {
|
|||
return loginName;
|
||||
}
|
||||
|
||||
public String getLoginPassword() {
|
||||
return loginPassword;
|
||||
}
|
||||
|
||||
public String getLoginStatus() {
|
||||
return loginStatus;
|
||||
}
|
||||
|
@ -176,19 +120,10 @@ public class LoginFormBean {
|
|||
return loginRole;
|
||||
}
|
||||
|
||||
public String getDuplicatePassword() {
|
||||
return duplicatePassword;
|
||||
}
|
||||
|
||||
public String getEmailAddress() {
|
||||
return emailAddress;
|
||||
}
|
||||
|
||||
public String getErrorMsg(String s) {
|
||||
String errorMsg = (String) errors.get(s.trim());
|
||||
return (errorMsg == null) ? "" : errorMsg;
|
||||
}
|
||||
|
||||
/********************** SET METHODS *********************/
|
||||
|
||||
public void setUserURI(String uri) {
|
||||
|
@ -211,10 +146,6 @@ public class LoginFormBean {
|
|||
loginName = ln;
|
||||
}
|
||||
|
||||
public void setLoginPassword(String lp) {
|
||||
loginPassword = lp;
|
||||
}
|
||||
|
||||
public void setLoginStatus(String ls) {
|
||||
loginStatus = ls;
|
||||
}
|
||||
|
@ -227,16 +158,8 @@ public class LoginFormBean {
|
|||
loginRole = lr;
|
||||
}
|
||||
|
||||
public void setDuplicatePassword(String dp) {
|
||||
duplicatePassword = dp;
|
||||
}
|
||||
|
||||
public void setEmailAddress(String ea) {
|
||||
emailAddress = ea;
|
||||
}
|
||||
|
||||
public void setErrorMsg(String key, String msg) {
|
||||
errors.put(key, msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -132,28 +132,28 @@ public class UserRetryController extends BaseEditController {
|
|||
/* bdc34: Datastar needs non-backend-editing users for logging in non-Cornell people*/
|
||||
/* SelfEditingPolicySetup.SELF_EDITING_POLICY_WAS_SETUP is set by the SelfEditingPolicySetup context listener */
|
||||
boolean selfEditing = (Boolean)getServletContext().getAttribute(SelfEditingPolicySetup.SELF_EDITING_POLICY_WAS_SETUP) == Boolean.TRUE;
|
||||
Option nonEditor = new Option(ROLE_PROTOCOL+loginBean.getNonEditor(), "self editor");
|
||||
Option nonEditor = new Option(ROLE_PROTOCOL+loginBean.NON_EDITOR, "self editor");
|
||||
/* self editing should be displayed if we are editing a user account that is already
|
||||
* self-editing even if self editing is off. */
|
||||
if( selfEditing ||
|
||||
( !"insert".equals(action) && userForEditing.getRoleURI().equals(nonEditor.getValue()) )){
|
||||
nonEditor.setSelected(userForEditing.getRoleURI().equals(nonEditor.getValue()));
|
||||
if (nonEditor.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.getNonEditor()))
|
||||
if (nonEditor.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.NON_EDITOR))
|
||||
roleOptionList.add(nonEditor);
|
||||
}
|
||||
|
||||
Option editor = new Option(ROLE_PROTOCOL+loginBean.getEditor(), "editor");
|
||||
Option editor = new Option(ROLE_PROTOCOL+loginBean.EDITOR, "editor");
|
||||
editor.setSelected(userForEditing.getRoleURI().equals(editor.getValue()));
|
||||
Option curator = new Option(ROLE_PROTOCOL+loginBean.getCurator(), "curator");
|
||||
Option curator = new Option(ROLE_PROTOCOL+loginBean.CURATOR, "curator");
|
||||
curator.setSelected(userForEditing.getRoleURI().equals(curator.getValue()));
|
||||
Option administrator = new Option (ROLE_PROTOCOL+loginBean.getDba(), "system administrator");
|
||||
Option administrator = new Option (ROLE_PROTOCOL+loginBean.DBA, "system administrator");
|
||||
administrator.setSelected(userForEditing.getRoleURI().equals(administrator.getValue()));
|
||||
|
||||
if (editor.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.getEditor()))
|
||||
if (editor.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.EDITOR))
|
||||
roleOptionList.add(editor);
|
||||
if (curator.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.getCurator()))
|
||||
if (curator.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.CURATOR))
|
||||
roleOptionList.add(curator);
|
||||
if (administrator.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.getDba()))
|
||||
if (administrator.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.DBA))
|
||||
roleOptionList.add(administrator);
|
||||
|
||||
optionMap.put("Role", roleOptionList);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue