|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.atlassian.jira.user.util.UserUtilImpl
public class UserUtilImpl
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 |
---|
Fields inherited from interface com.atlassian.jira.user.util.UserUtil |
---|
META_PROPERTY_PREFIX |
Constructor Summary | |
---|---|
UserUtilImpl(ComponentLocator componentLocator,
IssueSecurityLevelManager issueSecurityLevelManager,
GlobalPermissionManager globalPermissionManager,
com.atlassian.crowd.embedded.api.CrowdService crowdService,
com.atlassian.crowd.manager.directory.DirectoryManager directoryManager,
PermissionManager permissionManager,
ApplicationProperties applicationProperties,
SearchProvider searchProvider,
ProjectManager projectManager,
ProjectRoleService projectRoleService,
ProjectComponentManager componentManager,
SubscriptionManager subscriptionManager,
NotificationSchemeManager notificationSchemeManager,
UserHistoryManager userHistoryManager,
UserManager userManager,
com.atlassian.event.api.EventPublisher eventPublisher,
StudioHooks hooks)
|
Method Summary | |
---|---|
void |
addToJiraUsePermission(com.atlassian.crowd.embedded.api.User 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,
com.atlassian.crowd.embedded.api.User userToAdd)
This is used to add a specified user to a specified group. |
void |
addUserToGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups,
com.atlassian.crowd.embedded.api.User 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. |
boolean |
canActivateUsers(Collection<String> userNames)
Returns true if, after adding the specified users, the number of active users in JIRA does not exceed the user limit allowed by the license. |
void |
changePassword(com.atlassian.crowd.embedded.api.User 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. |
com.atlassian.crowd.embedded.api.User |
createUserNoNotification(String username,
String password,
String emailAddress,
String displayName)
Creates a User from supplied details. |
com.atlassian.crowd.embedded.api.User |
createUserNoNotification(String username,
String password,
String emailAddress,
String displayName,
Long directoryId)
Creates a User from supplied details. |
com.atlassian.crowd.embedded.api.User |
createUserWithNotification(String username,
String password,
String email,
String fullname,
int userEventType)
Creates a User from supplied details. |
com.atlassian.crowd.embedded.api.User |
createUserWithNotification(String username,
String password,
String email,
String fullname,
Long directoryId,
int userEventType)
Creates a User from supplied details. |
protected void |
dispatchEvent(com.atlassian.crowd.embedded.api.User user,
int userEventType,
Map<?,?> args)
|
void |
flushUserCaches()
|
static String |
generatePassword()
Generates a Random Password that can be used when the user has entered a blank password. |
UserUtil.PasswordResetToken |
generatePasswordResetToken(com.atlassian.crowd.embedded.api.User 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()
Returns the number of users that are currently 'active'. |
Collection<com.atlassian.crowd.embedded.api.User> |
getAdministrators()
Returns a list of JIRA admin User s. |
Set<com.atlassian.crowd.embedded.api.User> |
getAllUsers()
Returns the all users defined in JIRA, regardless of whether they are active or not. |
SortedSet<com.atlassian.crowd.embedded.api.User> |
getAllUsersInGroupNames(Collection<String> groupNames)
Returns a collection of User objects that belong to any of the passed in collection of group names. |
SortedSet<com.atlassian.crowd.embedded.api.User> |
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(com.atlassian.crowd.embedded.api.User user)
Retrieve a collection of ProjectComponents - where the lead of each component is the specified user. |
String |
getDisplayableNameSafely(com.atlassian.crowd.embedded.api.User 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 user name. |
SortedSet<com.atlassian.crowd.embedded.api.Group> |
getGroupsForUser(String userName)
Returns a collection of Group objects that the user belongs to. |
Collection<com.atlassian.crowd.embedded.api.User> |
getJiraAdministrators()
Returns a list of JIRA admin User s. |
Collection<com.atlassian.crowd.embedded.api.User> |
getJiraSystemAdministrators()
Returns a list of JIRA system admin User s. |
long |
getNumberOfAssignedIssuesIgnoreSecurity(com.atlassian.crowd.embedded.api.User loggedInUser,
com.atlassian.crowd.embedded.api.User user)
Returns number of issues assigned to user |
long |
getNumberOfReportedIssuesIgnoreSecurity(com.atlassian.crowd.embedded.api.User loggedInUser,
com.atlassian.crowd.embedded.api.User user)
Returns number of issues reported by user |
protected PortalPageService |
getPortalPageService()
A Factory method to get the PortalPageService. |
Collection<Project> |
getProjectsLeadBy(com.atlassian.crowd.embedded.api.User user)
Returns all the projects that leadUser is the project lead for. |
Collection<org.ofbiz.core.entity.GenericValue> |
getProjectsUserLeads(com.atlassian.crowd.embedded.api.User user)
|
protected SearchRequestService |
getSearchRequestService()
A Factory method to get the SearchRequestService. |
protected JiraServiceContext |
getServiceContext(com.atlassian.crowd.embedded.api.User user)
Protected level factory method to allow for better test integration |
Collection<com.atlassian.crowd.embedded.api.User> |
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. |
com.atlassian.crowd.embedded.api.User |
getUser(String userName)
Get a User by name. |
com.atlassian.crowd.embedded.api.User |
getUserObject(String userName)
Returns a user based on user name. |
Collection<com.atlassian.crowd.embedded.api.User> |
getUsers()
Returns the all users defined in JIRA, regardless of whether they are active or not. |
SortedSet<com.atlassian.crowd.embedded.api.User> |
getUsersInGroupNames(Collection<String> groupNames)
Returns a collection of User objects that are found within the passed in collection
of group names. |
SortedSet<com.atlassian.crowd.embedded.api.User> |
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 |
hasExceededUserLimit()
Returns true if this JIRA instance has more active users, than allowed by the license. |
boolean |
isNonSysAdminAttemptingToDeleteSysAdmin(com.atlassian.crowd.embedded.api.User loggedInUser,
com.atlassian.crowd.embedded.api.User user)
Checking if user without SYSTEM_ADMIN rights tries to remove user with SYSTEM_ADMIN rights. |
void |
onClearCache(ClearCacheEvent event)
|
void |
onDirectoryModified(com.atlassian.crowd.event.DirectoryEvent event)
|
void |
onDirectorySynchronisation(com.atlassian.crowd.event.directory.RemoteDirectorySynchronisedEvent event)
|
void |
removeUser(com.atlassian.crowd.embedded.api.User loggedInUser,
com.atlassian.crowd.embedded.api.User user)
This will remove the user and removes the user from all the groups. |
void |
removeUserFromGroup(com.atlassian.crowd.embedded.api.Group group,
com.atlassian.crowd.embedded.api.User userToRemove)
This is used to remove a specified user from a specified group. |
void |
removeUserFromGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups,
com.atlassian.crowd.embedded.api.User userToRemove)
This is used to remove a user from many groups at once. |
void |
start()
This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework. |
boolean |
userExists(String userName)
Returns true if the a user exists with the specified userName |
UserUtil.PasswordResetTokenValidation |
validatePasswordResetToken(com.atlassian.crowd.embedded.api.User user,
String token)
This can be called to validate a token against the user. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UserUtilImpl(ComponentLocator componentLocator, IssueSecurityLevelManager issueSecurityLevelManager, GlobalPermissionManager globalPermissionManager, com.atlassian.crowd.embedded.api.CrowdService crowdService, com.atlassian.crowd.manager.directory.DirectoryManager directoryManager, PermissionManager permissionManager, ApplicationProperties applicationProperties, SearchProvider searchProvider, ProjectManager projectManager, ProjectRoleService projectRoleService, ProjectComponentManager componentManager, SubscriptionManager subscriptionManager, NotificationSchemeManager notificationSchemeManager, UserHistoryManager userHistoryManager, UserManager userManager, com.atlassian.event.api.EventPublisher eventPublisher, StudioHooks hooks)
Method Detail |
---|
public void start() throws Exception
Startable
start
in interface Startable
Exception
- Allows implementations to throw an Exception.@EventListener public void onClearCache(ClearCacheEvent event)
@EventListener public void onDirectoryModified(com.atlassian.crowd.event.DirectoryEvent event)
@EventListener public void onDirectorySynchronisation(com.atlassian.crowd.event.directory.RemoteDirectorySynchronisedEvent event)
public void flushUserCaches()
protected SearchRequestService getSearchRequestService()
protected PortalPageService getPortalPageService()
protected JiraServiceContext getServiceContext(com.atlassian.crowd.embedded.api.User user)
user
- the user in action
public com.atlassian.crowd.embedded.api.User 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 user
PermissionException
- If the operation was not permitted.
CreateException
public com.atlassian.crowd.embedded.api.User 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 static String generatePassword()
The password is guaranteed to contain at least one upper-case letter, lower-case letter and number in case the backend user Directory has password restrictions.
public com.atlassian.crowd.embedded.api.User 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
PermissionException
- If the operation was not permitted.
CreateException
public com.atlassian.crowd.embedded.api.User 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
PermissionException
- If the operation was not permitted.
CreateException
protected void dispatchEvent(com.atlassian.crowd.embedded.api.User user, int userEventType, Map<?,?> args)
public void removeUser(com.atlassian.crowd.embedded.api.User loggedInUser, com.atlassian.crowd.embedded.api.User user)
UserUtil
removeUser
in interface UserUtil
loggedInUser
- the user performing operationuser
- the user to deletepublic long getNumberOfReportedIssuesIgnoreSecurity(com.atlassian.crowd.embedded.api.User loggedInUser, com.atlassian.crowd.embedded.api.User user) throws SearchException
UserUtil
getNumberOfReportedIssuesIgnoreSecurity
in interface UserUtil
loggedInUser
- the logged in useruser
- the user to find the issue count for
SearchException
- if something goes wrongpublic long getNumberOfAssignedIssuesIgnoreSecurity(com.atlassian.crowd.embedded.api.User loggedInUser, com.atlassian.crowd.embedded.api.User user) throws SearchException
UserUtil
getNumberOfAssignedIssuesIgnoreSecurity
in interface UserUtil
loggedInUser
- the logged in useruser
- the user to find the issue count for
SearchException
- if something goes wrongpublic Collection<ProjectComponent> getComponentsUserLeads(com.atlassian.crowd.embedded.api.User user)
UserUtil
getComponentsUserLeads
in interface UserUtil
user
- User leading components
public Collection<Project> getProjectsLeadBy(com.atlassian.crowd.embedded.api.User user)
UserUtil
getProjectsLeadBy
in interface UserUtil
user
- the user in play
GenericValue
spublic Collection<org.ofbiz.core.entity.GenericValue> getProjectsUserLeads(com.atlassian.crowd.embedded.api.User user)
public boolean isNonSysAdminAttemptingToDeleteSysAdmin(com.atlassian.crowd.embedded.api.User loggedInUser, com.atlassian.crowd.embedded.api.User user)
UserUtil
isNonSysAdminAttemptingToDeleteSysAdmin
in interface UserUtil
loggedInUser
- User performing operationuser
- User for remove
public void addUserToGroup(com.atlassian.crowd.embedded.api.Group group, com.atlassian.crowd.embedded.api.User 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, com.atlassian.crowd.embedded.api.User 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, com.atlassian.crowd.embedded.api.User 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, com.atlassian.crowd.embedded.api.User 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(com.atlassian.crowd.embedded.api.User user)
UserUtil
generatePasswordResetToken
in interface UserUtil
user
- the user in question. This MUST not be null
public UserUtil.PasswordResetTokenValidation validatePasswordResetToken(com.atlassian.crowd.embedded.api.User user, String token)
UserUtil
validatePasswordResetToken
in interface UserUtil
user
- the user in playtoken
- the token they provided
public void changePassword(com.atlassian.crowd.embedded.api.User user, String newPassword) throws PermissionException
UserUtil
changePassword
in interface UserUtil
user
- the user in playnewPassword
- their new password
PermissionException
public int getActiveUserCount()
UserUtil
UserUtil.clearActiveUserCount()
to clear the cache.
Please note that the calculation will be run if the license does not specify a user limit.
getActiveUserCount
in interface UserUtil
Permissions
public void clearActiveUserCount()
UserUtil
clearActiveUserCount
in interface UserUtil
public boolean hasExceededUserLimit()
UserUtil
hasExceededUserLimit
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!
public boolean canActivateUsers(Collection<String> userNames)
UserUtil
canActivateUsers
in interface UserUtil
userNames
- the names of the users to add to the JIRA instance. Must not be null!
public Set<com.atlassian.crowd.embedded.api.User> getAllUsers()
UserUtil
WARNING: This method will be changed in the future to return a set of Crowd User
objects. Since v4.3.
getAllUsers
in interface UserUtil
public Collection<com.atlassian.crowd.embedded.api.User> getUsers()
UserUtil
WARNING: This method will be changed in the future to return a set of Crowd User
objects. Since v4.3.
getUsers
in interface UserUtil
public int getTotalUserCount()
UserUtil
getTotalUserCount
in interface UserUtil
public com.atlassian.crowd.embedded.api.User getUser(String userName)
getUser
in interface UserUtil
userName
- the name of the user
public com.atlassian.crowd.embedded.api.User getUserObject(String userName)
UserUtil
WARNING: This method will be changed in the future to return a Crowd User
object. Since v4.3.
getUserObject
in interface UserUtil
userName
- the user name of the user
public boolean userExists(String userName)
UserUtil
userExists
in interface UserUtil
userName
- the name of the user
public Collection<com.atlassian.crowd.embedded.api.User> 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<com.atlassian.crowd.embedded.api.User> 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<com.atlassian.crowd.embedded.api.User> 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<com.atlassian.crowd.embedded.api.User> 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(com.atlassian.crowd.embedded.api.User 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(com.atlassian.crowd.embedded.api.User user)
UserUtil
getDisplayableNameSafely
in interface UserUtil
user
- the user. May be null.
public SortedSet<com.atlassian.crowd.embedded.api.User> 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
objects
UserBestNameComparator
orderpublic SortedSet<com.atlassian.crowd.embedded.api.User> 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
objects
UserBestNameComparator
orderpublic SortedSet<com.atlassian.crowd.embedded.api.User> getAllUsersInGroupNames(Collection<String> groupNames)
UserUtil
User
objects that belong to any of the passed in collection of group names.
getAllUsersInGroupNames
in interface UserUtil
groupNames
- a collection of group name strings
UserBestNameComparator
orderpublic SortedSet<com.atlassian.crowd.embedded.api.User> 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 strings
public 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 name
public SortedSet<String> getGroupNamesForUser(String userName)
UserUtil
getGroupNamesForUser
in interface UserUtil
userName
- A User name
public com.atlassian.crowd.embedded.api.Group getGroup(String groupName)
getGroup
in interface UserUtil
groupName
- the name of the group
public com.atlassian.crowd.embedded.api.Group getGroupObject(@Nullable String groupName)
UserUtil
Group
based on user name.
WARNING: This method will be changed in the future to return a Crowd Group
object. Since v4.3.
getGroupObject
in interface UserUtil
groupName
- the user name of the group
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |