Interface UserUtil

All Known Implementing Classes:
UserUtilImpl

@PublicApi public interface UserUtil
This is a back end service level interface that defines an API for user level operations.

In general, appropriate managers or services should be used in preference to this class, as it will be removed in some future revision of JIRA.

See Also:
  • Field Details

  • Method Details

    • removeUser

      void removeUser(ApplicationUser loggedInUser, ApplicationUser user)
      This will remove the user and removes the user from all the groups. All components lead by user will have lead cleared.
      Parameters:
      loggedInUser - the user performing operation
      user - the user to delete
    • addUserToGroup

      void addUserToGroup(com.atlassian.crowd.embedded.api.Group group, ApplicationUser userToAdd) throws PermissionException, AddException
      This is used to add a specified user to a specified group. The user will be added to the group if the user is not already a member of the group.
      Parameters:
      group - the group to add the user to.
      userToAdd - the user to add to the group.
      Throws:
      PermissionException
      AddException
    • addUserToGroups

      void addUserToGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups, ApplicationUser userToAdd) throws PermissionException, AddException
      This is used to add a user to many groups at once.
      Parameters:
      groups - a list containing the groups to add the user to.
      userToAdd - the user to add to the group.
      Throws:
      PermissionException
      AddException
    • removeUserFromGroup

      void removeUserFromGroup(com.atlassian.crowd.embedded.api.Group group, ApplicationUser userToRemove) throws PermissionException, RemoveException
      This is used to remove a specified user from a specified group. The user will be removed from the group only if the user is already a member of the group.
      Parameters:
      group - the group to add the user to.
      userToRemove - the user to add to the group.
      Throws:
      PermissionException
      RemoveException
    • removeUserFromGroups

      void removeUserFromGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups, ApplicationUser userToRemove) throws PermissionException, RemoveException
      This is used to remove a user from many groups at once.
      Parameters:
      groups - a list containing the groups to add the user to.
      userToRemove - the user to add to the group.
      Throws:
      PermissionException
      RemoveException
    • generatePasswordResetToken

      UserUtil.PasswordResetToken generatePasswordResetToken(ApplicationUser user)
      This is used to generate a reset password token that last a certain time and allows a person to access a page anonymously so they can reset their password.

      The generated token will be associated with the named user so that that this information can be verified at a later time.

      Parameters:
      user - the user in question. This MUST not be null
      Returns:
      a newly generated token that will live for a certain time
    • validatePasswordResetToken

      UserUtil.PasswordResetTokenValidation validatePasswordResetToken(ApplicationUser user, String token)
      This can be called to validate a token against the user.
      Parameters:
      user - the user in play
      token - the token they provided
      Returns:
      a Validation object that describes how the option went
    • changePassword

      void changePassword(ApplicationUser user, String newPassword) throws com.atlassian.crowd.exception.UserNotFoundException, com.atlassian.crowd.exception.InvalidCredentialException, com.atlassian.crowd.exception.OperationNotPermittedException, PermissionException
      Can be called to set the password for a user. This will delete any password request tokens associated with that user
      Parameters:
      user - the user in play
      newPassword - their new password
      Throws:
      com.atlassian.crowd.exception.UserNotFoundException - if the user does not exist
      com.atlassian.crowd.exception.InvalidCredentialException - if the password is invalid
      com.atlassian.crowd.exception.OperationNotPermittedException - if the underlying User Directory is read-only
      PermissionException
    • userExists

      boolean userExists(String userName)
      Returns true if the a user exists with the specified userName
      Parameters:
      userName - the name of the user
      Returns:
      true if t a user exists with the specified name or false if not
    • getJiraAdministrators

      Collection<ApplicationUser> getJiraAdministrators()
      Returns a list of JIRA admin Users.

      WARNING: This method will be changed in the future to return a Collection of Crowd User objects. Since v4.3.

      Returns:
      a list of JIRA admin Users.
      Since:
      v4.3
    • getJiraSystemAdministrators

      Collection<ApplicationUser> getJiraSystemAdministrators()
      Returns a list of JIRA system admin Users.

      WARNING: This method will be changed in the future to return a Collection of Crowd User objects. Since v4.3.

      Returns:
      a collection of User's that are associated with the Permissions.SYSTEM_ADMIN permission.
      Since:
      v4.3
    • getComponentsUserLeads

      Collection<ProjectComponent> getComponentsUserLeads(ApplicationUser user)
      Retrieve a collection of ProjectComponents - where the lead of each component is the specified user.
      Parameters:
      user - User leading components
      Returns:
      Collection of project components
    • getProjectsLeadBy

      Collection<Project> getProjectsLeadBy(ApplicationUser user)
      Returns all the projects that leadUser is the project lead for.
      Parameters:
      user - the user in play
      Returns:
      A collection of project GenericValues
    • isNonSysAdminAttemptingToDeleteSysAdmin

      boolean isNonSysAdminAttemptingToDeleteSysAdmin(ApplicationUser loggedInUser, ApplicationUser user)
      Checking if user without SYSTEM_ADMIN rights tries to remove user with SYSTEM_ADMIN rights.
      Parameters:
      loggedInUser - User performing operation
      user - User for remove
      Returns:
      true if user without SYSTEM_ADMIN rights tries to remove user with SYSTEM_ADMIN rights
    • getNumberOfReportedIssuesIgnoreSecurity

      long getNumberOfReportedIssuesIgnoreSecurity(ApplicationUser loggedInUser, ApplicationUser user) throws SearchException
      Returns number of issues reported by user
      Parameters:
      loggedInUser - the logged in user
      user - the user to find the issue count for
      Returns:
      number of issues reported by user
      Throws:
      SearchException - if something goes wrong
    • getNumberOfAssignedIssuesIgnoreSecurity

      long getNumberOfAssignedIssuesIgnoreSecurity(ApplicationUser loggedInUser, ApplicationUser user) throws SearchException
      Returns number of issues assigned to user
      Parameters:
      loggedInUser - the logged in user
      user - the user to find the issue count for
      Returns:
      number of issues assigned to user
      Throws:
      SearchException - if something goes wrong
    • getDisplayableNameSafely

      String getDisplayableNameSafely(ApplicationUser user)
      Takes the given user and returns a "displayable name" by cautiously checking the different edge cases for users.
      Parameters:
      user - the user. May be null.
      Returns:
      The user's full name if present and not blank, the username if present, or null otherwise.
    • getGroupsForUser

      SortedSet<com.atlassian.crowd.embedded.api.Group> getGroupsForUser(String userName)
      Returns a collection of Group objects that the user belongs to.
      Parameters:
      userName - A User name
      Returns:
      the set of groups that the user belongs to
      Since:
      v4.3
    • getGroupNamesForUser

      SortedSet<String> getGroupNamesForUser(String userName)
      Returns a collection of the names of the groups that the user belongs to.
      Parameters:
      userName - A User name
      Returns:
      the set of groups that the user belongs to
      Since:
      v4.3
    • getAllUsersInGroupNames

      SortedSet<ApplicationUser> getAllUsersInGroupNames(Collection<String> groupNames)
      Returns a collection of User objects that belong to any of the passed in collection of group names. Prefer using getAllUsersInGroupNamesUnsorted(java.util.Collection) and sorting the list of users only if absolutely necessary rather than relying on this method to perform the sort.
      Parameters:
      groupNames - a collection of group name strings
      Returns:
      the set of users that are in the named groups, sorted in UserCachingComparator order
    • getAllUsersInGroupNamesUnsorted

      Set<ApplicationUser> getAllUsersInGroupNamesUnsorted(Collection<String> groupNames)
      Returns a collection of User objects that belong to any of the passed in collection of group names.
      Parameters:
      groupNames - a collection of group name strings
      Returns:
      the set of users that are in the named groups
      Since:
      5.1
    • getAllUsersInGroups

      SortedSet<ApplicationUser> getAllUsersInGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups)
      Returns a collection of User objects that are found within the passed in collection of Group objects.
      Parameters:
      groups - a collection of Group objects
      Returns:
      the set of users that are in the groups, sorted in UserCachingComparator order