Package com.atlassian.jira.user.util
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:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic interface -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidaddUserToGroup(com.atlassian.crowd.embedded.api.Group group, ApplicationUser userToAdd) This is used to add a specified user to a specified group.voidaddUserToGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups, ApplicationUser userToAdd) This is used to add a user to many groups at once.voidchangePassword(ApplicationUser user, String newPassword) Can be called to set the password for a 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.getAllUsersInGroupNames(Collection<String> groupNames) Returns a collection ofUserobjects that belong to any of the passed in collection of group names.getAllUsersInGroupNamesUnsorted(Collection<String> groupNames) Returns a collection ofUserobjects that belong to any of the passed in collection of group names.getAllUsersInGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups) Returns a collection ofUserobjects that are found within the passed in collection ofGroupobjects.Retrieve a collection of ProjectComponents - where the lead of each component is the specified user.Takes the given user and returns a "displayable name" by cautiously checking the different edge cases for users.getGroupNamesForUser(String userName) Returns a collection of the names of the groups that the user belongs to.SortedSet<com.atlassian.crowd.embedded.api.Group>getGroupsForUser(String userName) Returns a collection ofGroupobjects that the user belongs to.Returns a list of JIRA adminUsers.Returns a list of JIRA system adminUsers.longgetNumberOfAssignedIssuesIgnoreSecurity(ApplicationUser loggedInUser, ApplicationUser user) Returns number of issues assigned to userlonggetNumberOfReportedIssuesIgnoreSecurity(ApplicationUser loggedInUser, ApplicationUser user) Returns number of issues reported by userReturns all the projects that leadUser is the project lead for.booleanisNonSysAdminAttemptingToDeleteSysAdmin(ApplicationUser loggedInUser, ApplicationUser user) Checking if user without SYSTEM_ADMIN rights tries to remove user with SYSTEM_ADMIN rights.voidremoveUser(ApplicationUser loggedInUser, ApplicationUser user) This will remove the user and removes the user from all the groups.voidremoveUserFromGroup(com.atlassian.crowd.embedded.api.Group group, ApplicationUser userToRemove) This is used to remove a specified user from a specified group.voidremoveUserFromGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups, ApplicationUser userToRemove) This is used to remove a user from many groups at once.booleanuserExists(String userName) Returns true if the a user exists with the specified userNamevalidatePasswordResetToken(ApplicationUser user, String token) This can be called to validate a token against the user.
-
Field Details
-
META_PROPERTY_PREFIX
- See Also:
-
-
Method Details
-
removeUser
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 operationuser- 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:
PermissionExceptionAddException
-
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:
PermissionExceptionAddException
-
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:
PermissionExceptionRemoveException
-
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:
PermissionExceptionRemoveException
-
generatePasswordResetToken
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 playtoken- 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 playnewPassword- their new password- Throws:
com.atlassian.crowd.exception.UserNotFoundException- if the user does not existcom.atlassian.crowd.exception.InvalidCredentialException- if the password is invalidcom.atlassian.crowd.exception.OperationNotPermittedException- if the underlying User Directory is read-onlyPermissionException
-
userExists
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 adminUsers.WARNING: This method will be changed in the future to return a Collection of Crowd
Userobjects. Since v4.3.- Returns:
- a list of JIRA admin
Users. - Since:
- v4.3
-
getJiraSystemAdministrators
Collection<ApplicationUser> getJiraSystemAdministrators()Returns a list of JIRA system adminUsers.WARNING: This method will be changed in the future to return a Collection of Crowd
Userobjects. Since v4.3.- Returns:
- a collection of
User's that are associated with thePermissions.SYSTEM_ADMINpermission. - Since:
- v4.3
-
getComponentsUserLeads
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
Returns all the projects that leadUser is the project lead for.- Parameters:
user- the user in play- Returns:
- A collection of project
GenericValues
-
isNonSysAdminAttemptingToDeleteSysAdmin
Checking if user without SYSTEM_ADMIN rights tries to remove user with SYSTEM_ADMIN rights.- Parameters:
loggedInUser- User performing operationuser- 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 useruser- 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 useruser- the user to find the issue count for- Returns:
- number of issues assigned to user
- Throws:
SearchException- if something goes wrong
-
getDisplayableNameSafely
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
Returns a collection ofGroupobjects that the user belongs to.- Parameters:
userName- A User name- Returns:
- the set of groups that the user belongs to
- Since:
- v4.3
-
getGroupNamesForUser
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
Returns a collection ofUserobjects that belong to any of the passed in collection of group names. Prefer usinggetAllUsersInGroupNamesUnsorted(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
UserCachingComparatororder
-
getAllUsersInGroupNamesUnsorted
Returns a collection ofUserobjects 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 ofUserobjects that are found within the passed in collection ofGroupobjects.- Parameters:
groups- a collection ofGroupobjects- Returns:
- the set of users that are in the groups, sorted in
UserCachingComparatororder
-