NIHVIVO-736 transitioning from LoginFormBean to LoginStatusBean.

This commit is contained in:
jeb228 2010-10-13 18:34:41 +00:00
parent 275ef7d471
commit b4ea726109
5 changed files with 74 additions and 84 deletions

View file

@ -23,13 +23,11 @@ import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vedit.beans.EditProcessObject;
import edu.cornell.mannlib.vedit.beans.LoginFormBean;
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vedit.util.FormUtils;
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
public class BaseEditController extends VitroHttpServlet {

View file

@ -6,7 +6,7 @@ import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpSession;
import edu.cornell.mannlib.vedit.beans.LoginFormBean;
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.auth.policy.RoleBasedPolicy;
import edu.cornell.mannlib.vitro.webapp.auth.policy.RoleBasedPolicy.AuthRole;
@ -17,15 +17,12 @@ public class CuratorEditingIdentifierFactory implements IdentifierBundleFactory{
IdentifierBundle ib = new ArrayIdentifierBundle();
ib.add( RoleBasedPolicy.AuthRole.ANYBODY);
if( session != null ){
LoginFormBean f = (LoginFormBean) session.getAttribute( "loginHandler" );
try{
if( f != null && Integer.parseInt( f.getLoginRole() ) >= LoginFormBean.CURATOR){
ib.add(new CuratorEditingId(f.getLoginRole(),f.getUserURI()));
LoginStatusBean loginBean = LoginStatusBean.getBean(session);
if (loginBean.isLoggedInAtLeast(LoginStatusBean.CURATOR)) {
String loginRole = String.valueOf(loginBean.getSecurityLevel());
ib.add(new CuratorEditingId(loginRole, loginBean.getUserURI()));
ib.add(AuthRole.CURATOR);
}
}catch(NumberFormatException th){}
}
return ib;
}

View file

@ -6,7 +6,7 @@ import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpSession;
import edu.cornell.mannlib.vedit.beans.LoginFormBean;
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.auth.policy.RoleBasedPolicy;
import edu.cornell.mannlib.vitro.webapp.auth.policy.RoleBasedPolicy.AuthRole;
@ -17,15 +17,12 @@ public class DbAdminEditingIdentifierFactory implements IdentifierBundleFactory{
IdentifierBundle ib = new ArrayIdentifierBundle();
ib.add( RoleBasedPolicy.AuthRole.ANYBODY);
if( session != null ){
LoginFormBean f = (LoginFormBean) session.getAttribute( "loginHandler" );
try{
if( f != null && Integer.parseInt( f.getLoginRole() ) >= LoginFormBean.DBA){
ib.add(new DbAdminEditingId(f.getLoginRole(),f.getUserURI()));
LoginStatusBean loginBean = LoginStatusBean.getBean(session);
if (loginBean.isLoggedInAtLeast(LoginStatusBean.DBA)) {
String loginRole = String.valueOf(loginBean.getSecurityLevel());
ib.add(new DbAdminEditingId(loginRole, loginBean.getUserURI()));
ib.add(AuthRole.DBA);
}
}catch(NumberFormatException th){}
}
return ib;
}

View file

@ -6,7 +6,7 @@ import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpSession;
import edu.cornell.mannlib.vedit.beans.LoginFormBean;
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.auth.policy.RoleBasedPolicy;
import edu.cornell.mannlib.vitro.webapp.auth.policy.RoleBasedPolicy.AuthRole;
@ -16,15 +16,14 @@ public class EditorEditingIdentifierFactory implements IdentifierBundleFactory{
HttpSession session, ServletContext context) {
IdentifierBundle ib = new ArrayIdentifierBundle();
ib.add( RoleBasedPolicy.AuthRole.ANYBODY);
if( session != null ){
LoginFormBean f = (LoginFormBean) session.getAttribute( "loginHandler" );
try{
if( f != null && Integer.parseInt( f.getLoginRole() ) >= LoginFormBean.EDITOR){
ib.add(new EditorEditingId(f.getLoginRole(), f.getUserURI()));
LoginStatusBean loginBean = LoginStatusBean.getBean(session);
if (loginBean.isLoggedInAtLeast(LoginStatusBean.EDITOR)) {
String loginRole = String.valueOf(loginBean.getSecurityLevel());
ib.add(new EditorEditingId(loginRole, loginBean.getUserURI()));
ib.add(AuthRole.EDITOR);
}
}catch(NumberFormatException th){ }
}
return ib;
}

View file

@ -10,7 +10,7 @@ import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpSession;
import edu.cornell.mannlib.vedit.beans.LoginFormBean;
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
@ -27,10 +27,9 @@ public class UserToIndIdentifierFactory implements IdentifierBundleFactory {
ServletRequest request,
HttpSession session,
ServletContext context) {
if( session != null ){
// is the request logged in as a User?
LoginFormBean loginBean = (LoginFormBean) session.getAttribute("loginHandler");
if( loginBean != null && "authenticated".equals(loginBean.getLoginStatus() )){
LoginStatusBean loginBean = LoginStatusBean.getBean(session);
if (loginBean.isLoggedIn()) {
String userURI = loginBean.getUserURI();
WebappDaoFactory wdf = (WebappDaoFactory)context.getAttribute("webappDaoFactory");
@ -56,13 +55,13 @@ public class UserToIndIdentifierFactory implements IdentifierBundleFactory {
}
return idb;
}
}
return null;
}
public static List<String> getIndividualsForUser(IdentifierBundle ids) {
if( ids == null )
return Collections.EMPTY_LIST;
return Collections.emptyList();
//find the user id
List<String> uris = new ArrayList<String>();