Interface SecurityService
- All Known Implementing Classes:
SecurityServiceImpl
public interface SecurityService
High-level methods for security-related manipulations.
- Version:
- $Id: SecurityService.java,v 1.98 2013/09/14 16:56:03 paul Exp $
- Author:
- paul
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddUserToGroup(String userName, String groupName) Add a given user to a group by name.arePrivate(Collection<T> securables) Check if the given securables are private.arePublic(Collection<T> securables) Check if the given securables are public.areShared(Collection<T> securables) Check if the given securable are shared.<T extends Securable>
Collection<T> choosePrivate(Collection<T> securables) Pick private securables.<T extends Securable>
Collection<T> choosePublic(Collection<T> securables) Pick public securables.voidcreateGroup(String groupName) If the group already exists, an exception will be thrown.Retrieve a list of users allowed to edit a given securable.intObtain the number of authenticated users.Collection<org.springframework.security.acls.model.Sid> Obtain a collection of all availble security IDs (basically, user names and group authorities).getGroupAuthoritiesNameFromGroupName(String groupName) <T extends Securable>
Map<T, Collection<String>> getGroupsEditableBy(Collection<T> securables) <T extends Securable>
Map<T, Collection<String>> getGroupsReadableBy(Collection<T> securables) Obtain all the groups whose members can read a given object.getGroupsUserCanEdit(String userName) Obtain all the groups that the user can edit.org.springframework.security.acls.model.SidObtain the owner of a given object.getOwners(Collection<T> securables) Obtain the owners of a collection of objects.booleanDetermine if the current user can edit the securable.booleanisEditableByGroup(Securable s, String groupName) Determine if the given group is allowed to edit an object.booleanisEditableByUser(Securable s, String userName) Determine if the given user is allowed to edit an object.booleanbooleanDetermine if a securable is private (i.e.booleanDetermine if a securable is public (i.e.booleanDetermine if the current user can read an object.booleanisReadableByGroup(Securable s, String groupName) Determine if members of a group is allowed to read an object.booleanisReadableByUser(Securable s, String userName) booleanDetermine if a securable is shared (i.e.voidmakeEditableByGroup(Securable s, String groupName) Adds write (and read) permissions.voidmakeOwnedByUser(Securable s, String userName) Administrative method to allow a user to get access to an object.voidmakePrivate(Collection<? extends Securable> objs) Make a collection of objects private.voidmakePrivate(Securable object) Makes the object private.voidmakePublic(Collection<? extends Securable> objs) Make a collection of objects public.voidmakePublic(Securable object) Makes the object publicvoidmakeReadableByGroup(Securable s, String groupName) Adds read permission for a given group.voidmakeUneditableByGroup(Securable s, String groupName) Remove write permissions.voidmakeUnreadableByGroup(Securable s, String groupName) Remove read permissions; also removes write permissions.voidremoveUserFromGroup(String userName, String groupName) Remove a user from a group.voidChange the 'owner' of an object to a specific user.
-
Method Details
-
arePublic
Check if the given securables are public. -
arePrivate
Check if the given securables are private.- Throws:
org.springframework.security.access.AuthorizationServiceException- if the collection is empty, see comments inAclCollectionEntryVoter
-
choosePublic
Pick public securables.- Returns:
- the subset that are public, if any
-
choosePrivate
Pick private securables.- Returns:
- the subset which are private, if any
-
readableBy
- Returns:
- list of userNames of users who can read the given securable.
-
editableBy
Retrieve a list of users allowed to edit a given securable.- Returns:
- list of userNames who can edit the given securable.
- Throws:
org.springframework.security.access.AuthorizationServiceException- if the collection is empty, see comments inAclCollectionEntryVoter
-
getAuthenticatedUserCount
int getAuthenticatedUserCount()Obtain the number of authenticated users.We make this available to anonymous
-
getAuthenticatedUserNames
- Returns:
- user names
-
getAvailableSids
Obtain a collection of all availble security IDs (basically, user names and group authorities).This methods is only available to administrators.
-
getGroupAuthoritiesNameFromGroupName
-
getGroupsEditableBy
@Secured("ACL_SECURABLE_COLLECTION_READ") <T extends Securable> Map<T, Collection<String>> getGroupsEditableBy(Collection<T> securables) - Throws:
org.springframework.security.access.AuthorizationServiceException- if the collection is empty, see comments inAclCollectionEntryVoter
-
getGroupsEditableBy
-
getGroupsReadableBy
@Secured("ACL_SECURABLE_COLLECTION_READ") <T extends Securable> Map<T, Collection<String>> getGroupsReadableBy(Collection<T> securables) -
getGroupsReadableBy
Obtain all the groups whose members can read a given object. -
getGroupsUserCanEdit
Obtain all the groups that the user can edit. -
getOwner
Obtain the owner of a given object. -
getOwners
<T extends Securable> Map<T, org.springframework.security.acls.model.Sid> getOwners(Collection<T> securables) Obtain the owners of a collection of objects.Pretty much have to be either the owner of the securables or administrator to call this.
- Throws:
org.springframework.security.access.AccessDeniedException- if the current user is not allowed to access the information.
-
isPublic
Determine if a securable is public (i.e. can be seen by anyone, including anonymous users).- See Also:
-
isPrivate
Determine if a securable is private (i.e. can only be seen by its owner or an administrator).- Returns:
- true if anonymous users can view (READ) the object, false otherwise. If the object doesn't have an ACL, return true (be safe!)
- See Also:
-
isOwnedByCurrentUser
- Returns:
- true if the owner is the same as the current authenticated user. Special case: if the owner is an administrator, and the uc
-
isReadableByCurrentUser
Determine if the current user can read an object. -
isReadableByUser
-
isReadableByGroup
-
isEditableByCurrentUser
Determine if the current user can edit the securable. -
isEditableByUser
-
isEditableByGroup
-
makePublic
Make a collection of objects public. -
makePublic
Makes the object public -
makePrivate
Make a collection of objects private. -
makePrivate
Makes the object private. -
makeReadableByGroup
-
makeUnreadableByGroup
-
makeUneditableByGroup
-
makeEditableByGroup
-
makeOwnedByUser
Administrative method to allow a user to get access to an object. This is useful for cases where a data set is loaded by admin but we need to hand it off to a user. If the user is the same as the current owner nothing is done.TODO: consider allowing a groupauthority to be the owner (GROUP_ADMIN) - see bug 2996
-
setOwner
-
createGroup
If the group already exists, an exception will be thrown. -
addUserToGroup
-
removeUserFromGroup
-