From a8b74facd14e7ed053eda833b9cac713ad3571b8 Mon Sep 17 00:00:00 2001 From: j2blake Date: Mon, 6 Jun 2011 13:39:37 +0000 Subject: [PATCH] NIHVIVO-2279 Remove LoginStatusBean methods isLoggedInAtLeast() and isLoggedInExactly() --- .../edu/cornell/mannlib/vedit/beans/LoginStatusBean.java | 8 -------- .../controller/authenticate/BasicAuthenticator.java | 6 ++++-- .../webapp/controller/authenticate/LoginRedirector.java | 5 +++-- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vedit/beans/LoginStatusBean.java b/webapp/src/edu/cornell/mannlib/vedit/beans/LoginStatusBean.java index e9ba5640a..ec000a661 100644 --- a/webapp/src/edu/cornell/mannlib/vedit/beans/LoginStatusBean.java +++ b/webapp/src/edu/cornell/mannlib/vedit/beans/LoginStatusBean.java @@ -168,14 +168,6 @@ public class LoginStatusBean { return authenticationSource != AuthenticationSource.UNKNOWN; } - public boolean isLoggedInExactly(int level) { - return securityLevel == level; - } - - public boolean isLoggedInAtLeast(int minimumLevel) { - return securityLevel >= minimumLevel; - } - public boolean hasExternalAuthentication() { return authenticationSource == AuthenticationSource.EXTERNAL; } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BasicAuthenticator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BasicAuthenticator.java index 4d245a25a..b5373268c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BasicAuthenticator.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BasicAuthenticator.java @@ -17,6 +17,7 @@ import org.apache.commons.logging.LogFactory; import edu.cornell.mannlib.vedit.beans.LoginStatusBean; import edu.cornell.mannlib.vedit.beans.LoginStatusBean.AuthenticationSource; +import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel; import edu.cornell.mannlib.vitro.webapp.beans.SelfEditingConfiguration; import edu.cornell.mannlib.vitro.webapp.beans.User; import edu.cornell.mannlib.vitro.webapp.controller.edit.Authenticate; @@ -155,8 +156,9 @@ public class BasicAuthenticator extends Authenticator { * Editors and other privileged users get a longer timeout interval. */ private void setSessionTimeoutLimit(HttpSession session) { - if (LoginStatusBean.getBean(session).isLoggedInAtLeast( - LoginStatusBean.EDITOR)) { + RoleLevel role = RoleLevel.getRoleFromLoginStatus(request); + if (role == RoleLevel.EDITOR || role == RoleLevel.CURATOR + || role == RoleLevel.DB_ADMIN) { session.setMaxInactiveInterval(PRIVILEGED_TIMEOUT_INTERVAL); } else { session.setMaxInactiveInterval(LOGGED_IN_TIMEOUT_INTERVAL); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginRedirector.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginRedirector.java index 9e019d81e..39a43a3ec 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginRedirector.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/LoginRedirector.java @@ -15,6 +15,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import edu.cornell.mannlib.vedit.beans.LoginStatusBean; +import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel; import edu.cornell.mannlib.vitro.webapp.beans.DisplayMessage; import edu.cornell.mannlib.vitro.webapp.beans.User; import edu.cornell.mannlib.vitro.webapp.controller.Controllers; @@ -152,8 +153,8 @@ public class LoginRedirector { } private boolean isMerelySelfEditor() { - return LoginStatusBean.getBean(session).isLoggedInExactly( - LoginStatusBean.NON_EDITOR); + RoleLevel role = RoleLevel.getRoleFromLoginStatus(request); + return role == RoleLevel.PUBLIC || role == RoleLevel.SELF; } private boolean isLoginPage(String page) {