diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/CuratorEditingIdentifierFactory.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/CuratorEditingIdentifierFactory.java index 649099ac2..b59405dfc 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/CuratorEditingIdentifierFactory.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/CuratorEditingIdentifierFactory.java @@ -40,6 +40,6 @@ public class CuratorEditingIdentifierFactory implements IdentifierBundleFactory{ public String getUri(){ return uri; } - public String toString(){ return uri; } + public String toString(){ return "CuratorEditingId: " + uri; } } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/DbAdminEditingIdentifierFactory.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/DbAdminEditingIdentifierFactory.java index 5fa04ee4e..6be72b250 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/DbAdminEditingIdentifierFactory.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/DbAdminEditingIdentifierFactory.java @@ -43,7 +43,7 @@ public class DbAdminEditingIdentifierFactory implements IdentifierBundleFactory{ public String getUri(){ return uri; } public String toString(){ - return "DbAdmin role of " + getRole(); + return "DbAdminEditingId: role of " + getRole(); } } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/RoleIdentifier.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/RoleIdentifier.java index 7da77eecf..2d6d7797d 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/RoleIdentifier.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/RoleIdentifier.java @@ -2,8 +2,6 @@ package edu.cornell.mannlib.vitro.webapp.auth.identifier; -import edu.cornell.mannlib.vitro.webapp.auth.identifier.SelfEditingIdentifierFactory.SelfEditing; - public abstract class RoleIdentifier implements Identifier { public abstract String getRole(); public abstract String getUri(); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/SelfEditingIdentifierFactory.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/SelfEditingIdentifierFactory.java index dddc4c26e..6d308e175 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/SelfEditingIdentifierFactory.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/SelfEditingIdentifierFactory.java @@ -33,22 +33,19 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; /** * Pulls a netId out of the CUWebAuth REMOTE_USER header. * - * * @author bdc34 - * */ public class SelfEditingIdentifierFactory implements IdentifierBundleFactory { public final static String httpHeaderForNetId = "REMOTE_USER"; private static final Log log = LogFactory.getLog(SelfEditingIdentifierFactory.class.getName()); - public IdentifierBundle getIdentifierBundle(ServletRequest request, HttpSession session, ServletContext context) { IdentifierBundle idb = getFromCUWebAuthHeader(request,session,context); if( idb != null ) return idb; else - return getFromSession(request,session); + return getFromSession(session); } private IdentifierBundle getFromCUWebAuthHeader(ServletRequest request, HttpSession session,ServletContext context){ @@ -100,7 +97,6 @@ public class SelfEditingIdentifierFactory implements IdentifierBundleFactory { } putNetIdInSession(session, selfE, netid); return idb; - } /** @@ -139,7 +135,7 @@ public class SelfEditingIdentifierFactory implements IdentifierBundleFactory { break; }catch(RuntimeException ex){ log.error("Could not run blacklist check query for file " + - file.getAbsolutePath() + file.separatorChar + file.getName(), + file.getAbsolutePath() + File.separatorChar + file.getName(), ex); } } @@ -214,7 +210,7 @@ public class SelfEditingIdentifierFactory implements IdentifierBundleFactory { return null; } - private IdentifierBundle getFromSession(ServletRequest req, HttpSession session ){ + private IdentifierBundle getFromSession( HttpSession session ){ if (session == null) { return null; } @@ -258,7 +254,7 @@ public class SelfEditingIdentifierFactory implements IdentifierBundleFactory { this.value = value; } public String getValue(){return value;} - public String toString(){ return value;} + public String toString(){ return "NetID: " + value;} } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/UserToIndIdentifierFactory.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/UserToIndIdentifierFactory.java index 680a20b1c..8aa3e84e0 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/UserToIndIdentifierFactory.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/UserToIndIdentifierFactory.java @@ -86,6 +86,11 @@ public class UserToIndIdentifierFactory implements IdentifierBundleFactory { } public List getMayEditAsURIs() { return mayEditAsURIs; - } + } + @Override + public String toString() { + return "UserIdentifier: " + userURI; + } + } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/RoleBasedPolicy.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/RoleBasedPolicy.java index d66ed8a2b..ae8d82bca 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/RoleBasedPolicy.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/RoleBasedPolicy.java @@ -57,7 +57,7 @@ public class RoleBasedPolicy extends DefaultInconclusivePolicy implements Polic /** * What is the minimum AuthRole needed to perform a given action? */ - private static Map actionToMinRole = new HashMap(); + private static Map,AuthRole> actionToMinRole = new HashMap,AuthRole>(); static{ //anybody actions //view resources? @@ -103,7 +103,7 @@ public class RoleBasedPolicy extends DefaultInconclusivePolicy implements Polic //We need to find the class of the RequestedAction since that //encodes what type of action is being requested. - Class requesetClass = whatToAuth.getClass(); + Class requesetClass = whatToAuth.getClass(); AuthRole minmumRoleForAction = actionToMinRole.get(requesetClass); if( minmumRoleForAction == null ){ @@ -118,33 +118,14 @@ public class RoleBasedPolicy extends DefaultInconclusivePolicy implements Polic return new BasicPolicyDecision(Authorization.UNAUTHORIZED,"not authorized for role"); } - /** - * Because it extends AbstractPolicySetup and implements this method, RoleBasedPolicy - * can be used as a ServletContextListener that puts its self on the ServletPolicyList - * at servlet context initialization. - * - * Notice that this method also setups the IdentifierBundleFactory that it needs. - */ -// @Override -// public List createPolicies(ServletContextEvent sce) { -// List list = new ArrayList(1); -// list.add(new RoleBasedPolicy()); -// -// //notice that the idBundleFactory gets created here, -// JenaRoleIdentifierBundleFactory jibf = new JenaRoleIdentifierBundleFactory(userModelUri); -// ServletIdentifierBundleFactory.addIdentifierBundleFactory(sce.getServletContext(),jibf); -// -// return list; -// } + @Override + public String toString() { + return "RoleBasedPolicy"; + } - /********************** Roles *****************************************/ + + /********************** Roles *****************************************/ public static enum AuthRole implements Identifier { -// ANYBODY("http://vitro.mannlib.cornell.edu/authRole#anybody",0), -// USER("http://vitro.mannlib.cornell.edu/authRole#user",1), -// EDITOR("http://vitro.mannlib.cornell.edu/authRole#editor",2), -// CURATOR("http://vitro.mannlib.cornell.edu/authRole#curator",3), -// DBA("http://vitro.mannlib.cornell.edu/authRole#dba",50); - ANYBODY( "role:/0" ,LoginStatusBean.ANYBODY), USER( "role:/1" ,LoginStatusBean.NON_EDITOR), EDITOR( "role:/4" ,LoginStatusBean.EDITOR), @@ -181,5 +162,10 @@ public class RoleBasedPolicy extends DefaultInconclusivePolicy implements Polic } return false; } + + @Override + public String toString() { + return "AuthRole: " + name(); + } }/* end of enum AuthRole */ }/* end of class RoleBasedPolicy */ diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/ifaces/DefaultAuthorizedPolicy.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/ifaces/DefaultAuthorizedPolicy.java index 7a4259c1a..0e64f5b40 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/ifaces/DefaultAuthorizedPolicy.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/ifaces/DefaultAuthorizedPolicy.java @@ -4,35 +4,18 @@ package edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces; import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle; import edu.cornell.mannlib.vitro.webapp.auth.policy.BasicPolicyDecision; -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.AddResource; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.DropDataPropStmt; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.DropObjectPropStmt; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.DropResource; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.EditDataPropStmt; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.EditObjPropStmt; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.AddNewUser; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.LoadOntology; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.RebuildTextIndex; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.RemoveUser; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.ServerStatus; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.UpdateTextIndex; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.UploadFile; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.CreateOwlClass; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineDataProperty; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineObjectProperty; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.RemoveOwlClass; /** * a policy where every type of action is authorized as INCONCLUSIVE * by default. * * @author bdc34 - * */ public class DefaultAuthorizedPolicy implements PolicyIface{ + protected static PolicyDecision AUTHORIZED_DECISION = new BasicPolicyDecision( + Authorization.AUTHORIZED, + "This is the default decision defined in DefaultAuthorizedPolicy"); public PolicyDecision isAuthorized(IdentifierBundle whoToAuth, RequestedAction whatToAuth) { @@ -45,7 +28,8 @@ public class DefaultAuthorizedPolicy implements PolicyIface{ return AUTHORIZED_DECISION; } - protected static PolicyDecision AUTHORIZED_DECISION = new BasicPolicyDecision( - Authorization.AUTHORIZED, - "This is the default decision defined in DefaultAuthorizedPolicy"); + @Override + public String toString() { + return "DefaultAuthorizedPolicy"; + } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/ifaces/DefaultInconclusivePolicy.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/ifaces/DefaultInconclusivePolicy.java index 606b1d20c..0729ecf5f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/ifaces/DefaultInconclusivePolicy.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/ifaces/DefaultInconclusivePolicy.java @@ -4,35 +4,17 @@ package edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces; import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle; import edu.cornell.mannlib.vitro.webapp.auth.policy.BasicPolicyDecision; -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.AddResource; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.DropDataPropStmt; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.DropObjectPropStmt; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.DropResource; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.EditDataPropStmt; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.EditObjPropStmt; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.AddNewUser; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.LoadOntology; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.RebuildTextIndex; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.RemoveUser; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.ServerStatus; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.UpdateTextIndex; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.UploadFile; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.CreateOwlClass; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineDataProperty; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineObjectProperty; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.RemoveOwlClass; /** - * A policy where every type of action is authorized as INCONCLUSIVE - * by default. - * + * A policy where every type of action is authorized as INCONCLUSIVE by default. + * * @author bdc34 - * */ -public class DefaultInconclusivePolicy implements PolicyIface{ +public class DefaultInconclusivePolicy implements PolicyIface { + protected static PolicyDecision INCONCLUSIVE_DECISION = new BasicPolicyDecision( + Authorization.INCONCLUSIVE, + "This is the default decision defined in DefaultInconclusivePolicy"); public PolicyDecision isAuthorized(IdentifierBundle whoToAuth, RequestedAction whatToAuth) { @@ -44,7 +26,10 @@ public class DefaultInconclusivePolicy implements PolicyIface{ "null was passed as whatToAuth"); return INCONCLUSIVE_DECISION; } - protected static PolicyDecision INCONCLUSIVE_DECISION = new BasicPolicyDecision( - Authorization.INCONCLUSIVE, - "This is the default decision defined in DefaultInconclusivePolicy"); + + @Override + public String toString() { + return "DefaultInconclusivePolicy"; + } + } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/ifaces/DefaultUnauthorizedPolicy.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/ifaces/DefaultUnauthorizedPolicy.java index a4558634a..9d7b76e27 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/ifaces/DefaultUnauthorizedPolicy.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/ifaces/DefaultUnauthorizedPolicy.java @@ -4,41 +4,19 @@ package edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces; import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle; import edu.cornell.mannlib.vitro.webapp.auth.policy.BasicPolicyDecision; -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.AddResource; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.DropDataPropStmt; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.DropObjectPropStmt; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.DropResource; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.EditDataPropStmt; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.EditObjPropStmt; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.AddNewUser; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.LoadOntology; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.RebuildTextIndex; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.RemoveUser; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.ServerStatus; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.UpdateTextIndex; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.UploadFile; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.CreateOwlClass; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineDataProperty; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineObjectProperty; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.RemoveOwlClass; /** - * *a policy where every type of action is authorized as UNAUTHORIZED * by default. This can be useful for a unauthenticated session or * as the last policy on a PolicyList to force INCONCLUSIVE decisions * to UNAUTHORIZED. */ public class DefaultUnauthorizedPolicy implements PolicyIface{ - protected static PolicyDecision UNAUTHORIZED_DECISION = new BasicPolicyDecision( Authorization.UNAUTHORIZED, "This is the default decision defined in DefaultUnauthorizedPolicy"); - public PolicyDecision isAuthorized(IdentifierBundle whoToAuth, RequestedAction whatToAuth) { if (whoToAuth == null) @@ -48,5 +26,10 @@ public class DefaultUnauthorizedPolicy implements PolicyIface{ return new BasicPolicyDecision(Authorization.UNAUTHORIZED, "null was passed as whatToAuth"); return UNAUTHORIZED_DECISION; - } + } + + @Override + public String toString() { + return "DefaultInconclusivePolicy"; + } }