public class AuthorizeServiceImpl extends Object implements AuthorizeService
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.
| Modifier and Type | Field and Description |
|---|---|
protected BitstreamService |
bitstreamService |
protected GroupService |
groupService |
protected ResourcePolicyService |
resourcePolicyService |
protected ContentServiceFactory |
serviceFactory |
protected WorkflowItemService |
workflowItemService |
protected WorkspaceItemService |
workspaceItemService |
| Modifier | Constructor and Description |
|---|---|
protected |
AuthorizeServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
addPolicies(Context c,
List<ResourcePolicy> policies,
DSpaceObject dest)
Copies policies from a list of resource policies to a given DSpaceObject
|
void |
addPolicy(Context c,
DSpaceObject o,
int actionID,
EPerson e)
Add a policy for an individual eperson
|
void |
addPolicy(Context context,
DSpaceObject o,
int actionID,
EPerson e,
String type)
Add a policy for an individual eperson
|
void |
addPolicy(Context c,
DSpaceObject o,
int actionID,
Group g)
Add a policy for a group
|
void |
addPolicy(Context c,
DSpaceObject o,
int actionID,
Group g,
String type)
Add a policy for a group
|
protected boolean |
authorize(Context c,
DSpaceObject o,
int action,
EPerson e,
boolean useInheritance)
Check to see if the given user can perform the given action on the given
object.
|
void |
authorizeAction(Context c,
DSpaceObject o,
int action)
Checks that the context's current user can perform the given action on
the given object.
|
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.
|
void |
authorizeAction(Context c,
EPerson e,
DSpaceObject o,
int action,
boolean useInheritance)
Checks that the specified eperson can perform the given action on
the given object.
|
boolean |
authorizeActionBoolean(Context c,
DSpaceObject o,
int a)
same authorize, returns boolean for those who don't want to deal with
catching exceptions.
|
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.
|
boolean |
authorizeActionBoolean(Context c,
EPerson e,
DSpaceObject o,
int a,
boolean useInheritance)
same authorize with a specif eperson (not the current user), returns boolean for those who don't want to deal with
catching exceptions.
|
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.
|
ResourcePolicy |
createOrModifyPolicy(ResourcePolicy policy,
Context context,
String name,
Group group,
EPerson ePerson,
Date embargoDate,
int action,
String reason,
DSpaceObject dso) |
ResourcePolicy |
createResourcePolicy(Context context,
DSpaceObject dso,
Group group,
EPerson eperson,
int type,
String rpType) |
ResourcePolicy |
findByTypeIdGroupAction(Context c,
DSpaceObject dso,
Group group,
int action,
int policyID) |
List<ResourcePolicy> |
findPoliciesByDSOAndType(Context c,
DSpaceObject o,
String type)
Return a List of the policies for an object
|
void |
generateAutomaticPolicies(Context context,
Date embargoDate,
String reason,
DSpaceObject dso,
Collection owningCollection)
Generate Policies policies READ for the date in input adding reason.
|
List<Group> |
getAuthorizedGroups(Context c,
DSpaceObject o,
int actionID)
Returns all groups authorized to perform an action on an object.
|
List<ResourcePolicy> |
getPolicies(Context c,
DSpaceObject o)
Return a List of the policies for an object
|
List<ResourcePolicy> |
getPoliciesActionFilter(Context c,
DSpaceObject o,
int actionID)
Return a list of policies for an object that match the action
|
List<ResourcePolicy> |
getPoliciesForGroup(Context c,
Group g)
Return a List of the policies for a group
|
void |
inheritPolicies(Context c,
DSpaceObject src,
DSpaceObject dest)
Add policies to an object to match those from a previous object
|
boolean |
isAdmin(Context c)
Check to see if the current user is a System Admin.
|
boolean |
isAdmin(Context c,
DSpaceObject o)
Check to see if the current user is an Administrator of a given object
within DSpace.
|
boolean |
isAnIdenticalPolicyAlreadyInPlace(Context c,
DSpaceObject dso,
Group group,
int action,
int policyID)
Is a policy with the specified parameters already in place?
|
boolean |
isAnIdenticalPolicyAlreadyInPlace(Context c,
DSpaceObject o,
ResourcePolicy rp) |
protected boolean |
isAnyItemInstalled(Context ctx,
List<Bundle> bundles) |
boolean |
isCollectionAdmin(Context c) |
boolean |
isCommunityAdmin(Context c) |
void |
removeAllPolicies(Context c,
DSpaceObject o)
removes ALL policies for an object.
|
void |
removeAllPoliciesByDSOAndType(Context c,
DSpaceObject o,
String type)
removes policies
|
void |
removeAllPoliciesByDSOAndTypeNotEqualsTo(Context c,
DSpaceObject o,
String type)
removes ALL policies for an object that are not of the input type.
|
void |
removeEPersonPolicies(Context c,
DSpaceObject o,
EPerson e)
Removes all policies from an eperson for a particular object that belong to
an EPerson.
|
void |
removeGroupPolicies(Context c,
DSpaceObject o,
Group g)
Removes all policies from a group for a particular object that belong to
a Group.
|
void |
removeGroupPolicies(Context c,
Group group)
Removes all policies relating to a particular group.
|
void |
removePoliciesActionFilter(Context context,
DSpaceObject dso,
int actionID)
Remove all policies from an object that match a given action.
|
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)
|
@Autowired(required=true) protected BitstreamService bitstreamService
@Autowired(required=true) protected ContentServiceFactory serviceFactory
@Autowired(required=true) protected GroupService groupService
@Autowired(required=true) protected ResourcePolicyService resourcePolicyService
@Autowired(required=true) protected WorkspaceItemService workspaceItemService
@Autowired(required=true) protected WorkflowItemService workflowItemService
public void authorizeAnyOf(Context c, DSpaceObject o, int[] actions) throws AuthorizeException, SQLException
AuthorizeServiceAuthorizeException if all the authorizations fail.authorizeAnyOf in interface AuthorizeServicec - 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.SQLException - if database errorpublic void authorizeAction(Context c, DSpaceObject o, int action) throws AuthorizeException, SQLException
AuthorizeServiceauthorizeAction in interface AuthorizeServicec - contexto - a DSpaceObjectaction - action to perform from org.dspace.core.ConstantsAuthorizeException - if the user is deniedSQLException - if database errorpublic void authorizeAction(Context c, DSpaceObject o, int action, boolean useInheritance) throws AuthorizeException, SQLException
AuthorizeServiceauthorizeAction in interface AuthorizeServicec - contexto - a DSpaceObjectaction - action to perform from org.dspace.core.ConstantsuseInheritance - flag to say if ADMIN action on the current object or parent
object can be usedAuthorizeException - if the user is deniedSQLException - if database errorpublic void authorizeAction(Context c, EPerson e, DSpaceObject o, int action, boolean useInheritance) throws AuthorizeException, SQLException
AuthorizeServiceauthorizeAction in interface AuthorizeServicec - contexte - the eperson to use for the authorization checko - a DSpaceObjectaction - action to perform from org.dspace.core.ConstantsuseInheritance - flag to say if ADMIN action on the current object or parent
object can be usedAuthorizeException - if the user is deniedSQLException - if database errorpublic boolean authorizeActionBoolean(Context c, DSpaceObject o, int a) throws SQLException
AuthorizeServiceauthorizeActionBoolean in interface AuthorizeServicec - 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 objectSQLException - if database errorpublic boolean authorizeActionBoolean(Context c, DSpaceObject o, int a, boolean useInheritance) throws SQLException
AuthorizeServiceauthorizeActionBoolean in interface AuthorizeServicec - 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 objectSQLException - if database errorpublic boolean authorizeActionBoolean(Context c, EPerson e, DSpaceObject o, int a, boolean useInheritance) throws SQLException
AuthorizeServiceauthorizeActionBoolean in interface AuthorizeServicec - DSpace contexte - EPerson to use in the checko - 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 requested user is
authorized to perform the given action on the given objectSQLException - if database errorprotected boolean authorize(Context c, DSpaceObject o, int action, EPerson e, boolean useInheritance) throws SQLException
c - current context. User is irrelevant; "ignore authorization"
flag is relevanto - object action is being attempted onaction - ID of action being attempted, from
org.dspace.core.Constantse - user attempting actionuseInheritance - flag to say if ADMIN action on the current object or parent
object can be usedtrue if user is authorized to perform the given
action, false otherwiseSQLException - if database errorprotected boolean isAnyItemInstalled(Context ctx, List<Bundle> bundles) throws SQLException
SQLExceptionpublic boolean isAdmin(Context c, DSpaceObject o) throws SQLException
AuthorizeServicetrue if the user is a System
AdminisAdmin in interface AuthorizeServicec - 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 objectSQLException - if database errorpublic boolean isAdmin(Context c) throws SQLException
AuthorizeServicetrue if c.ignoreAuthorization is set. Anonymous users
can't be Admins (EPerson set to NULL)isAdmin in interface AuthorizeServicec - current contexttrue if user is an admin or ignore authorization
flag setSQLException - if database errorpublic boolean isCommunityAdmin(Context c) throws SQLException
isCommunityAdmin in interface AuthorizeServiceSQLExceptionpublic boolean isCollectionAdmin(Context c) throws SQLException
isCollectionAdmin in interface AuthorizeServiceSQLExceptionpublic void addPolicy(Context c, DSpaceObject o, int actionID, EPerson e) throws SQLException, AuthorizeException
AuthorizeServiceaddPolicy in interface AuthorizeServicec - context. Current user irrelevanto - DSpaceObject to add policy toactionID - ID of action from org.dspace.core.Constantse - eperson who can perform the actionSQLException - if database errorAuthorizeException - if current user in context is not authorized to add policiespublic void addPolicy(Context context, DSpaceObject o, int actionID, EPerson e, String type) throws SQLException, AuthorizeException
AuthorizeServiceaddPolicy in interface AuthorizeServicecontext - 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 classSQLException - if database errorAuthorizeException - if current user in context is not authorized to add policiespublic void addPolicy(Context c, DSpaceObject o, int actionID, Group g) throws SQLException, AuthorizeException
AuthorizeServiceaddPolicy in interface AuthorizeServicec - current contexto - object to add policy foractionID - ID of action from org.dspace.core.Constantsg - group to add policy forSQLException - if there's a database problemAuthorizeException - if the current user is not authorized to add this policypublic void addPolicy(Context c, DSpaceObject o, int actionID, Group g, String type) throws SQLException, AuthorizeException
AuthorizeServiceaddPolicy in interface AuthorizeServicec - 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 classSQLException - if there's a database problemAuthorizeException - if the current user is not authorized to add this policypublic List<ResourcePolicy> getPolicies(Context c, DSpaceObject o) throws SQLException
AuthorizeServicegetPolicies in interface AuthorizeServicec - current contexto - object to retrieve policies forResourcePolicy objectsSQLException - if database errorpublic List<ResourcePolicy> findPoliciesByDSOAndType(Context c, DSpaceObject o, String type) throws SQLException
AuthorizeServicefindPoliciesByDSOAndType in interface AuthorizeServicec - current contexto - object to retrieve policies fortype - typeResourcePolicy objectsSQLException - if database errorpublic List<ResourcePolicy> getPoliciesForGroup(Context c, Group g) throws SQLException
AuthorizeServicegetPoliciesForGroup in interface AuthorizeServicec - current contextg - group to retrieve policies forResourcePolicy objectsSQLException - if database errorpublic List<ResourcePolicy> getPoliciesActionFilter(Context c, DSpaceObject o, int actionID) throws SQLException
AuthorizeServicegetPoliciesActionFilter in interface AuthorizeServicec - contexto - DSpaceObject policies relate toactionID - action (defined in class Constants)SQLException - if there's a database problempublic void inheritPolicies(Context c, DSpaceObject src, DSpaceObject dest) throws SQLException, AuthorizeException
AuthorizeServiceinheritPolicies in interface AuthorizeServicec - contextsrc - source of policiesdest - destination of inherited policiesSQLException - if there's a database problemAuthorizeException - if the current user is not authorized to add these policiespublic void switchPoliciesAction(Context context, DSpaceObject dso, int fromAction, int toAction) throws SQLException, AuthorizeException
AuthorizeServiceswitchPoliciesAction in interface AuthorizeServicedso - the dspace objectfromAction - the action to changetoAction - the new action to setSQLExceptionAuthorizeExceptionpublic void addPolicies(Context c, List<ResourcePolicy> policies, DSpaceObject dest) throws SQLException, AuthorizeException
AuthorizeServiceaddPolicies in interface AuthorizeServicec - DSpace contextpolicies - List of ResourcePolicy objectsdest - object to have policies addedSQLException - if there's a database problemAuthorizeException - if the current user is not authorized to add these policiespublic void removeAllPolicies(Context c, DSpaceObject o) throws SQLException, AuthorizeException
AuthorizeServiceremoveAllPolicies in interface AuthorizeServicec - DSpace contexto - object to remove policies forSQLException - if there's a database problemAuthorizeException - if authorization errorpublic void removeAllPoliciesByDSOAndTypeNotEqualsTo(Context c, DSpaceObject o, String type) throws SQLException, AuthorizeException
AuthorizeServiceremoveAllPoliciesByDSOAndTypeNotEqualsTo in interface AuthorizeServicec - DSpace contexto - object to remove policies fortype - typeSQLException - if there's a database problemAuthorizeException - if authorization errorpublic void removeAllPoliciesByDSOAndType(Context c, DSpaceObject o, String type) throws SQLException, AuthorizeException
AuthorizeServiceremoveAllPoliciesByDSOAndType in interface AuthorizeServicec - DSpace contexto - object to remove policies fortype - policy typeSQLException - if there's a database problemAuthorizeException - if authorization errorpublic void removePoliciesActionFilter(Context context, DSpaceObject dso, int actionID) throws SQLException, AuthorizeException
AuthorizeServiceremovePoliciesActionFilter in interface AuthorizeServicecontext - current contextdso - object to remove policies fromactionID - ID of action to match from
Constants, or -1=allSQLException - if there's a database problemAuthorizeException - if authorization errorpublic void removeGroupPolicies(Context c, Group group) throws SQLException
AuthorizeServiceremoveGroupPolicies in interface AuthorizeServicec - current contextgroup - the groupSQLException - if there's a database problempublic void removeGroupPolicies(Context c, DSpaceObject o, Group g) throws SQLException, AuthorizeException
AuthorizeServiceremoveGroupPolicies in interface AuthorizeServicec - current contexto - the objectg - the groupSQLException - if there's a database problemAuthorizeException - if authorization errorpublic void removeEPersonPolicies(Context c, DSpaceObject o, EPerson e) throws SQLException, AuthorizeException
AuthorizeServiceremoveEPersonPolicies in interface AuthorizeServicec - current contexto - the objecte - the epersonSQLException - if there's a database problemAuthorizeException - if authorization errorpublic List<Group> getAuthorizedGroups(Context c, DSpaceObject o, int actionID) throws SQLException
AuthorizeServicegetAuthorizedGroups in interface AuthorizeServicec - current contexto - objectactionID - ID of action from ConstantsGroups that can perform the specified
action on the specified objectSQLException - if there's a database problempublic boolean isAnIdenticalPolicyAlreadyInPlace(Context c, DSpaceObject o, ResourcePolicy rp) throws SQLException
isAnIdenticalPolicyAlreadyInPlace in interface AuthorizeServiceSQLExceptionpublic boolean isAnIdenticalPolicyAlreadyInPlace(Context c, DSpaceObject dso, Group group, int action, int policyID) throws SQLException
AuthorizeServiceisAnIdenticalPolicyAlreadyInPlace in interface AuthorizeServicec - current contextdso - objectgroup - groupaction - ID of action from ConstantspolicyID - ID of an existing policy. If -1 is specified, this parameter will be ignoredSQLException - if there's a database problempublic ResourcePolicy findByTypeIdGroupAction(Context c, DSpaceObject dso, Group group, int action, int policyID) throws SQLException
findByTypeIdGroupAction in interface AuthorizeServiceSQLExceptionpublic void generateAutomaticPolicies(Context context, Date embargoDate, String reason, DSpaceObject dso, Collection owningCollection) throws SQLException, AuthorizeException
generateAutomaticPolicies in interface AuthorizeServicecontext - embargoDate - reason - dso - owningCollection - SQLException - if database errorAuthorizeException - if authorization errorpublic ResourcePolicy createResourcePolicy(Context context, DSpaceObject dso, Group group, EPerson eperson, int type, String rpType) throws SQLException, AuthorizeException
createResourcePolicy in interface AuthorizeServiceSQLExceptionAuthorizeExceptionpublic ResourcePolicy createOrModifyPolicy(ResourcePolicy policy, Context context, String name, Group group, EPerson ePerson, Date embargoDate, int action, String reason, DSpaceObject dso) throws AuthorizeException, SQLException
createOrModifyPolicy in interface AuthorizeServiceAuthorizeExceptionSQLExceptionCopyright © 2016 DuraSpace. All rights reserved.