Package com.atlassian.jira.user.util
Class UserUtilImpl
java.lang.Object
com.atlassian.jira.user.util.UserUtilImpl
- All Implemented Interfaces:
UserUtil
This is the default implementation of the UserUtil interface.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.jira.user.util.UserUtil
UserUtil.PasswordResetToken, UserUtil.PasswordResetTokenValidation -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from interface com.atlassian.jira.user.util.UserUtil
META_PROPERTY_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionUserUtilImpl(IssueSecurityLevelManager issueSecurityLevelManager, GlobalPermissionManager globalPermissionManager, com.atlassian.crowd.embedded.api.CrowdService crowdService, PermissionManager permissionManager, ApplicationProperties applicationProperties, SearchService searchService, ProjectManager projectManager, ProjectRoleService projectRoleService, ProjectComponentManager componentManager, SubscriptionManager subscriptionManager, NotificationSchemeManager notificationSchemeManager, UserHistoryManager userHistoryManager, UserManager userManager, ExtendedUserDao userDao, ApplicationRoleManager applicationRoleManager, JsonEntityPropertyManager jsonEntityPropertyManager, SharePermissionDeleteUtils sharePermissionDeleteUtils) -
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 userprotected PortalPageServiceA Factory method to get the PortalPageService.Returns all the projects that leadUser is the project lead for.protected SearchRequestServiceA Factory method to get the SearchRequestService.protected JiraServiceContextProtected level factory method to allow for better test integrationgetUsersInGroupNames(Collection<String> groupNames) 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
-
USERNAME
- See Also:
-
EMAIL
- See Also:
-
DISPLAY_NAME
- See Also:
-
DIRECTORY_NAME
- See Also:
-
DIRECTORY_ID
- See Also:
-
PASSWORD_TOKEN
- See Also:
-
PASSWORD_HOURS
- See Also:
-
SEND_EMAIL
- See Also:
-
-
Constructor Details
-
Method Details
-
getSearchRequestService
A Factory method to get the SearchRequestService. This helps break the cyclic dependency of SearchRequestService to UserUtils AND allows test to override the value used.- Returns:
- a SearchRequestService
-
getPortalPageService
A Factory method to get the PortalPageService. This helps break the cyclic dependency of PortalPageService to UserUtils AND allows test to override the value used.- Returns:
- a PortalPageService
-
getServiceContext
Protected level factory method to allow for better test integration- Parameters:
user- the user in action- Returns:
- a new JiraServiceContext
-
removeUser
Description copied from interface:UserUtilThis will remove the user and removes the user from all the groups. All components lead by user will have lead cleared.- Specified by:
removeUserin interfaceUserUtil- Parameters:
loggedInUser- the user performing operationuser- the user to delete
-
getNumberOfReportedIssuesIgnoreSecurity
public long getNumberOfReportedIssuesIgnoreSecurity(ApplicationUser loggedInUser, ApplicationUser user) throws SearchException Description copied from interface:UserUtilReturns number of issues reported by user- Specified by:
getNumberOfReportedIssuesIgnoreSecurityin interfaceUserUtil- 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
public long getNumberOfAssignedIssuesIgnoreSecurity(ApplicationUser loggedInUser, ApplicationUser user) throws SearchException Description copied from interface:UserUtilReturns number of issues assigned to user- Specified by:
getNumberOfAssignedIssuesIgnoreSecurityin interfaceUserUtil- 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
-
getComponentsUserLeads
Description copied from interface:UserUtilRetrieve a collection of ProjectComponents - where the lead of each component is the specified user.- Specified by:
getComponentsUserLeadsin interfaceUserUtil- Parameters:
user- User leading components- Returns:
- Collection of project components
-
getProjectsLeadBy
Description copied from interface:UserUtilReturns all the projects that leadUser is the project lead for.- Specified by:
getProjectsLeadByin interfaceUserUtil- Parameters:
user- the user in play- Returns:
- A collection of project
GenericValues
-
isNonSysAdminAttemptingToDeleteSysAdmin
public boolean isNonSysAdminAttemptingToDeleteSysAdmin(ApplicationUser loggedInUser, ApplicationUser user) Description copied from interface:UserUtilChecking if user without SYSTEM_ADMIN rights tries to remove user with SYSTEM_ADMIN rights.- Specified by:
isNonSysAdminAttemptingToDeleteSysAdminin interfaceUserUtil- Parameters:
loggedInUser- User performing operationuser- User for remove- Returns:
- true if user without SYSTEM_ADMIN rights tries to remove user with SYSTEM_ADMIN rights
-
addUserToGroup
public void addUserToGroup(com.atlassian.crowd.embedded.api.Group group, ApplicationUser userToAdd) throws PermissionException, AddException Description copied from interface:UserUtilThis 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.- Specified by:
addUserToGroupin interfaceUserUtil- Parameters:
group- the group to add the user to.userToAdd- the user to add to the group.- Throws:
PermissionExceptionAddException
-
addUserToGroups
public void addUserToGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups, ApplicationUser userToAdd) throws PermissionException, AddException Description copied from interface:UserUtilThis is used to add a user to many groups at once.- Specified by:
addUserToGroupsin interfaceUserUtil- Parameters:
groups- a list containing the groups to add the user to.userToAdd- the user to add to the group.- Throws:
PermissionExceptionAddException
-
removeUserFromGroup
public void removeUserFromGroup(com.atlassian.crowd.embedded.api.Group group, ApplicationUser userToRemove) throws PermissionException, RemoveException Description copied from interface:UserUtilThis 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.- Specified by:
removeUserFromGroupin interfaceUserUtil- Parameters:
group- the group to add the user to.userToRemove- the user to add to the group.- Throws:
PermissionExceptionRemoveException
-
removeUserFromGroups
public void removeUserFromGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups, ApplicationUser userToRemove) throws PermissionException, RemoveException Description copied from interface:UserUtilThis is used to remove a user from many groups at once.- Specified by:
removeUserFromGroupsin interfaceUserUtil- Parameters:
groups- a list containing the groups to add the user to.userToRemove- the user to add to the group.- Throws:
PermissionExceptionRemoveException
-
generatePasswordResetToken
Description copied from interface:UserUtilThis 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.
- Specified by:
generatePasswordResetTokenin interfaceUserUtil- Parameters:
user- the user in question. This MUST not be null- Returns:
- a newly generated token that will live for a certain time
-
validatePasswordResetToken
public UserUtil.PasswordResetTokenValidation validatePasswordResetToken(ApplicationUser user, String token) Description copied from interface:UserUtilThis can be called to validate a token against the user.- Specified by:
validatePasswordResetTokenin interfaceUserUtil- Parameters:
user- the user in playtoken- the token they provided- Returns:
- a Validation object that describes how the option went
-
changePassword
public void changePassword(ApplicationUser user, String newPassword) throws PermissionException, com.atlassian.crowd.exception.InvalidCredentialException Description copied from interface:UserUtilCan be called to set the password for a user. This will delete any password request tokens associated with that user- Specified by:
changePasswordin interfaceUserUtil- Parameters:
user- the user in playnewPassword- their new password- Throws:
com.atlassian.crowd.exception.InvalidCredentialException- if the password is invalidPermissionException
-
userExists
Description copied from interface:UserUtilReturns true if the a user exists with the specified userName- Specified by:
userExistsin interfaceUserUtil- Parameters:
userName- the name of the user- Returns:
- true if t a user exists with the specified name or false if not
-
getJiraAdministrators
Description copied from interface:UserUtilReturns a list of JIRA adminUsers.WARNING: This method will be changed in the future to return a Collection of Crowd
Userobjects. Since v4.3.- Specified by:
getJiraAdministratorsin interfaceUserUtil- Returns:
- a list of JIRA admin
Users.
-
getJiraSystemAdministrators
Description copied from interface:UserUtilReturns 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.- Specified by:
getJiraSystemAdministratorsin interfaceUserUtil- Returns:
- a collection of
User's that are associated with thePermissions.SYSTEM_ADMINpermission.
-
getDisplayableNameSafely
Description copied from interface:UserUtilTakes the given user and returns a "displayable name" by cautiously checking the different edge cases for users.- Specified by:
getDisplayableNameSafelyin interfaceUserUtil- 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.
-
getAllUsersInGroups
public SortedSet<ApplicationUser> getAllUsersInGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups) Description copied from interface:UserUtilReturns a collection ofUserobjects that are found within the passed in collection ofGroupobjects.- Specified by:
getAllUsersInGroupsin interfaceUserUtil- Parameters:
groups- a collection ofGroupobjects- Returns:
- the set of users that are in the groups, sorted in
UserCachingComparatororder
-
getAllUsersInGroupNames
Description copied from interface:UserUtilReturns a collection ofUserobjects that belong to any of the passed in collection of group names. Prefer usingUserUtil.getAllUsersInGroupNamesUnsorted(java.util.Collection)and sorting the list of users only if absolutely necessary rather than relying on this method to perform the sort.- Specified by:
getAllUsersInGroupNamesin interfaceUserUtil- Parameters:
groupNames- a collection of group name strings- Returns:
- the set of users that are in the named groups, sorted in
UserCachingComparatororder
-
getAllUsersInGroupNamesUnsorted
Description copied from interface:UserUtilReturns a collection ofUserobjects that belong to any of the passed in collection of group names.- Specified by:
getAllUsersInGroupNamesUnsortedin interfaceUserUtil- Parameters:
groupNames- a collection of group name strings- Returns:
- the set of users that are in the named groups
-
getUsersInGroupNames
-
getGroupsForUser
Description copied from interface:UserUtilReturns a collection ofGroupobjects that the user belongs to.- Specified by:
getGroupsForUserin interfaceUserUtil- Parameters:
userName- A User name- Returns:
- the set of groups that the user belongs to
-
getGroupNamesForUser
Description copied from interface:UserUtilReturns a collection of the names of the groups that the user belongs to.- Specified by:
getGroupNamesForUserin interfaceUserUtil- Parameters:
userName- A User name- Returns:
- the set of groups that the user belongs to
-