Class SecurityServiceImpl
java.lang.Object
ubic.gemma.core.security.SecurityServiceImpl
- All Implemented Interfaces:
SecurityService
Methods for changing security on objects, creating and modifying groups, checking security on objects.
We removed the ACL filtering/checking from most of these methods, because it results in basically checking permissions inside of methods that are checking permissions etc. We assume that anybody with read access on an object can know something about its security state.
- Version:
- $Id: SecurityServiceImpl.java,v 1.28 2013/12/12 00:10:12 paul Exp $
- Author:
- keshav, paul
-
Constructor Summary
ConstructorsConstructorDescriptionSecurityServiceImpl(AclService aclService, org.springframework.security.core.session.SessionRegistry sessionRegistry, org.springframework.security.acls.model.ObjectIdentityRetrievalStrategy objectIdentityRetrievalStrategy, org.springframework.security.acls.model.SidRetrievalStrategy sidRetrievalStrategy, UserDetailsManager userDetailsManager, GroupManager groupManager, BaseUserService userService) -
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) From the group name get the authority which should be underscored with GROUP_<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.
-
Constructor Details
-
SecurityServiceImpl
public SecurityServiceImpl(AclService aclService, org.springframework.security.core.session.SessionRegistry sessionRegistry, org.springframework.security.acls.model.ObjectIdentityRetrievalStrategy objectIdentityRetrievalStrategy, org.springframework.security.acls.model.SidRetrievalStrategy sidRetrievalStrategy, UserDetailsManager userDetailsManager, GroupManager groupManager, BaseUserService userService)
-
-
Method Details
-
arePublic
@Transactional(readOnly=true) public <T extends Securable> Map<T,Boolean> arePublic(Collection<T> securables) Description copied from interface:SecurityServiceCheck if the given securables are public.- Specified by:
arePublicin interfaceSecurityService
-
arePrivate
@Transactional(readOnly=true) public <T extends Securable> Map<T,Boolean> arePrivate(Collection<T> securables) Description copied from interface:SecurityServiceCheck if the given securables are private.- Specified by:
arePrivatein interfaceSecurityService
-
choosePrivate
@Transactional(readOnly=true) public <T extends Securable> Collection<T> choosePrivate(Collection<T> securables) Description copied from interface:SecurityServicePick private securables.- Specified by:
choosePrivatein interfaceSecurityService- Returns:
- the subset which are private, if any
-
choosePublic
@Transactional(readOnly=true) public <T extends Securable> Collection<T> choosePublic(Collection<T> securables) Description copied from interface:SecurityServicePick public securables.- Specified by:
choosePublicin interfaceSecurityService- Returns:
- the subset that are public, if any
-
readableBy
- Specified by:
readableByin interfaceSecurityService- Returns:
- list of userNames of users who can read the given securable.
-
editableBy
Description copied from interface:SecurityServiceRetrieve a list of users allowed to edit a given securable.- Specified by:
editableByin interfaceSecurityService- Returns:
- list of userNames who can edit the given securable.
-
getAuthenticatedUserCount
public int getAuthenticatedUserCount()Description copied from interface:SecurityServiceObtain the number of authenticated users.We make this available to anonymous
- Specified by:
getAuthenticatedUserCountin interfaceSecurityService
-
getAuthenticatedUserNames
- Specified by:
getAuthenticatedUserNamesin interfaceSecurityService- Returns:
- user names
-
getAvailableSids
@Transactional(readOnly=true) public Collection<org.springframework.security.acls.model.Sid> getAvailableSids()Description copied from interface:SecurityServiceObtain a collection of all availble security IDs (basically, user names and group authorities).This methods is only available to administrators.
- Specified by:
getAvailableSidsin interfaceSecurityService
-
getGroupAuthoritiesNameFromGroupName
@Transactional(readOnly=true) public List<String> getGroupAuthoritiesNameFromGroupName(String groupName) From the group name get the authority which should be underscored with GROUP_- Specified by:
getGroupAuthoritiesNameFromGroupNamein interfaceSecurityService- Parameters:
groupName- The group name e.g. fish- Returns:
- The authority e.g. GROUP_FISH_...
-
getGroupsEditableBy
@Transactional(readOnly=true) public <T extends Securable> Map<T, Collection<String>> getGroupsEditableBy(Collection<T> securables) - Specified by:
getGroupsEditableByin interfaceSecurityService
-
getGroupsEditableBy
- Specified by:
getGroupsEditableByin interfaceSecurityService
-
getGroupsReadableBy
@Transactional(readOnly=true) public <T extends Securable> Map<T, Collection<String>> getGroupsReadableBy(Collection<T> securables) - Specified by:
getGroupsReadableByin interfaceSecurityService
-
getGroupsReadableBy
Description copied from interface:SecurityServiceObtain all the groups whose members can read a given object.- Specified by:
getGroupsReadableByin interfaceSecurityService
-
getGroupsUserCanEdit
Description copied from interface:SecurityServiceObtain all the groups that the user can edit.- Specified by:
getGroupsUserCanEditin interfaceSecurityService
-
getOwner
@Transactional(readOnly=true) public org.springframework.security.acls.model.Sid getOwner(Securable s) Description copied from interface:SecurityServiceObtain the owner of a given object.- Specified by:
getOwnerin interfaceSecurityService
-
getOwners
@Transactional(readOnly=true) public <T extends Securable> Map<T, org.springframework.security.acls.model.Sid> getOwners(Collection<T> securables) Description copied from interface:SecurityServiceObtain the owners of a collection of objects.Pretty much have to be either the owner of the securables or administrator to call this.
- Specified by:
getOwnersin interfaceSecurityService
-
isOwnedByCurrentUser
- Specified by:
isOwnedByCurrentUserin interfaceSecurityService- 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
Description copied from interface:SecurityServiceDetermine if the current user can read an object.- Specified by:
isReadableByCurrentUserin interfaceSecurityService
-
isReadableByUser
- Specified by:
isReadableByUserin interfaceSecurityService- Returns:
- true if the given user can read the securable, false otherwise. (READ or ADMINISTRATION required)
-
isReadableByGroup
Description copied from interface:SecurityServiceDetermine if members of a group is allowed to read an object.- Specified by:
isReadableByGroupin interfaceSecurityService
-
isEditableByCurrentUser
Description copied from interface:SecurityServiceDetermine if the current user can edit the securable.- Specified by:
isEditableByCurrentUserin interfaceSecurityService
-
isEditableByUser
Description copied from interface:SecurityServiceDetermine if the given user is allowed to edit an object.- Specified by:
isEditableByUserin interfaceSecurityService
-
isEditableByGroup
Description copied from interface:SecurityServiceDetermine if the given group is allowed to edit an object.- Specified by:
isEditableByGroupin interfaceSecurityService
-
isPublic
Description copied from interface:SecurityServiceDetermine if a securable is public (i.e. can be seen by anyone, including anonymous users).- Specified by:
isPublicin interfaceSecurityService- See Also:
-
isPrivate
Description copied from interface:SecurityServiceDetermine if a securable is private (i.e. can only be seen by its owner or an administrator).- Specified by:
isPrivatein interfaceSecurityService- 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:
-
makeOwnedByUser
Description copied from interface:SecurityServiceAdministrative 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
- Specified by:
makeOwnedByUserin interfaceSecurityService
-
makePrivate
Description copied from interface:SecurityServiceMake a collection of objects private.- Specified by:
makePrivatein interfaceSecurityService
-
makePrivate
Description copied from interface:SecurityServiceMakes the object private.- Specified by:
makePrivatein interfaceSecurityService
-
makePublic
Description copied from interface:SecurityServiceMake a collection of objects public.- Specified by:
makePublicin interfaceSecurityService
-
makePublic
Description copied from interface:SecurityServiceMakes the object public- Specified by:
makePublicin interfaceSecurityService
-
makeReadableByGroup
@Transactional public void makeReadableByGroup(Securable s, String groupName) throws org.springframework.security.access.AccessDeniedException Description copied from interface:SecurityServiceAdds read permission for a given group.- Specified by:
makeReadableByGroupin interfaceSecurityService- Throws:
org.springframework.security.access.AccessDeniedException
-
makeUnreadableByGroup
@Transactional public void makeUnreadableByGroup(Securable s, String groupName) throws org.springframework.security.access.AccessDeniedException Description copied from interface:SecurityServiceRemove read permissions; also removes write permissions.- Specified by:
makeUnreadableByGroupin interfaceSecurityService- Throws:
org.springframework.security.access.AccessDeniedException
-
makeUneditableByGroup
@Transactional public void makeUneditableByGroup(Securable s, String groupName) throws org.springframework.security.access.AccessDeniedException Description copied from interface:SecurityServiceRemove write permissions. Leaves read permissions, if present.- Specified by:
makeUneditableByGroupin interfaceSecurityService- Throws:
org.springframework.security.access.AccessDeniedException
-
makeEditableByGroup
@Transactional public void makeEditableByGroup(Securable s, String groupName) throws org.springframework.security.access.AccessDeniedException Description copied from interface:SecurityServiceAdds write (and read) permissions.- Specified by:
makeEditableByGroupin interfaceSecurityService- Throws:
org.springframework.security.access.AccessDeniedException
-
setOwner
Description copied from interface:SecurityServiceChange the 'owner' of an object to a specific user. Note that this doesn't support making the owner a grantedAuthority.- Specified by:
setOwnerin interfaceSecurityService
-
createGroup
Description copied from interface:SecurityServiceIf the group already exists, an exception will be thrown.- Specified by:
createGroupin interfaceSecurityService
-
addUserToGroup
Description copied from interface:SecurityServiceAdd a given user to a group by name.- Specified by:
addUserToGroupin interfaceSecurityService
-
removeUserFromGroup
Description copied from interface:SecurityServiceRemove a user from a group.- Specified by:
removeUserFromGroupin interfaceSecurityService
-