Package org.dspace.authorize.service
Interface AuthorizeService
- All Known Implementing Classes:
AuthorizeServiceImpl
public interface AuthorizeService
AuthorizeManager handles all authorization checks for DSpace. For better
security, DSpace assumes that you do not have the right to do something
unless that permission is spelled out somewhere. That "somewhere" is the
ResourcePolicy table. The AuthorizeManager is given a user, an object, and an
action, and it then does a lookup in the ResourcePolicy table to see if there
are any policies giving the user permission to do that action.
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, then they are automatically given permission for all requests another special group is group with name "Anonymous" - all EPeople are members of this group.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddPolicies(Context c, List<ResourcePolicy> policies, DSpaceObject dest) Copies policies from a list of resource policies to a given DSpaceObjectvoidaddPolicy(Context c, DSpaceObject o, int actionID, EPerson e) Add a policy for an individual epersonvoidaddPolicy(Context c, DSpaceObject o, int actionID, EPerson e, String type) Add a policy for an individual epersonvoidaddPolicy(Context c, DSpaceObject o, int actionID, Group g) Add a policy for a groupvoidaddPolicy(Context c, DSpaceObject o, int actionID, Group g, String type) Add a policy for a groupvoidauthorizeAction(Context c, DSpaceObject o, int action) Checks that the context's current user can perform the given action on the given object.voidauthorizeAction(Context c, DSpaceObject o, int action, boolean useInheritance) Checks that the context's current user can perform the given action on the given object.voidauthorizeAction(Context c, EPerson e, DSpaceObject o, int action, boolean useInheritance) Checks that the specified eperson can perform the given action on the given object.booleanauthorizeActionBoolean(Context c, DSpaceObject o, int a) same authorize, returns boolean for those who don't want to deal with catching exceptions.booleanauthorizeActionBoolean(Context c, DSpaceObject o, int a, boolean useInheritance) same authorize, returns boolean for those who don't want to deal with catching exceptions.booleanauthorizeActionBoolean(Context c, EPerson e, DSpaceObject o, int a, boolean useInheritance) same authorize with a specific eperson (not the current user), returns boolean for those who don't want to deal with catching exceptions.voidauthorizeAnyOf(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.longcountAdminAuthorizedCollection(Context context, String query) Counts collections for which the current user is admin, AND which match the query.longcountAdminAuthorizedCommunity(Context context, String query) Counts communities for which the current user is admin, AND which match the query.createOrModifyPolicy(ResourcePolicy policy, Context context, String name, Group group, EPerson ePerson, LocalDate embargoDate, int action, String reason, DSpaceObject dso) createResourcePolicy(Context context, DSpaceObject dso, Group group, EPerson eperson, int type, String rpType) createResourcePolicy(Context context, DSpaceObject dso, Group group, EPerson eperson, int type, String rpType, String rpName, String rpDescription, LocalDate startDate, LocalDate endDate) findAdminAuthorizedCollection(Context context, String query, int offset, int limit) Finds collections for which the current user is admin, AND which match the query.findAdminAuthorizedCommunity(Context context, String query, int offset, int limit) Finds communities for which the current user is admin, AND which match the query.findByTypeGroupAction(Context c, DSpaceObject dso, Group group, int action) findPoliciesByDSOAndType(Context c, DSpaceObject o, String type) Return a List of the policies for an objectgetAuthorizedGroups(Context c, DSpaceObject o, int actionID) Returns all groups authorized to perform an action on an object.getPolicies(Context c, DSpaceObject o) Return a List of the policies for an objectgetPoliciesActionFilter(Context c, DSpaceObject o, int actionID) Return a list of policies for an object that match the actiongetPoliciesActionFilterExceptRpType(Context c, DSpaceObject o, int actionID, String rpType) Return a list of policies for an object that match the action except the record labeled with the rpTypegetPoliciesForGroup(Context c, Group g) Return a List of the policies for a groupvoidinheritPolicies(Context c, DSpaceObject src, DSpaceObject dest) Add policies to an object to match those from a previous objectbooleanisAccountManager(Context context) Returns true if the current user can manage accounts.booleanCheck to see if the current user is a System Admin.booleanisAdmin(Context c, DSpaceObject o) Check to see if the current user is an Administrator of a given object within DSpace.booleanCheck to see if a specific user is system admin.booleanisAdmin(Context c, EPerson e, DSpaceObject o) Check to see if a specific user is an Administrator of a given object within DSpace.booleanbooleanisAnIdenticalPolicyAlreadyInPlace(Context c, DSpaceObject o, Group group, int actionID, int policyID) Is a policy with the specified parameters already in place?booleanisCollectionAdmin(Context context) Checks that the context's current user is a collection admin in the site by querying the solr database.booleanisComColAdmin(Context context) Checks that the context's current user is a community or collection admin in the site.booleanisCommunityAdmin(Context context) Checks that the context's current user is a community admin in the site by querying the solr database.booleanisItemAdmin(Context context) Checks that the context's current user is an item admin in the site by querying the solr database.voidRemoves all policies from an eperson that belong to an EPerson.voidremoves ALL policies for an object.voidremoveAllPoliciesByDSOAndType(Context c, DSpaceObject o, String type) removes policiesvoidremoves ALL policies for an object that are not of the input type.voidremoveEPersonPolicies(Context c, DSpaceObject o, EPerson e) Removes all policies from an eperson for a particular object that belong to an EPerson.voidremoveGroupPolicies(Context c, DSpaceObject o, Group g) Removes all policies from a group for a particular object that belong to a Group.voidremoveGroupPolicies(Context c, Group group) Removes all policies relating to a particular group.voidremovePoliciesActionFilter(Context context, DSpaceObject dso, int actionID) Remove all policies from an object that match a given action.voidreplaceAllPolicies(Context context, DSpaceObject source, DSpaceObject dest) Replace all the policies in the target object with exactly the same policies that exist in the source objectvoidswitchPoliciesAction(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)
-
Method Details
-
authorizeAnyOf
void authorizeAnyOf(Context c, DSpaceObject o, int[] actions) throws AuthorizeException, SQLException Utility method, checks that the current user of the given context can perform all of the specified actions on the given object. AnAuthorizeExceptionif all the authorizations fail.- Parameters:
c- context with the current usero- DSpace object user is attempting to perform action onactions- array of action IDs fromorg.dspace.core.Constants- Throws:
AuthorizeException- if any one of the specified actions cannot be performed by the current user on the given object.SQLException- An exception that provides information on a database access error or other errors.
-
authorizeAction
Checks that the context's current user can perform the given action on the given object. Throws an exception if the user is not authorized, otherwise the method call does nothing.- Parameters:
c- contexto- a DSpaceObjectaction- action to perform fromorg.dspace.core.Constants- Throws:
AuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.SQLException- An exception that provides information on a database access error or other errors.
-
authorizeAction
void authorizeAction(Context c, DSpaceObject o, int action, boolean useInheritance) throws AuthorizeException, SQLException Checks that the context's current user can perform the given action on the given object. Throws an exception if the user is not authorized, otherwise the method call does nothing.- Parameters:
c- contexto- a DSpaceObjectuseInheritance- flag to say if ADMIN action on the current object or parent object can be usedaction- action to perform fromorg.dspace.core.Constants- Throws:
AuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.SQLException- An exception that provides information on a database access error or other errors.
-
authorizeAction
void authorizeAction(Context c, EPerson e, DSpaceObject o, int action, boolean useInheritance) throws AuthorizeException, SQLException Checks that the specified eperson can perform the given action on the given object. Throws an exception if the user is not authorized, otherwise the method call does nothing.- Parameters:
c- contexte- the eperson to use for the authorization checko- a DSpaceObjectuseInheritance- flag to say if ADMIN action on the current object or parent object can be usedaction- action to perform fromorg.dspace.core.Constants- Throws:
AuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.SQLException- An exception that provides information on a database access error or other errors.
-
authorizeActionBoolean
same authorize, returns boolean for those who don't want to deal with catching exceptions.- Parameters:
c- DSpace context, containing current usero- DSpaceObjecta- action being attempted, fromorg.dspace.core.Constants- Returns:
trueif the current user in the context is authorized to perform the given action on the given object- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
authorizeActionBoolean
boolean authorizeActionBoolean(Context c, DSpaceObject o, int a, boolean useInheritance) throws SQLException same authorize, returns boolean for those who don't want to deal with catching exceptions.- Parameters:
c- DSpace context, containing current usero- DSpaceObjecta- action being attempted, fromorg.dspace.core.ConstantsuseInheritance- flag to say if ADMIN action on the current object or parent object can be used- Returns:
trueif the current user in the context is authorized to perform the given action on the given object- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
authorizeActionBoolean
boolean authorizeActionBoolean(Context c, EPerson e, DSpaceObject o, int a, boolean useInheritance) throws SQLException same authorize with a specific eperson (not the current user), returns boolean for those who don't want to deal with catching exceptions.- Parameters:
c- DSpace contexte- EPerson to use in the checko- DSpaceObjecta- action being attempted, fromorg.dspace.core.ConstantsuseInheritance- flag to say if ADMIN action on the current object or parent object can be used- Returns:
trueif the requested user is authorized to perform the given action on the given object- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
isAdmin
Check to see if the current user is an Administrator of a given object within DSpace. Always returntrueif the user is a System Admin- Parameters:
c- current contexto- current DSpace Object, ifnullthe call will be equivalent to a call to theisAdmin(Context c)method- Returns:
trueif user has administrative privileges on the given DSpace object- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
isAdmin
Check to see if a specific user is an Administrator of a given object within DSpace. Always returntrueif the user is a System Admin- Parameters:
c- current contexte- the user to checko- current DSpace Object, ifnullthe call will be equivalent to a call to theisAdmin(Context c)method- Returns:
trueif the user has administrative privileges on the given DSpace object- Throws:
SQLException- if database error
-
isAdmin
Check to see if the current user is a System Admin. Always returntrueif c.ignoreAuthorization is set. If no EPerson is logged in and context.getCurrentUser() returns null, this method returns false as anonymous users can never be administrators.- Parameters:
c- current context- Returns:
trueif user is an admin or ignore authorization flag set- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
isAdmin
Check to see if a specific user is system admin. Always returntrueif c.ignoreAuthorization is set.- Parameters:
c- current context- Returns:
trueif user is an admin or ignore authorization flag set- Throws:
SQLException- if database error
-
addPolicy
void addPolicy(Context c, DSpaceObject o, int actionID, EPerson e) throws SQLException, AuthorizeException Add a policy for an individual eperson- Parameters:
c- context. Current user irrelevanto- DSpaceObject to add policy toactionID- ID of action fromorg.dspace.core.Constantse- eperson who can perform the action- Throws:
SQLException- if database errorAuthorizeException- if current user in context is not authorized to add policies
-
addPolicy
void addPolicy(Context c, DSpaceObject o, int actionID, EPerson e, String type) throws SQLException, AuthorizeException Add a policy for an individual eperson- Parameters:
c- context. Current user irrelevanto- DSpaceObject to add policy toactionID- ID of action fromorg.dspace.core.Constantse- eperson who can perform the actiontype- policy type, default types are declared in the ResourcePolicy class- Throws:
SQLException- if database errorAuthorizeException- if current user in context is not authorized to add policies
-
addPolicy
void addPolicy(Context c, DSpaceObject o, int actionID, Group g) throws SQLException, AuthorizeException Add a policy for a group- Parameters:
c- current contexto- object to add policy foractionID- ID of action fromorg.dspace.core.Constantsg- group to add policy for- Throws:
SQLException- if there's a database problemAuthorizeException- if the current user is not authorized to add this policy
-
addPolicy
void addPolicy(Context c, DSpaceObject o, int actionID, Group g, String type) throws SQLException, AuthorizeException Add a policy for a group- Parameters:
c- current contexto- object to add policy foractionID- ID of action fromorg.dspace.core.Constantsg- group to add policy fortype- policy type, default types are declared in the ResourcePolicy class- Throws:
SQLException- if there's a database problemAuthorizeException- if the current user is not authorized to add this policy
-
getPolicies
Return a List of the policies for an object- Parameters:
c- current contexto- object to retrieve policies for- Returns:
- List of
ResourcePolicyobjects - Throws:
SQLException- if database error
-
findPoliciesByDSOAndType
List<ResourcePolicy> findPoliciesByDSOAndType(Context c, DSpaceObject o, String type) throws SQLException Return a List of the policies for an object- Parameters:
c- current contexto- object to retrieve policies fortype- type- Returns:
- List of
ResourcePolicyobjects - Throws:
SQLException- if database error
-
getPoliciesForGroup
Return a List of the policies for a group- Parameters:
c- current contextg- group to retrieve policies for- Returns:
- List of
ResourcePolicyobjects - Throws:
SQLException- if database error
-
getPoliciesActionFilter
List<ResourcePolicy> getPoliciesActionFilter(Context c, DSpaceObject o, int actionID) throws SQLException Return a list of policies for an object that match the action- Parameters:
c- contexto- DSpaceObject policies relate toactionID- action (defined in class Constants)- Returns:
- list of resource policies
- Throws:
SQLException- if there's a database problem
-
getPoliciesActionFilterExceptRpType
List<ResourcePolicy> getPoliciesActionFilterExceptRpType(Context c, DSpaceObject o, int actionID, String rpType) throws SQLException Return a list of policies for an object that match the action except the record labeled with the rpType- Parameters:
c- contexto- DSpaceObject policies relate toactionID- action (defined in class Constants)rpType- the resource policy type- Returns:
- list of resource policies
- Throws:
SQLException- if there's a database problem
-
inheritPolicies
void inheritPolicies(Context c, DSpaceObject src, DSpaceObject dest) throws SQLException, AuthorizeException Add policies to an object to match those from a previous object- Parameters:
c- contextsrc- source of policiesdest- destination of inherited policies- Throws:
SQLException- if there's a database problemAuthorizeException- if the current user is not authorized to add these policies
-
addPolicies
void addPolicies(Context c, List<ResourcePolicy> policies, DSpaceObject dest) throws SQLException, AuthorizeException Copies policies from a list of resource policies to a given DSpaceObject- Parameters:
c- DSpace contextpolicies- List of ResourcePolicy objectsdest- object to have policies added- Throws:
SQLException- if there's a database problemAuthorizeException- if the current user is not authorized to add these policies
-
removeAllPolicies
removes ALL policies for an object. FIXME doesn't check authorization- Parameters:
c- DSpace contexto- object to remove policies for- Throws:
SQLException- if there's a database problemAuthorizeException- if authorization error
-
removeAllPoliciesByDSOAndTypeNotEqualsTo
void removeAllPoliciesByDSOAndTypeNotEqualsTo(Context c, DSpaceObject o, String type) throws SQLException, AuthorizeException removes ALL policies for an object that are not of the input type.- Parameters:
c- DSpace contexto- object to remove policies fortype- type- Throws:
SQLException- if there's a database problemAuthorizeException- if authorization error
-
removeAllPoliciesByDSOAndType
void removeAllPoliciesByDSOAndType(Context c, DSpaceObject o, String type) throws SQLException, AuthorizeException removes policies- Parameters:
c- DSpace contexto- object to remove policies fortype- policy type- Throws:
SQLException- if there's a database problemAuthorizeException- if authorization error
-
removePoliciesActionFilter
void removePoliciesActionFilter(Context context, DSpaceObject dso, int actionID) throws SQLException, AuthorizeException Remove all policies from an object that match a given action. FIXME doesn't check authorization- Parameters:
context- current contextdso- object to remove policies fromactionID- ID of action to match fromConstants, or -1=all- Throws:
SQLException- if there's a database problemAuthorizeException- if authorization error
-
removeGroupPolicies
Removes all policies relating to a particular group. FIXME doesn't check authorization- Parameters:
c- current contextgroup- the group- Throws:
SQLException- if there's a database problem
-
removeGroupPolicies
void removeGroupPolicies(Context c, DSpaceObject o, Group g) throws SQLException, AuthorizeException Removes all policies from a group for a particular object that belong to a Group. FIXME doesn't check authorization- Parameters:
c- current contexto- the objectg- the group- Throws:
SQLException- if there's a database problemAuthorizeException- if authorization error
-
removeEPersonPolicies
void removeEPersonPolicies(Context c, DSpaceObject o, EPerson e) throws SQLException, AuthorizeException Removes all policies from an eperson for a particular object that belong to an EPerson. FIXME doesn't check authorization- Parameters:
c- current contexto- the objecte- the eperson- Throws:
SQLException- if there's a database problemAuthorizeException- if authorization error
-
removeAllEPersonPolicies
Removes all policies from an eperson that belong to an EPerson.- Parameters:
c- current contexte- the eperson- Throws:
SQLException- if there's a database problemAuthorizeException- if authorization error
-
getAuthorizedGroups
Returns all groups authorized to perform an action on an object. Returns empty array if no matches.- Parameters:
c- current contexto- objectactionID- ID of action fromConstants- Returns:
- array of
Groupsthat can perform the specified action on the specified object - Throws:
SQLException- if there's a database problem
-
isAnIdenticalPolicyAlreadyInPlace
boolean isAnIdenticalPolicyAlreadyInPlace(Context c, DSpaceObject o, ResourcePolicy rp) throws SQLException - Throws:
SQLException
-
isAnIdenticalPolicyAlreadyInPlace
boolean isAnIdenticalPolicyAlreadyInPlace(Context c, DSpaceObject o, Group group, int actionID, int policyID) throws SQLException Is a policy with the specified parameters already in place?- Parameters:
c- current contexto- objectgroup- groupactionID- ID of action fromConstantspolicyID- ID of an existing policy. If -1 is specified, this parameter will be ignored- Returns:
- true if such a policy exists, false otherwise
- Throws:
SQLException- if there's a database problem
-
findByTypeGroupAction
ResourcePolicy findByTypeGroupAction(Context c, DSpaceObject dso, Group group, int action) throws SQLException - Throws:
SQLException
-
createResourcePolicy
ResourcePolicy createResourcePolicy(Context context, DSpaceObject dso, Group group, EPerson eperson, int type, String rpType) throws SQLException, AuthorizeException - Throws:
SQLExceptionAuthorizeException
-
createResourcePolicy
ResourcePolicy createResourcePolicy(Context context, DSpaceObject dso, Group group, EPerson eperson, int type, String rpType, String rpName, String rpDescription, LocalDate startDate, LocalDate endDate) throws SQLException, AuthorizeException - Throws:
SQLExceptionAuthorizeException
-
createOrModifyPolicy
ResourcePolicy createOrModifyPolicy(ResourcePolicy policy, Context context, String name, Group group, EPerson ePerson, LocalDate embargoDate, int action, String reason, DSpaceObject dso) throws AuthorizeException, SQLException - Throws:
AuthorizeExceptionSQLException
-
switchPoliciesAction
void switchPoliciesAction(Context context, DSpaceObject dso, int fromAction, int toAction) throws SQLException, AuthorizeException Change all the policies related to the action (fromPolicy) of the specified object to the new action (toPolicy)- Parameters:
context- The relevant DSpace Context.dso- the dspace objectfromAction- the action to changetoAction- the new action to set- Throws:
SQLException- An exception that provides information on a database access error or other errors.AuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.
-
isCommunityAdmin
Checks that the context's current user is a community admin in the site by querying the solr database.- Parameters:
context- context with the current user- Returns:
- true if the current user is a community admin in the site false when this is not the case, or an exception occurred
- Throws:
SQLException
-
isCollectionAdmin
Checks that the context's current user is a collection admin in the site by querying the solr database.- Parameters:
context- context with the current user- Returns:
- true if the current user is a collection admin in the site false when this is not the case, or an exception occurred
- Throws:
SQLException
-
isItemAdmin
Checks that the context's current user is an item admin in the site by querying the solr database.- Parameters:
context- context with the current user- Returns:
- true if the current user is an item admin in the site false when this is not the case, or an exception occurred
- Throws:
SQLException
-
isComColAdmin
Checks that the context's current user is a community or collection admin in the site.- Parameters:
context- context with the current user- Returns:
- true if the current user is a community or collection admin in the site false when this is not the case, or an exception occurred
- Throws:
SQLException
-
findAdminAuthorizedCommunity
List<Community> findAdminAuthorizedCommunity(Context context, String query, int offset, int limit) throws SearchServiceException, SQLException Finds communities for which the current user is admin, AND which match the query.- Parameters:
context- context with the current userquery- the query for which to filter the results moreoffset- used for pagination of the resultslimit- used for pagination of the results- Returns:
- the number of matching communities
- Throws:
SearchServiceExceptionSQLException
-
countAdminAuthorizedCommunity
long countAdminAuthorizedCommunity(Context context, String query) throws SearchServiceException, SQLException Counts communities for which the current user is admin, AND which match the query.- Parameters:
context- context with the current userquery- the query for which to filter the results more- Returns:
- the matching communities
- Throws:
SearchServiceExceptionSQLException
-
findAdminAuthorizedCollection
List<Collection> findAdminAuthorizedCollection(Context context, String query, int offset, int limit) throws SearchServiceException, SQLException Finds collections for which the current user is admin, AND which match the query.- Parameters:
context- context with the current userquery- the query for which to filter the results moreoffset- used for pagination of the resultslimit- used for pagination of the results- Returns:
- the matching collections
- Throws:
SearchServiceExceptionSQLException
-
countAdminAuthorizedCollection
long countAdminAuthorizedCollection(Context context, String query) throws SearchServiceException, SQLException Counts collections for which the current user is admin, AND which match the query.- Parameters:
context- context with the current userquery- the query for which to filter the results more- Returns:
- the number of matching collections
- Throws:
SearchServiceExceptionSQLException
-
isAccountManager
Returns true if the current user can manage accounts.- Parameters:
context- context with the current user- Returns:
- true if the current user can manage accounts
-
replaceAllPolicies
void replaceAllPolicies(Context context, DSpaceObject source, DSpaceObject dest) throws SQLException, AuthorizeException Replace all the policies in the target object with exactly the same policies that exist in the source object- Parameters:
context- DSpace Contextsource- source of policiesdest- destination of inherited policies- Throws:
SQLException- if there's a database problemAuthorizeException- if the current user is not authorized to add these policies
-