NIHVIVO-736 transitioning from LoginFormBean to LoginStatusBean.

This commit is contained in:
jeb228 2010-10-13 20:13:17 +00:00
parent 5c3307ac59
commit 579ce5fdd8
8 changed files with 32 additions and 44 deletions

View file

@ -5,13 +5,13 @@ package edu.cornell.mannlib.vitro.webapp.auth.policy;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vedit.beans.LoginFormBean; import com.hp.hpl.jena.rdf.model.impl.Util;
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.CuratorEditingIdentifierFactory; import edu.cornell.mannlib.vitro.webapp.auth.identifier.CuratorEditingIdentifierFactory;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.Identifier; import edu.cornell.mannlib.vitro.webapp.auth.identifier.Identifier;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle; import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
@ -41,7 +41,6 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineData
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineObjectProperty; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineObjectProperty;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.RemoveOwlClass; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.RemoveOwlClass;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import com.hp.hpl.jena.rdf.model.impl.Util;
/** /**
* Policy to use for Vivo Curator-Editing for use at Cornell. * Policy to use for Vivo Curator-Editing for use at Cornell.
@ -136,7 +135,7 @@ public class CuratorEditingPolicy implements VisitingPolicyIface {
return pd.setMessage("Unable to get a role for the curator from IdBundle"); return pd.setMessage("Unable to get a role for the curator from IdBundle");
try{ try{
if( Integer.parseInt( roleStr ) /*<*/ != LoginFormBean.CURATOR) if( Integer.parseInt( roleStr ) /*<*/ != LoginStatusBean.CURATOR)
return pd.setMessage("CuratorEditingPolicy found role of "+roleStr+" but only authorizes for users logged in as CURATOR or higher"); return pd.setMessage("CuratorEditingPolicy found role of "+roleStr+" but only authorizes for users logged in as CURATOR or higher");
}catch(NumberFormatException nef){} }catch(NumberFormatException nef){}

View file

