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;
|
package edu.cornell.mannlib.vedit.beans;
|
||||||
|
|
||||||
import java.util.Hashtable;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
@ -14,83 +12,30 @@ import javax.servlet.http.HttpSession;
|
||||||
*/
|
*/
|
||||||
public class LoginFormBean {
|
public class LoginFormBean {
|
||||||
public static final int ANYBODY = 0;
|
public static final int ANYBODY = 0;
|
||||||
|
|
||||||
public int getAnybody() {
|
|
||||||
return ANYBODY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final int NON_EDITOR = 1;
|
public static final int NON_EDITOR = 1;
|
||||||
|
|
||||||
public int getNonEditor() {
|
|
||||||
return NON_EDITOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final int EDITOR = 4;
|
public static final int EDITOR = 4;
|
||||||
|
|
||||||
public int getEditor() {
|
|
||||||
return EDITOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final int CURATOR = 5;
|
public static final int CURATOR = 5;
|
||||||
|
|
||||||
public int getCurator() {
|
|
||||||
return CURATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final int DBA = 50;
|
public static final int DBA = 50;
|
||||||
|
|
||||||
public int getDba() {
|
|
||||||
return DBA;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getBla() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String userURI;
|
private String userURI;
|
||||||
private String sessionId;
|
private String sessionId;
|
||||||
private String loginBrowser;
|
private String loginBrowser;
|
||||||
private String loginRemoteAddr;
|
private String loginRemoteAddr;
|
||||||
private String loginName;
|
private String loginName;
|
||||||
private String loginPassword;
|
|
||||||
private String loginStatus;
|
private String loginStatus;
|
||||||
private int loginUserId;
|
private int loginUserId;
|
||||||
private String loginRole;
|
private String loginRole;
|
||||||
private String duplicatePassword;
|
|
||||||
private String emailAddress;
|
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() {
|
public LoginFormBean() {
|
||||||
sessionId = "";
|
sessionId = "";
|
||||||
loginBrowser = "";
|
loginBrowser = "";
|
||||||
loginRemoteAddr = "";
|
loginRemoteAddr = "";
|
||||||
loginName = "";
|
loginName = "";
|
||||||
loginPassword = "";
|
|
||||||
loginStatus = "none";
|
loginStatus = "none";
|
||||||
loginUserId = 0;
|
loginUserId = 0;
|
||||||
loginRole = "1";
|
loginRole = "1";
|
||||||
duplicatePassword = "";
|
|
||||||
emailAddress = "";
|
emailAddress = "";
|
||||||
|
|
||||||
errors = new Hashtable<String, String>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -124,14 +69,17 @@ public class LoginFormBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean loggedIn(HttpServletRequest request, int minLevel) {
|
public static boolean loggedIn(HttpServletRequest request, int minLevel) {
|
||||||
if (request == null)
|
if (request == null) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
HttpSession sess = request.getSession(false);
|
HttpSession sess = request.getSession(false);
|
||||||
if (sess == null)
|
if (sess == null) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
Object obj = sess.getAttribute("loginHandler");
|
Object obj = sess.getAttribute("loginHandler");
|
||||||
if (obj == null || !(obj instanceof LoginFormBean))
|
if (!(obj instanceof LoginFormBean)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
LoginFormBean lfb = (LoginFormBean) obj;
|
LoginFormBean lfb = (LoginFormBean) obj;
|
||||||
return ("authenticated".equals(lfb.loginStatus) && Integer
|
return ("authenticated".equals(lfb.loginStatus) && Integer
|
||||||
|
@ -160,10 +108,6 @@ public class LoginFormBean {
|
||||||
return loginName;
|
return loginName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLoginPassword() {
|
|
||||||
return loginPassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLoginStatus() {
|
public String getLoginStatus() {
|
||||||
return loginStatus;
|
return loginStatus;
|
||||||
}
|
}
|
||||||
|
@ -176,19 +120,10 @@ public class LoginFormBean {
|
||||||
return loginRole;
|
return loginRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDuplicatePassword() {
|
|
||||||
return duplicatePassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEmailAddress() {
|
public String getEmailAddress() {
|
||||||
return emailAddress;
|
return emailAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getErrorMsg(String s) {
|
|
||||||
String errorMsg = (String) errors.get(s.trim());
|
|
||||||
return (errorMsg == null) ? "" : errorMsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
/********************** SET METHODS *********************/
|
/********************** SET METHODS *********************/
|
||||||
|
|
||||||
public void setUserURI(String uri) {
|
public void setUserURI(String uri) {
|
||||||
|
@ -211,10 +146,6 @@ public class LoginFormBean {
|
||||||
loginName = ln;
|
loginName = ln;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoginPassword(String lp) {
|
|
||||||
loginPassword = lp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLoginStatus(String ls) {
|
public void setLoginStatus(String ls) {
|
||||||
loginStatus = ls;
|
loginStatus = ls;
|
||||||
}
|
}
|
||||||
|
@ -227,16 +158,8 @@ public class LoginFormBean {
|
||||||
loginRole = lr;
|
loginRole = lr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDuplicatePassword(String dp) {
|
|
||||||
duplicatePassword = dp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmailAddress(String ea) {
|
public void setEmailAddress(String ea) {
|
||||||
emailAddress = 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*/
|
/* 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 */
|
/* 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;
|
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 should be displayed if we are editing a user account that is already
|
||||||
* self-editing even if self editing is off. */
|
* self-editing even if self editing is off. */
|
||||||
if( selfEditing ||
|
if( selfEditing ||
|
||||||
( !"insert".equals(action) && userForEditing.getRoleURI().equals(nonEditor.getValue()) )){
|
( !"insert".equals(action) && userForEditing.getRoleURI().equals(nonEditor.getValue()) )){
|
||||||
nonEditor.setSelected(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);
|
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()));
|
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()));
|
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()));
|
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);
|
roleOptionList.add(editor);
|
||||||
if (curator.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.getCurator()))
|
if (curator.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.CURATOR))
|
||||||
roleOptionList.add(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);
|
roleOptionList.add(administrator);
|
||||||
|
|
||||||
optionMap.put("Role", roleOptionList);
|
optionMap.put("Role", roleOptionList);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue