UserUtil.PasswordResetToken, UserUtil.PasswordResetTokenValidation
Modifier and Type | Field and Description |
---|---|
static String |
DIRECTORY_ID |
static String |
DIRECTORY_NAME |
static String |
DISPLAY_NAME |
static String |
EMAIL |
static String |
PASSWORD_HOURS |
static String |
PASSWORD_TOKEN |
static String |
SEND_EMAIL |
static String |
USERNAME |
META_PROPERTY_PREFIX
Constructor and Description |
---|
UserUtilImpl(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,
LicenseCountService licenseCountService,
ApplicationRoleManager applicationRoleManager,
JsonEntityPropertyManager jsonEntityPropertyManager,
SharePermissionDeleteUtils sharePermissionDeleteUtils) |
Modifier and Type | Method and Description |
---|---|
void |
addToJiraUsePermission(ApplicationUser user)
Takes the given user and adds him/her to all the groups that grant a user the global JIRA use permission.
|
void |
addUserToGroup(com.atlassian.crowd.embedded.api.Group group,
ApplicationUser userToAdd)
This is used to add a specified user to a specified group.
|
void |
addUserToGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups,
ApplicationUser userToAdd)
This is used to add a user to many groups at once.
|
boolean |
canActivateNumberOfUsers(int numUsers)
Returns true if, after adding the specified number of users, the number of active users in JIRA does not exceed
the user limit allowed by the license.
|
void |
changePassword(ApplicationUser user,
String newPassword)
Can be called to set the password for a user.
|
void |
clearActiveUserCount()
Clears the cache of the active user count so that it can be recalculated.
|
ApplicationUser |
createUser(UserDetails userData,
boolean sendEmailNotification,
int eventType,
Set<com.atlassian.application.api.ApplicationKey> applicationKeys)
This method is being removed - Please use
UserService . |
ApplicationUser |
createUserNoNotification(String username,
String password,
String emailAddress,
String displayName)
Creates a User from supplied details.
|
ApplicationUser |
createUserNoNotification(String username,
String password,
String emailAddress,
String displayName,
Long directoryId)
Creates a User from supplied details.
|
ApplicationUser |
createUserWithNotification(String username,
String password,
String email,
String fullname,
int userEventType)
Creates a User from supplied details.
|
ApplicationUser |
createUserWithNotification(String username,
String password,
String email,
String fullname,
Long directoryId,
int userEventType)
Creates a User from supplied details.
|
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.
|
int |
getActiveUserCount()
Gets the number of active users who currently count towards the license and should be charged for.
|
Collection<ApplicationUser> |
getAdministrators()
Returns a list of JIRA admin
User s. |
Collection<ApplicationUser> |
getAllApplicationUsers()
Returns the all users defined in JIRA, regardless of whether they are active or not.
|
SortedSet<ApplicationUser> |
getAllUsersInGroupNames(Collection<String> groupNames)
Returns a collection of
User objects that belong to any of the passed in collection of group names. |
Set<ApplicationUser> |
getAllUsersInGroupNamesUnsorted(Collection<String> groupNames)
Returns a collection of
User objects that belong to any of the passed in collection of group names. |
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. |
Collection<ProjectComponent> |
getComponentsUserLeads(ApplicationUser user)
Retrieve a collection of ProjectComponents - where the lead of each component is the specified user.
|
String |
getDisplayableNameSafely(ApplicationUser user)
Takes the given user and returns a "displayable name" by cautiously checking the different edge cases for users.
|
com.atlassian.crowd.embedded.api.Group |
getGroup(String groupName)
Get a Group by name.
|
SortedSet<String> |
getGroupNamesForUser(String userName)
Returns a collection of the names of the groups that the user belongs to.
|
com.atlassian.crowd.embedded.api.Group |
getGroupObject(String groupName)
Returns a
Group based on group name. |
SortedSet<com.atlassian.crowd.embedded.api.Group> |
getGroupsForUser(String userName)
Returns a collection of
Group objects that the user belongs to. |
Collection<ApplicationUser> |
getJiraAdministrators()
Returns a list of JIRA admin
User s. |
Collection<ApplicationUser> |
getJiraSystemAdministrators()
Returns a list of JIRA system admin
User s. |
long |
getNumberOfAssignedIssuesIgnoreSecurity(ApplicationUser loggedInUser,
ApplicationUser user)
Returns number of issues assigned to user
|
long |
getNumberOfReportedIssuesIgnoreSecurity(ApplicationUser loggedInUser,
ApplicationUser user)
Returns number of issues reported by user
|
protected PortalPageService |
getPortalPageService()
A Factory method to get the PortalPageService.
|
Collection<Project> |
getProjectsLeadBy(ApplicationUser user)
Returns all the projects that leadUser is the project lead for.
|
protected SearchRequestService |
getSearchRequestService()
A Factory method to get the SearchRequestService.
|
protected JiraServiceContext |
getServiceContext(ApplicationUser user)
Protected level factory method to allow for better test integration
|
Collection<ApplicationUser> |
getSystemAdministrators()
Returns a list of JIRA system admin
User s. |
int |
getTotalUserCount()
Returns the total number of users defined in JIRA, regardless of whether they are active or not.
|
ApplicationUser |
getUser(String userName)
Get a User by name.
|
ApplicationUser |
getUserByKey(String key)
Returns a user based on key.
|
ApplicationUser |
getUserByName(String username)
Returns a user based on user name.
|
ApplicationUser |
getUserObject(String userName)
Returns a user based on user name.
|
Collection<ApplicationUser> |
getUsers()
Returns the all users defined in JIRA, regardless of whether they are active or not.
|
SortedSet<ApplicationUser> |
getUsersInGroupNames(Collection<String> groupNames)
Returns a collection of
User objects that are found within the passed in collection of group names. |
SortedSet<ApplicationUser> |
getUsersInGroups(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. |
boolean |
isNonSysAdminAttemptingToDeleteSysAdmin(ApplicationUser loggedInUser,
ApplicationUser user)
Checking if user without SYSTEM_ADMIN rights tries to remove user with SYSTEM_ADMIN rights.
|
void |
removeUser(ApplicationUser loggedInUser,
ApplicationUser user)
This will remove the user and removes the user from all the groups.
|
void |
removeUserFromGroup(com.atlassian.crowd.embedded.api.Group group,
ApplicationUser userToRemove)
This is used to remove a specified user from a specified group.
|
void |
removeUserFromGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups,
ApplicationUser userToRemove)
This is used to remove a user from many groups at once.
|
boolean |
userExists(String userName)
Returns true if the a user exists with the specified userName
|
UserUtil.PasswordResetTokenValidation |
validatePasswordResetToken(ApplicationUser user,
String token)
This can be called to validate a token against the user.
|
public static final String USERNAME
public static final String EMAIL
public static final String DISPLAY_NAME
public static final String DIRECTORY_NAME
public static final String DIRECTORY_ID
public static final String PASSWORD_TOKEN
public static final String PASSWORD_HOURS
public static final String SEND_EMAIL
public UserUtilImpl(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, LicenseCountService licenseCountService, ApplicationRoleManager applicationRoleManager, JsonEntityPropertyManager jsonEntityPropertyManager, SharePermissionDeleteUtils sharePermissionDeleteUtils)
protected SearchRequestService getSearchRequestService()
protected PortalPageService getPortalPageService()
protected JiraServiceContext getServiceContext(ApplicationUser user)
user
- the user in actionpublic ApplicationUser createUserNoNotification(String username, String password, String emailAddress, String displayName) throws PermissionException, CreateException
UserUtil
No email notification will be send to created user.
createUserNoNotification
in interface UserUtil
username
- The username of the new user. Needs to be lowercase and unique.password
- The password for the new user.emailAddress
- The email for the new user. Needs to be a valid email address.displayName
- The display name for the new userPermissionException
- If the operation was not permitted.CreateException
public ApplicationUser createUserNoNotification(String username, String password, String emailAddress, String displayName, Long directoryId) throws PermissionException, CreateException
UserUtil
No email notification will be send to created user.
createUserNoNotification
in interface UserUtil
username
- The username of the new user. Needs to be lowercase and unique.password
- The password for the new user.emailAddress
- The email for the new user. Needs to be a valid email address.displayName
- The display name for the new userdirectoryId
- The directory to create the user in. Null means "first writable directory".PermissionException
- If the operation was not permitted.CreateException
public ApplicationUser createUserWithNotification(String username, String password, String email, String fullname, int userEventType) throws PermissionException, CreateException
UserUtil
Email notification will be send to created user.
createUserWithNotification
in interface UserUtil
username
- The username of the new user. Needs to be lowercase and unique.password
- The password for the new user.email
- The email for the new user. Needs to be a valid email address.fullname
- The full name for the new useruserEventType
- The event type dispatched on user creation. Either UserEventType.USER_CREATED
or UserEventType.USER_SIGNUP
PermissionException
- If the operation was not permitted.CreateException
public ApplicationUser createUserWithNotification(String username, String password, String email, String fullname, Long directoryId, int userEventType) throws PermissionException, CreateException
UserUtil
Email notification will be send to created user.
createUserWithNotification
in interface UserUtil
username
- The username of the new user. Needs to be lowercase and unique.password
- The password for the new user.email
- The email for the new user. Needs to be a valid email address.fullname
- The full name for the new userdirectoryId
- The directory to create the user in. Null means "first writable directory".userEventType
- The event type dispatched on user creation. Either UserEventType.USER_CREATED
or UserEventType.USER_SIGNUP
PermissionException
- If the operation was not permitted.CreateException
@Nonnull public ApplicationUser createUser(@Nonnull UserDetails userData, boolean sendEmailNotification, int eventType, @Nullable Set<com.atlassian.application.api.ApplicationKey> applicationKeys) throws PermissionException, CreateException
UserUtil
UserService
.
Creates a JIRA user.createUser
in interface UserUtil
userData
- user request containing user details.sendEmailNotification
- should send email notification.eventType
- notification event type (see to UserEventType
).applicationKeys
- applications that user should be granted access to,
null
if instance default applications should be used,
empty Set when user does not require access to any applications.PermissionException
- If the operation was not permitted.CreateException
- Unable to create user.public void removeUser(ApplicationUser loggedInUser, ApplicationUser user)
UserUtil
removeUser
in interface UserUtil
loggedInUser
- the user performing operationuser
- the user to deletepublic long getNumberOfReportedIssuesIgnoreSecurity(ApplicationUser loggedInUser, ApplicationUser user) throws SearchException
UserUtil
getNumberOfReportedIssuesIgnoreSecurity
in interface UserUtil
loggedInUser
- the logged in useruser
- the user to find the issue count forSearchException
- if something goes wrongpublic long getNumberOfAssignedIssuesIgnoreSecurity(ApplicationUser loggedInUser, ApplicationUser user) throws SearchException
UserUtil
getNumberOfAssignedIssuesIgnoreSecurity
in interface UserUtil
loggedInUser
- the logged in useruser
- the user to find the issue count forSearchException
- if something goes wrongpublic Collection<ProjectComponent> getComponentsUserLeads(ApplicationUser user)
UserUtil
getComponentsUserLeads
in interface UserUtil
user
- User leading componentspublic Collection<Project> getProjectsLeadBy(ApplicationUser user)
UserUtil
getProjectsLeadBy
in interface UserUtil
user
- the user in playGenericValue
spublic boolean isNonSysAdminAttemptingToDeleteSysAdmin(ApplicationUser loggedInUser, ApplicationUser user)
UserUtil
isNonSysAdminAttemptingToDeleteSysAdmin
in interface UserUtil
loggedInUser
- User performing operationuser
- User for removepublic void addUserToGroup(com.atlassian.crowd.embedded.api.Group group, ApplicationUser userToAdd) throws PermissionException, AddException
UserUtil
addUserToGroup
in interface UserUtil
group
- the group to add the user to.userToAdd
- the user to add to the group.PermissionException
AddException
public void addUserToGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups, ApplicationUser userToAdd) throws PermissionException, AddException
UserUtil
addUserToGroups
in interface UserUtil
groups
- a list containing the groups to add the user to.userToAdd
- the user to add to the group.PermissionException
AddException
public void removeUserFromGroup(com.atlassian.crowd.embedded.api.Group group, ApplicationUser userToRemove) throws PermissionException, RemoveException
UserUtil
removeUserFromGroup
in interface UserUtil
group
- the group to add the user to.userToRemove
- the user to add to the group.PermissionException
RemoveException
public void removeUserFromGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups, ApplicationUser userToRemove) throws PermissionException, RemoveException
UserUtil
removeUserFromGroups
in interface UserUtil
groups
- a list containing the groups to add the user to.userToRemove
- the user to add to the group.PermissionException
RemoveException
public UserUtil.PasswordResetToken generatePasswordResetToken(ApplicationUser user)
UserUtil
The generated token will be associated with the named user so that that this information can be verified at a later time.
generatePasswordResetToken
in interface UserUtil
user
- the user in question. This MUST not be nullpublic UserUtil.PasswordResetTokenValidation validatePasswordResetToken(ApplicationUser user, String token)
UserUtil
validatePasswordResetToken
in interface UserUtil
user
- the user in playtoken
- the token they providedpublic void changePassword(ApplicationUser user, String newPassword) throws PermissionException, com.atlassian.crowd.exception.InvalidCredentialException
UserUtil
changePassword
in interface UserUtil
user
- the user in playnewPassword
- their new passwordcom.atlassian.crowd.exception.InvalidCredentialException
- if the password is invalidPermissionException
public int getActiveUserCount()
UserUtil
In all cases this method will exclude Connect users from the count. In Cloud this will also exclude users who exist for the purpose of providing support (such as the Atlassian sysadmin user).
getActiveUserCount
in interface UserUtil
Permissions
public int getTotalUserCount()
UserUtil
getTotalUserCount
in interface UserUtil
public void clearActiveUserCount()
UserUtil
clearActiveUserCount
in interface UserUtil
public boolean canActivateNumberOfUsers(int numUsers)
UserUtil
canActivateNumberOfUsers
in interface UserUtil
numUsers
- the number of users to add to the JIRA instance. If 0, all things being equal, this method will
return true. Must not be negative!@Nonnull public Collection<ApplicationUser> getUsers()
UserUtil
@Nonnull public Collection<ApplicationUser> getAllApplicationUsers()
UserUtil
getAllApplicationUsers
in interface UserUtil
public ApplicationUser getUser(String userName)
public ApplicationUser getUserByKey(String key)
UserUtil
getUserByKey
in interface UserUtil
key
- the key of the userpublic ApplicationUser getUserByName(String username)
UserUtil
getUserByName
in interface UserUtil
username
- the user name of the userpublic ApplicationUser getUserObject(String userName)
UserUtil
getUserObject
in interface UserUtil
userName
- the user name of the userpublic boolean userExists(String userName)
UserUtil
userExists
in interface UserUtil
userName
- the name of the userpublic Collection<ApplicationUser> getAdministrators()
UserUtil
User
s.
WARNING: This method will be changed in the future to return a Collection of Crowd User
objects. Since v4.3.
getAdministrators
in interface UserUtil
User
s.public Collection<ApplicationUser> getJiraAdministrators()
UserUtil
User
s.
WARNING: This method will be changed in the future to return a Collection of Crowd User
objects. Since v4.3.
getJiraAdministrators
in interface UserUtil
User
s.public Collection<ApplicationUser> getSystemAdministrators()
UserUtil
User
s.
WARNING: This method will be changed in the future to return a Collection of Crowd User
objects. Since v4.3.
getSystemAdministrators
in interface UserUtil
User
's that are associated with the Permissions.SYSTEM_ADMIN
permission.public Collection<ApplicationUser> getJiraSystemAdministrators()
UserUtil
User
s.
WARNING: This method will be changed in the future to return a Collection of Crowd User
objects. Since v4.3.
getJiraSystemAdministrators
in interface UserUtil
User
's that are associated with the Permissions.SYSTEM_ADMIN
permission.public void addToJiraUsePermission(ApplicationUser user)
UserUtil
Permissions.USE
) Note: operation is only performed if by doing so we will not
exceed the user limit (if the current license happens to specify a limit)addToJiraUsePermission
in interface UserUtil
user
- The user to be added to the USE permissionpublic String getDisplayableNameSafely(ApplicationUser user)
UserUtil
getDisplayableNameSafely
in interface UserUtil
user
- the user. May be null.public SortedSet<ApplicationUser> getAllUsersInGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups)
UserUtil
User
objects that are found within the passed in collection of Group
objects.getAllUsersInGroups
in interface UserUtil
groups
- a collection of Group
objectsUserCachingComparator
orderpublic SortedSet<ApplicationUser> getUsersInGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups)
UserUtil
User
objects that are found within the passed in collection of Group
objects. Null users are excluded even if they exist in the underlying data.getUsersInGroups
in interface UserUtil
groups
- a collection of Group
objectsUserCachingComparator
orderpublic SortedSet<ApplicationUser> getAllUsersInGroupNames(Collection<String> groupNames)
UserUtil
User
objects that belong to any of the passed in collection of group names.
Prefer using UserUtil.getAllUsersInGroupNamesUnsorted(java.util.Collection)
and sorting the list of users only if
absolutely necessary rather than relying on this method to perform the sort.getAllUsersInGroupNames
in interface UserUtil
groupNames
- a collection of group name stringsUserCachingComparator
orderpublic Set<ApplicationUser> getAllUsersInGroupNamesUnsorted(Collection<String> groupNames)
UserUtil
User
objects that belong to any of the passed in collection of group names.getAllUsersInGroupNamesUnsorted
in interface UserUtil
groupNames
- a collection of group name stringspublic SortedSet<ApplicationUser> getUsersInGroupNames(Collection<String> groupNames)
UserUtil
User
objects that are found within the passed in collection of group names. Null
users are excluded even if they exist in the underlying data.getUsersInGroupNames
in interface UserUtil
groupNames
- a collection of group name stringspublic SortedSet<com.atlassian.crowd.embedded.api.Group> getGroupsForUser(String userName)
UserUtil
Group
objects that the user belongs to.getGroupsForUser
in interface UserUtil
userName
- A User namepublic SortedSet<String> getGroupNamesForUser(String userName)
UserUtil
getGroupNamesForUser
in interface UserUtil
userName
- A User namepublic com.atlassian.crowd.embedded.api.Group getGroup(String groupName)
public com.atlassian.crowd.embedded.api.Group getGroupObject(@Nullable String groupName)
UserUtil
Group
based on group name.getGroupObject
in interface UserUtil
groupName
- the user name of the groupCopyright © 2002-2019 Atlassian. All Rights Reserved.