public class AuthorizeManager
extends java.lang.Object
ResourcePolicies now apply to single objects (such as submit (ADD) permission to a collection.)
Note: If an eperson is a member of the administrator group (id 1), then they are automatically given permission for all requests another special group is group 0, which is anonymous - all EPeople are members of group 0.
| Constructor and Description |
|---|
AuthorizeManager() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addPolicies(Context c,
java.util.List<ResourcePolicy> policies,
DSpaceObject dest)
Copies policies from a list of resource policies to a given DSpaceObject
|
static void |
addPolicy(Context c,
DSpaceObject o,
int actionID,
EPerson e)
Add a policy for an individual eperson
|
static void |
addPolicy(Context c,
DSpaceObject o,
int actionID,
EPerson e,
java.lang.String type)
Add a policy for an individual eperson
|
static void |
addPolicy(Context c,
DSpaceObject o,
int actionID,
Group g)
Add a policy for a group
|
static void |
addPolicy(Context c,
DSpaceObject o,
int actionID,
Group g,
java.lang.String type)
Add a policy for a group
|
static void |
authorizeAction(Context c,
DSpaceObject o,
int action)
Checks that the context's current user can perform the given action on
the given object.
|
static void |
authorizeAction(Context c,
DSpaceObject o,
int action,
boolean useInheritance)
Checks that the context's current user can perform the given action on
the given object.
|
static boolean |
authorizeActionBoolean(Context c,
DSpaceObject o,
int a)
same authorize, returns boolean for those who don't want to deal with
catching exceptions.
|
static boolean |
authorizeActionBoolean(Context c,
DSpaceObject o,
int a,
boolean useInheritance)
same authorize, returns boolean for those who don't want to deal with
catching exceptions.
|
static void |
authorizeAnyOf(Context c,
DSpaceObject o,
int[] actions)
Utility method, checks that the current user of the given context can
perform all of the specified actions on the given object.
|
static ResourcePolicy |
createOrModifyPolicy(ResourcePolicy policy,
Context context,
java.lang.String name,
int idGroup,
EPerson ePerson,
java.util.Date embargoDate,
int action,
java.lang.String reason,
DSpaceObject dso) |
static ResourcePolicy |
findByTypeIdGroupAction(Context c,
int dsoType,
int dsoID,
int groupID,
int action,
int policyID) |
static java.util.List<ResourcePolicy> |
findPoliciesByDSOAndType(Context c,
DSpaceObject o,
java.lang.String type)
Return a List of the policies for an object
|
static void |
generateAutomaticPolicies(Context context,
java.util.Date embargoDate,
java.lang.String reason,
DSpaceObject dso,
Collection owningCollection)
Generate Policies policies READ for the date in input adding reason.
|
static Group[] |
getAuthorizedGroups(Context c,
DSpaceObject o,
int actionID)
Returns all groups authorized to perform an action on an object.
|
static java.util.List<ResourcePolicy> |
getPolicies(Context c,
DSpaceObject o)
Return a List of the policies for an object
|
static java.util.List<ResourcePolicy> |
getPoliciesActionFilter(Context c,
DSpaceObject o,
int actionID)
Return a list of policies for an object that match the action
|
static java.util.List<ResourcePolicy> |
getPoliciesForGroup(Context c,
Group g)
Return a List of the policies for a group
|
static void |
inheritPolicies(Context c,
DSpaceObject src,
DSpaceObject dest)
Add policies to an object to match those from a previous object
|
static boolean |
isAdmin(Context c)
Check to see if the current user is a System Admin.
|
static boolean |
isAdmin(Context c,
DSpaceObject o)
Check to see if the current user is an Administrator of a given object
within DSpace.
|
static boolean |
isAnIdenticalPolicyAlreadyInPlace(Context c,
DSpaceObject o,
int groupID,
int action,
int policyID)
Is a policy with the specified parameters already in place?
|
static boolean |
isAnIdenticalPolicyAlreadyInPlace(Context c,
DSpaceObject o,
ResourcePolicy rp) |
static boolean |
isAnIdenticalPolicyAlreadyInPlace(Context c,
int dsoType,
int dsoID,
int groupID,
int action,
int policyID)
Is a policy with the specified parameters already in place?
|
static void |
removeAllPolicies(Context c,
DSpaceObject o)
removes ALL policies for an object.
|
static void |
removeAllPoliciesByDSOAndType(Context c,
DSpaceObject o,
java.lang.String type)
removes policies
|
static void |
removeAllPoliciesByDSOAndTypeNotEqualsTo(Context c,
DSpaceObject o,
java.lang.String type)
removes ALL policies for an object that are not of the input type.
|
static void |
removeEPersonPolicies(Context c,
DSpaceObject o,
EPerson e)
Removes all policies from an eperson for a particular object that belong to
an EPerson.
|
static void |
removeGroupPolicies(Context c,
DSpaceObject o,
Group g)
Removes all policies from a group for a particular object that belong to
a Group.
|
static void |
removeGroupPolicies(Context c,
int groupID)
Removes all policies relating to a particular group.
|
static void |
removePoliciesActionFilter(Context context,
DSpaceObject dso,
int actionID)
Remove all policies from an object that match a given action.
|
static void |
switchPoliciesAction(Context context,
DSpaceObject dso,
int fromAction,
int toAction)
Change all the policies related to the action (fromPolicy) of the
specified object to the new action (toPolicy)
|
public static void authorizeAnyOf(Context c, DSpaceObject o, int[] actions) throws AuthorizeException, java.sql.SQLException
AuthorizeException if all the authorizations fail.c - context with the current usero - DSpace object user is attempting to perform action onactions - array of action IDs from
org.dspace.core.ConstantsAuthorizeException - if any one of the specified actions cannot be performed by
the current user on the given object.java.sql.SQLException - if there's a database problempublic static void authorizeAction(Context c, DSpaceObject o, int action) throws AuthorizeException, java.sql.SQLException
c - contexto - a DSpaceObjectaction - action to perform from org.dspace.core.ConstantsAuthorizeException - if the user is deniedjava.sql.SQLExceptionpublic static void authorizeAction(Context c, DSpaceObject o, int action, boolean useInheritance) throws AuthorizeException, java.sql.SQLException
c - contexto - a DSpaceObjectuseInheritance - flag to say if ADMIN action on the current object or parent
object can be usedaction - action to perform from org.dspace.core.ConstantsAuthorizeException - if the user is deniedjava.sql.SQLExceptionpublic static boolean authorizeActionBoolean(Context c, DSpaceObject o, int a) throws java.sql.SQLException
c - DSpace context, containing current usero - DSpaceObjecta - action being attempted, from
org.dspace.core.Constantstrue if the current user in the context is
authorized to perform the given action on the given objectjava.sql.SQLExceptionpublic static boolean authorizeActionBoolean(Context c, DSpaceObject o, int a, boolean useInheritance) throws java.sql.SQLException
c - DSpace context, containing current usero - DSpaceObjecta - action being attempted, from
org.dspace.core.ConstantsuseInheritance - flag to say if ADMIN action on the current object or parent
object can be usedtrue if the current user in the context is
authorized to perform the given action on the given objectjava.sql.SQLExceptionpublic static boolean isAdmin(Context c, DSpaceObject o) throws java.sql.SQLException
true if the user is a System
Adminc - current contexto - current DSpace Object, if null the call will be
equivalent to a call to the isAdmin(Context c)
methodtrue if user has administrative privileges on the
given DSpace objectjava.sql.SQLExceptionpublic static boolean isAdmin(Context c) throws java.sql.SQLException
true if c.ignoreAuthorization is set. Anonymous users
can't be Admins (EPerson set to NULL)c - current contexttrue if user is an admin or ignore authorization
flag setjava.sql.SQLExceptionpublic static void addPolicy(Context c, DSpaceObject o, int actionID, EPerson e) throws java.sql.SQLException, AuthorizeException
c - context. Current user irrelevanto - DSpaceObject to add policy toactionID - ID of action from org.dspace.core.Constantse - eperson who can perform the actionAuthorizeException - if current user in context is not authorized to add policiesjava.sql.SQLExceptionpublic static void addPolicy(Context c, DSpaceObject o, int actionID, EPerson e, java.lang.String type) throws java.sql.SQLException, AuthorizeException
c - context. Current user irrelevanto - DSpaceObject to add policy toactionID - ID of action from org.dspace.core.Constantse - eperson who can perform the actiontype - policy type, deafult types are declared in the ResourcePolicy classAuthorizeException - if current user in context is not authorized to add policiesjava.sql.SQLExceptionpublic static void addPolicy(Context c, DSpaceObject o, int actionID, Group g) throws java.sql.SQLException, AuthorizeException
c - current contexto - object to add policy foractionID - ID of action from org.dspace.core.Constantsg - group to add policy forjava.sql.SQLException - if there's a database problemAuthorizeException - if the current user is not authorized to add this policypublic static void addPolicy(Context c, DSpaceObject o, int actionID, Group g, java.lang.String type) throws java.sql.SQLException, AuthorizeException
c - current contexto - object to add policy foractionID - ID of action from org.dspace.core.Constantsg - group to add policy fortype - policy type, deafult types are declared in the ResourcePolicy classjava.sql.SQLException - if there's a database problemAuthorizeException - if the current user is not authorized to add this policypublic static java.util.List<ResourcePolicy> getPolicies(Context c, DSpaceObject o) throws java.sql.SQLException
c - current contexto - object to retrieve policies forResourcePolicy objectsjava.sql.SQLExceptionpublic static java.util.List<ResourcePolicy> findPoliciesByDSOAndType(Context c, DSpaceObject o, java.lang.String type) throws java.sql.SQLException
c - current contexto - object to retrieve policies forResourcePolicy objectsjava.sql.SQLExceptionpublic static java.util.List<ResourcePolicy> getPoliciesForGroup(Context c, Group g) throws java.sql.SQLException
c - current contextg - group to retrieve policies forResourcePolicy objectsjava.sql.SQLExceptionpublic static java.util.List<ResourcePolicy> getPoliciesActionFilter(Context c, DSpaceObject o, int actionID) throws java.sql.SQLException
c - contexto - DSpaceObject policies relate toactionID - action (defined in class Constants)java.sql.SQLException - if there's a database problempublic static void inheritPolicies(Context c, DSpaceObject src, DSpaceObject dest) throws java.sql.SQLException, AuthorizeException
c - contextsrc - source of policiesdest - destination of inherited policiesjava.sql.SQLException - if there's a database problemAuthorizeException - if the current user is not authorized to add these policiespublic static void addPolicies(Context c, java.util.List<ResourcePolicy> policies, DSpaceObject dest) throws java.sql.SQLException, AuthorizeException
c - DSpace contextpolicies - List of ResourcePolicy objectsdest - object to have policies addedjava.sql.SQLException - if there's a database problemAuthorizeException - if the current user is not authorized to add these policiespublic static void removeAllPolicies(Context c, DSpaceObject o) throws java.sql.SQLException
c - DSpace contexto - object to remove policies forjava.sql.SQLException - if there's a database problempublic static void removeAllPoliciesByDSOAndTypeNotEqualsTo(Context c, DSpaceObject o, java.lang.String type) throws java.sql.SQLException
c - DSpace contexto - object to remove policies forjava.sql.SQLException - if there's a database problempublic static void removeAllPoliciesByDSOAndType(Context c, DSpaceObject o, java.lang.String type) throws java.sql.SQLException
c - DSpace contexto - object to remove policies fortype - policy typejava.sql.SQLException - if there's a database problempublic static void removePoliciesActionFilter(Context context, DSpaceObject dso, int actionID) throws java.sql.SQLException
context - current contextdso - object to remove policies fromactionID - ID of action to match from
org.dspace.core.Constants, or -1=alljava.sql.SQLException - if there's a database problempublic static void removeGroupPolicies(Context c, int groupID) throws java.sql.SQLException
c - current contextgroupID - ID of the groupjava.sql.SQLException - if there's a database problempublic static void removeGroupPolicies(Context c, DSpaceObject o, Group g) throws java.sql.SQLException
c - current contexto - the objectg - the groupjava.sql.SQLException - if there's a database problempublic static void switchPoliciesAction(Context context, DSpaceObject dso, int fromAction, int toAction) throws java.sql.SQLException, AuthorizeException
context - dso - the dspace objectfromAction - the action to changetoAction - the new action to setjava.sql.SQLExceptionAuthorizeExceptionpublic static void removeEPersonPolicies(Context c, DSpaceObject o, EPerson e) throws java.sql.SQLException
c - current contexto - the objecte - the epersonjava.sql.SQLException - if there's a database problempublic static Group[] getAuthorizedGroups(Context c, DSpaceObject o, int actionID) throws java.sql.SQLException
c - current contexto - objectactionID - ID of action from org.dspace.core.ConstantsGroups that can perform the specified
action on the specified objectjava.sql.SQLException - if there's a database problempublic static boolean isAnIdenticalPolicyAlreadyInPlace(Context c, DSpaceObject o, ResourcePolicy rp) throws java.sql.SQLException
java.sql.SQLExceptionpublic static boolean isAnIdenticalPolicyAlreadyInPlace(Context c, DSpaceObject o, int groupID, int action, int policyID) throws java.sql.SQLException
c - current contexto - objectactionID - ID of action from org.dspace.core.ConstantspolicyID - ID of an existing policy. If -1 is specified, this parameter will be ignoredjava.sql.SQLException - if there's a database problempublic static boolean isAnIdenticalPolicyAlreadyInPlace(Context c, int dsoType, int dsoID, int groupID, int action, int policyID) throws java.sql.SQLException
c - current contexto - ID of an objectaction - ID of action from org.dspace.core.ConstantspolicyID - ID of an existing policy. If -1 is specified, this parameter will be ignoredjava.sql.SQLException - if there's a database problempublic static ResourcePolicy findByTypeIdGroupAction(Context c, int dsoType, int dsoID, int groupID, int action, int policyID) throws java.sql.SQLException
java.sql.SQLExceptionpublic static void generateAutomaticPolicies(Context context, java.util.Date embargoDate, java.lang.String reason, DSpaceObject dso, Collection owningCollection) throws java.sql.SQLException, AuthorizeException
context - embargoDate - reason - dso - owningCollection - java.sql.SQLExceptionAuthorizeExceptionpublic static ResourcePolicy createOrModifyPolicy(ResourcePolicy policy, Context context, java.lang.String name, int idGroup, EPerson ePerson, java.util.Date embargoDate, int action, java.lang.String reason, DSpaceObject dso) throws AuthorizeException, java.sql.SQLException
AuthorizeExceptionjava.sql.SQLExceptionCopyright © 2018 DuraSpace. All Rights Reserved.