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 Details

    • arePublic

      <T extends Securable> Map<T,Boolean> arePublic(Collection<T> securables)
      Check if the given securables are public.
    • arePrivate

      <T extends Securable> Map<T,Boolean> arePrivate(Collection<T> securables)
      Check if the given securables are private.
      Throws:
      org.springframework.security.access.AuthorizationServiceException - if the collection is empty, see comments in AclCollectionEntryVoter
    • areShared

      <T extends Securable> Map<T,Boolean> areShared(Collection<T> securables)
      Check if the given securable are shared.
      Throws:
      org.springframework.security.access.AuthorizationServiceException - if the collection is empty, see comments in AclCollectionEntryVoter
    • choosePublic

      <T extends Securable> Collection<T> choosePublic(Collection<T> securables)
      Pick public securables.
      Returns:
      the subset that are public, if any
    • choosePrivate

      <T extends Securable> Collection<T> choosePrivate(Collection<T> securables)
      Pick private securables.
      Returns:
      the subset which are private, if any
    • readableBy

      Collection<String> readableBy(Securable s)
      Returns:
      list of userNames of users who can read the given securable.
    • editableBy

      Collection<String> editableBy(Securable s)
      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 in AclCollectionEntryVoter
    • getAuthenticatedUserCount

      int getAuthenticatedUserCount()
      Obtain the number of authenticated users.

      We make this available to anonymous

    • getAuthenticatedUserNames

      @Secured("GROUP_ADMIN") Collection<String> getAuthenticatedUserNames()
      Returns:
      user names
    • getAvailableSids

      @Secured("GROUP_ADMIN") Collection<org.springframework.security.acls.model.Sid> getAvailableSids()
      Obtain a collection of all availble security IDs (basically, user names and group authorities).

      This methods is only available to administrators.

    • getGroupAuthoritiesNameFromGroupName

      List<String> getGroupAuthoritiesNameFromGroupName(String groupName)
    • 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 in AclCollectionEntryVoter
    • getGroupsEditableBy

      @Secured("ACL_SECURABLE_READ") Collection<String> getGroupsEditableBy(Securable s)
    • getGroupsReadableBy

      @Secured("ACL_SECURABLE_COLLECTION_READ") <T extends Securable> Map<T, Collection<String>> getGroupsReadableBy(Collection<T> securables)
    • getGroupsReadableBy

      Collection<String> getGroupsReadableBy(Securable s)
      Obtain all the groups whose members can read a given object.
    • getGroupsUserCanEdit

      Collection<String> getGroupsUserCanEdit(String userName)
      Obtain all the groups that the user can edit.
    • getOwner

      org.springframework.security.acls.model.Sid getOwner(Securable s)
      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

      boolean isPublic(Securable s)
      Determine if a securable is public (i.e. can be seen by anyone, including anonymous users).
      See Also:
    • isShared

      boolean isShared(Securable s)
      Determine if a securable is shared (i.e. can be seen by any registered users).
      See Also:
    • isPrivate

      boolean isPrivate(Securable s)
      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

      boolean isOwnedByCurrentUser(Securable s)
      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

      boolean isReadableByCurrentUser(Securable s)
      Determine if the current user can read an object.
    • isReadableByUser

      boolean isReadableByUser(Securable s, String userName)
      Returns:
      true if the given user can read the securable, false otherwise. (READ or ADMINISTRATION required)
    • isReadableByGroup

      boolean isReadableByGroup(Securable s, String groupName)
      Determine if members of a group is allowed to read an object.
    • isEditableByCurrentUser

      boolean isEditableByCurrentUser(Securable s)
      Determine if the current user can edit the securable.
    • isEditableByUser

      boolean isEditableByUser(Securable s, String userName)
      Determine if the given user is allowed to edit an object.
    • isEditableByGroup

      boolean isEditableByGroup(Securable s, String groupName)
      Determine if the given group is allowed to edit an object.
    • makePublic

      @Secured("ACL_SECURABLE_COLLECTION_EDIT") void makePublic(Collection<? extends Securable> objs)
      Make a collection of objects public.
    • makePublic

      @Secured("ACL_SECURABLE_EDIT") void makePublic(Securable object)
      Makes the object public
    • makePrivate

      @Secured("ACL_SECURABLE_COLLECTION_EDIT") void makePrivate(Collection<? extends Securable> objs)
      Make a collection of objects private.
    • makePrivate

      @Secured("ACL_SECURABLE_EDIT") void makePrivate(Securable object)
      Makes the object private.
    • makeReadableByGroup

      @Secured("ACL_SECURABLE_EDIT") void makeReadableByGroup(Securable s, String groupName) throws org.springframework.security.access.AccessDeniedException
      Adds read permission for a given group.
      Throws:
      org.springframework.security.access.AccessDeniedException
    • makeUnreadableByGroup

      @Secured("ACL_SECURABLE_EDIT") void makeUnreadableByGroup(Securable s, String groupName) throws org.springframework.security.access.AccessDeniedException
      Remove read permissions; also removes write permissions.
      Throws:
      org.springframework.security.access.AccessDeniedException
    • makeUneditableByGroup

      @Secured("ACL_SECURABLE_EDIT") void makeUneditableByGroup(Securable s, String groupName) throws org.springframework.security.access.AccessDeniedException
      Remove write permissions. Leaves read permissions, if present.
      Throws:
      org.springframework.security.access.AccessDeniedException
    • makeEditableByGroup

      @Secured("ACL_SECURABLE_EDIT") void makeEditableByGroup(Securable s, String groupName) throws org.springframework.security.access.AccessDeniedException
      Adds write (and read) permissions.
      Throws:
      org.springframework.security.access.AccessDeniedException
    • makeOwnedByUser

      @Secured("GROUP_ADMIN") void makeOwnedByUser(Securable s, String userName)
      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

      @Secured("GROUP_ADMIN") void setOwner(Securable s, String userName)
      Change the 'owner' of an object to a specific user. Note that this doesn't support making the owner a grantedAuthority.
    • createGroup

      void createGroup(String groupName)
      If the group already exists, an exception will be thrown.
    • addUserToGroup

      void addUserToGroup(String userName, String groupName)
      Add a given user to a group by name.
    • removeUserFromGroup

      void removeUserFromGroup(String userName, String groupName)
      Remove a user from a group.