@ -11,7 +11,7 @@ import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.rdf.model.impl.Util; import com.hp.hpl.jena.rdf.model.impl.Util;
import edu.cornell.mannlib.vedit.beans.LoginFormBean; import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.DbAdminEditingIdentifierFactory; import edu.cornell.mannlib.vitro.webapp.auth.identifier.DbAdminEditingIdentifierFactory;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.Identifier; import edu.cornell.mannlib.vitro.webapp.auth.identifier.Identifier;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle; import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
@ -137,7 +137,7 @@ public class DbAdminEditingPolicy implements VisitingPolicyIface {
return pd.setMessage("Unable to get a role for the dbAdmin from IdBundle"); return pd.setMessage("Unable to get a role for the dbAdmin from IdBundle");
try{ try{
if( Integer.parseInt( roleStr ) /*<*/ != LoginFormBean.DBA) { if( Integer.parseInt( roleStr ) /*<*/ != LoginStatusBean.DBA) {
return pd.setMessage("DbAdminEditingPolicy found role of "+roleStr+" and only authorizes for users logged in as DB_ADMIN"); return pd.setMessage("DbAdminEditingPolicy found role of "+roleStr+" and only authorizes for users logged in as DB_ADMIN");
} }
} catch(NumberFormatException nef){ } catch(NumberFormatException nef){

View file

@ -5,15 +5,13 @@ package edu.cornell.mannlib.vitro.webapp.auth.policy;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.rdf.model.impl.Util; import com.hp.hpl.jena.rdf.model.impl.Util;
import edu.cornell.mannlib.vedit.beans.LoginFormBean; import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.EditorEditingIdentifierFactory; import edu.cornell.mannlib.vitro.webapp.auth.identifier.EditorEditingIdentifierFactory;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.Identifier; import edu.cornell.mannlib.vitro.webapp.auth.identifier.Identifier;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle; import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
@ -137,7 +135,7 @@ public class EditorEditingPolicy implements VisitingPolicyIface{
return pd.setMessage("Unable to get a role for the editor from IdBundle"); return pd.setMessage("Unable to get a role for the editor from IdBundle");
try{ try{
if( Integer.parseInt( roleStr ) /*<*/ != LoginFormBean.EDITOR) if( Integer.parseInt( roleStr ) /*<*/ != LoginStatusBean.EDITOR)
return pd.setMessage("EditorEditingPolicy found role of "+roleStr+" but only authorizes for users logged in as EDITOR or higher"); return pd.setMessage("EditorEditingPolicy found role of "+roleStr+" but only authorizes for users logged in as EDITOR or higher");
}catch(NumberFormatException nef){} }catch(NumberFormatException nef){}

View file

@ -8,14 +8,13 @@ import java.util.Map;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vedit.beans.LoginFormBean; import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.Identifier; import edu.cornell.mannlib.vitro.webapp.auth.identifier.Identifier;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle; import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization; import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization;
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.DefaultInconclusivePolicy; import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.DefaultInconclusivePolicy;
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision; import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision;
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface; import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface;
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.VisitingPolicyIface;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AddDataPropStmt; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AddDataPropStmt;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AddObjectPropStmt; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AddObjectPropStmt;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AddResource; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AddResource;
@ -146,11 +145,11 @@ public class RoleBasedPolicy extends DefaultInconclusivePolicy implements Polic
// CURATOR("http://vitro.mannlib.cornell.edu/authRole#curator",3), // CURATOR("http://vitro.mannlib.cornell.edu/authRole#curator",3),
// DBA("http://vitro.mannlib.cornell.edu/authRole#dba",50); // DBA("http://vitro.mannlib.cornell.edu/authRole#dba",50);
ANYBODY( "role:/0" ,LoginFormBean.ANYBODY), ANYBODY( "role:/0" ,LoginStatusBean.ANYBODY),
USER( "role:/1" ,LoginFormBean.NON_EDITOR), USER( "role:/1" ,LoginStatusBean.NON_EDITOR),
EDITOR( "role:/4" ,LoginFormBean.EDITOR), EDITOR( "role:/4" ,LoginStatusBean.EDITOR),
CURATOR( "role:/5" ,LoginFormBean.CURATOR), CURATOR( "role:/5" ,LoginStatusBean.CURATOR),
DBA( "role:/50",LoginFormBean.DBA); DBA( "role:/50",LoginStatusBean.DBA);
private final String roleUri; private final String roleUri;
private final int level; private final int level;

View file

@ -6,7 +6,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.openrdf.model.impl.URIImpl; import org.openrdf.model.impl.URIImpl;
import edu.cornell.mannlib.vedit.beans.LoginFormBean; import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.flags.AuthFlag; import edu.cornell.mannlib.vitro.webapp.flags.AuthFlag;
@ -69,15 +69,15 @@ public class BaseResourceBean implements ResourceBean {
public static RoleLevel getRoleFromAuth(AuthFlag ar){ public static RoleLevel getRoleFromAuth(AuthFlag ar){
int level = ar.getUserSecurityLevel(); int level = ar.getUserSecurityLevel();
if( level == LoginFormBean.ANYBODY) // 0 if( level == LoginStatusBean.ANYBODY) // 0
return PUBLIC; return PUBLIC;
if( level == LoginFormBean.NON_EDITOR) // 1 if( level == LoginStatusBean.NON_EDITOR) // 1
return PUBLIC; // no correspondence with self-editing, which does not authorize through the LoginFormBean return PUBLIC; // no correspondence with self-editing, which does not authorize through the LoginFormBean
if( level == LoginFormBean.EDITOR ) // 4 if( level == LoginStatusBean.EDITOR ) // 4
return EDITOR; return EDITOR;
if( level == LoginFormBean.CURATOR ) // 5 if( level == LoginStatusBean.CURATOR ) // 5
return CURATOR; return CURATOR;
if( level == LoginFormBean.DBA ) // 50 if( level == LoginStatusBean.DBA ) // 50
return DB_ADMIN; return DB_ADMIN;
else else
return null; return null;

View file

@ -10,7 +10,7 @@ import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vedit.beans.LoginFormBean; import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.beans.User; import edu.cornell.mannlib.vitro.webapp.beans.User;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.UserDao; import edu.cornell.mannlib.vitro.webapp.dao.UserDao;
@ -32,12 +32,12 @@ public class Logout extends HttpServlet {
UserDao userDao = ((WebappDaoFactory) session UserDao userDao = ((WebappDaoFactory) session
.getServletContext().getAttribute("webappDaoFactory")) .getServletContext().getAttribute("webappDaoFactory"))
.getUserDao(); .getUserDao();
LoginFormBean f = (LoginFormBean) session
.getAttribute("loginHandler"); LoginStatusBean loginBean = LoginStatusBean.getBean(session);
if (f != null) { if (loginBean.isLoggedIn()) {
User user = userDao.getUserByUsername(f.getLoginName()); User user = userDao.getUserByUsername(loginBean.getUsername());
if (user == null) { if (user == null) {
log.error("Unable to retrieve user " + f.getLoginName() log.error("Unable to retrieve user " + loginBean.getUsername()
+ " from model"); + " from model");
} else { } else {
Authenticate.sendLoginNotifyEvent( Authenticate.sendLoginNotifyEvent(

View file

@ -27,6 +27,7 @@ import com.hp.hpl.jena.shared.JenaException;
import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.shared.Lock;
import edu.cornell.mannlib.vedit.beans.LoginFormBean; import edu.cornell.mannlib.vedit.beans.LoginFormBean;
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vedit.controller.BaseEditController; import edu.cornell.mannlib.vedit.controller.BaseEditController;
import edu.cornell.mannlib.vitro.webapp.beans.Portal; import edu.cornell.mannlib.vitro.webapp.beans.Portal;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers; import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
@ -66,7 +67,7 @@ public class RDFUploadController extends BaseEditController {
return; return;
} }
LoginFormBean loginBean = (LoginFormBean) request.getSession().getAttribute("loginHandler"); LoginStatusBean loginBean = LoginStatusBean.getBean(request);
try { try {
super.doGet(request,response); super.doGet(request,response);

View file

@ -3,7 +3,6 @@
package edu.cornell.mannlib.vitro.webapp.controller.login; package edu.cornell.mannlib.vitro.webapp.controller.login;
import java.io.IOException; import java.io.IOException;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -13,11 +12,10 @@ import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vedit.beans.LoginFormBean; import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.edit.Authenticate; import edu.cornell.mannlib.vitro.webapp.controller.edit.Authenticate;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.State; import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.State;
import freemarker.template.Configuration; import freemarker.template.Configuration;
@ -178,19 +176,12 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
* Where are we in the process? Logged in? Not? Somewhere in between? * Where are we in the process? Logged in? Not? Somewhere in between?
*/ */
private State getCurrentLoginState(HttpServletRequest request) { private State getCurrentLoginState(HttpServletRequest request) {
HttpSession session = request.getSession(false); if (LoginStatusBean.getBean(request).isLoggedIn()) {
if (session == null) {
return State.NOWHERE;
}
LoginFormBean lfb = (LoginFormBean) session
.getAttribute("loginHandler");
if ((lfb != null) && (lfb.getLoginStatus().equals("authenticated"))) {
return State.LOGGED_IN; return State.LOGGED_IN;
} } else {
return getLoginProcessBean(request).getState(); return getLoginProcessBean(request).getState();
} }
}
/** /**
* How is the login process coming along? * How is the login process coming along?