com.atlassian.jira.user.util
Class UserUtilImpl

java.lang.Object
  extended by com.atlassian.jira.user.util.UserUtilImpl
All Implemented Interfaces:
Startable, UserUtil

public class UserUtilImpl
extends Object
implements UserUtil, Startable

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
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
           
 
Fields inherited from interface com.atlassian.jira.user.util.UserUtil
META_PROPERTY_PREFIX
 
Constructor Summary
UserUtilImpl(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, com.atlassian.cache.CacheManager cacheManager)
           
 
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.
protected  com.atlassian.crowd.embedded.api.User createUserInDefaultDirectory(String username, String password, String emailAddress, String displayName, int userEventType, boolean sendEmail)
           
protected  com.atlassian.crowd.embedded.api.User createUserInDirectory(String username, String password, String emailAddress, String displayName, Long directoryId, int userEventType, boolean sendEmail)
           
 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<String,Object> 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 Users.
 Collection<ApplicationUser> getAllApplicationUsers()
          Returns the all users defined in JIRA, regardless of whether they are active or not.
 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.
 Set<com.atlassian.crowd.embedded.api.User> getAllUsersInGroupNamesUnsorted(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(ApplicationUser user)
          Retrieve a collection of ProjectComponents - where the lead of each component is the specified user.
 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(ApplicationUser user)
          Takes the given user and returns a "displayable name" by cautiously checking the different edge cases for users.
 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 Users.
 Collection<com.atlassian.crowd.embedded.api.User> getJiraSystemAdministrators()
          Returns a list of JIRA system admin Users.
 long getNumberOfAssignedIssuesIgnoreSecurity(ApplicationUser loggedInUser, ApplicationUser user)
          Returns number of issues assigned to user
 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(ApplicationUser loggedInUser, ApplicationUser user)
          Returns number of issues reported by 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(ApplicationUser user)
          Returns all the projects that leadUser is the project lead for.
 Collection<Project> getProjectsLeadBy(com.atlassian.crowd.embedded.api.User 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<com.atlassian.crowd.embedded.api.User> getSystemAdministrators()
          Returns a list of JIRA system admin Users.
 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.
 ApplicationUser getUserByKey(String key)
          Returns a user based on key.
 ApplicationUser getUserByName(String username)
          Returns a user based on user 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(ApplicationUser loggedInUser, ApplicationUser user)
          Checking if user without SYSTEM_ADMIN rights tries to remove user with SYSTEM_ADMIN rights.
 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(ApplicationUser loggedInUser, ApplicationUser user)
          This will remove the user and removes the user from all the groups.
 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
 

Field Detail

USERNAME

public static final String USERNAME
See Also:
Constant Field Values

EMAIL

public static final String EMAIL
See Also:
Constant Field Values

DISPLAY_NAME

public static final String DISPLAY_NAME
See Also:
Constant Field Values

DIRECTORY_NAME

public static final String DIRECTORY_NAME
See Also:
Constant Field Values

DIRECTORY_ID

public static final String DIRECTORY_ID
See Also:
Constant Field Values

PASSWORD_TOKEN

public static final String PASSWORD_TOKEN
See Also:
Constant Field Values

PASSWORD_HOURS

public static final String PASSWORD_HOURS
See Also:
Constant Field Values

SEND_EMAIL

public static final String SEND_EMAIL
See Also:
Constant Field Values
Constructor Detail

UserUtilImpl

public UserUtilImpl(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,
                    com.atlassian.cache.CacheManager cacheManager)
Method Detail

start

public void start()
           throws Exception
Description copied from interface: Startable
This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.

Specified by:
start in interface Startable
Throws:
Exception - Allows implementations to throw an Exception.

onClearCache

@EventListener
public void onClearCache(ClearCacheEvent event)

onDirectoryModified

@EventListener
public void onDirectoryModified(com.atlassian.crowd.event.DirectoryEvent event)

onDirectorySynchronisation

@EventListener
public void onDirectorySynchronisation(com.atlassian.crowd.event.directory.RemoteDirectorySynchronisedEvent event)

flushUserCaches

public void flushUserCaches()

getSearchRequestService

protected SearchRequestService 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

protected PortalPageService 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 JiraServiceContext getServiceContext(ApplicationUser user)
Protected level factory method to allow for better test integration

Parameters:
user - the user in action
Returns:
a new JiraServiceContext

createUserInDefaultDirectory

protected com.atlassian.crowd.embedded.api.User createUserInDefaultDirectory(String username,
                                                                             String password,
                                                                             String emailAddress,
                                                                             String displayName,
                                                                             int userEventType,
                                                                             boolean sendEmail)
                                                                      throws PermissionException,
                                                                             CreateException
Throws:
PermissionException
CreateException

createUserNoNotification

public com.atlassian.crowd.embedded.api.User createUserNoNotification(String username,
                                                                      String password,
                                                                      String emailAddress,
                                                                      String displayName)
                                                               throws PermissionException,
                                                                      CreateException
Description copied from interface: UserUtil
Creates a User from supplied details.

No email notification will be send to created user.

Specified by:
createUserNoNotification in interface UserUtil
Parameters:
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
Returns:
The new user object that was created
Throws:
PermissionException - If the operation was not permitted.
CreateException

createUserNoNotification

public com.atlassian.crowd.embedded.api.User createUserNoNotification(String username,
                                                                      String password,
                                                                      String emailAddress,
                                                                      String displayName,
                                                                      Long directoryId)
                                                               throws PermissionException,
                                                                      CreateException
Description copied from interface: UserUtil
Creates a User from supplied details.

No email notification will be send to created user.

Specified by:
createUserNoNotification in interface UserUtil
Parameters:
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
directoryId - The directory to create the user in. Null means "first writable directory".
Returns:
The new user object that was created
Throws:
PermissionException - If the operation was not permitted.
CreateException

createUserInDirectory

protected com.atlassian.crowd.embedded.api.User createUserInDirectory(String username,
                                                                      String password,
                                                                      String emailAddress,
                                                                      String displayName,
                                                                      Long directoryId,
                                                                      int userEventType,
                                                                      boolean sendEmail)
                                                               throws PermissionException,
                                                                      CreateException
Throws:
PermissionException
CreateException

generatePassword

public static String generatePassword()
Generates a Random Password that can be used when the user has entered a blank password.

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.

Returns:
a random password.

createUserWithNotification

public com.atlassian.crowd.embedded.api.User createUserWithNotification(String username,
                                                                        String password,
                                                                        String email,
                                                                        String fullname,
                                                                        int userEventType)
                                                                 throws PermissionException,
                                                                        CreateException
Description copied from interface: UserUtil
Creates a User from supplied details.

Email notification will be send to created user.

Specified by:
createUserWithNotification in interface UserUtil
Parameters:
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 user
userEventType - The event type dispatched on user creation. Either UserEventType.USER_CREATED or UserEventType.USER_SIGNUP
Returns:
The new user object that was created
Throws:
PermissionException - If the operation was not permitted.
CreateException

createUserWithNotification

public com.atlassian.crowd.embedded.api.User createUserWithNotification(String username,
                                                                        String password,
                                                                        String email,
                                                                        String fullname,
                                                                        Long directoryId,
                                                                        int userEventType)
                                                                 throws PermissionException,
                                                                        CreateException
Description copied from interface: UserUtil
Creates a User from supplied details.

Email notification will be send to created user.

Specified by:
createUserWithNotification in interface UserUtil
Parameters:
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 user
directoryId - 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
Returns:
The new user object that was created
Throws:
PermissionException - If the operation was not permitted.
CreateException

dispatchEvent

protected void dispatchEvent(com.atlassian.crowd.embedded.api.User user,
                             int userEventType,
                             Map<String,Object> args)

removeUser

public void removeUser(com.atlassian.crowd.embedded.api.User loggedInUser,
                       com.atlassian.crowd.embedded.api.User user)
Description copied from interface: UserUtil
This will remove the user and removes the user from all the groups. All components lead by user will have lead cleared.

Specified by:
removeUser in interface UserUtil
Parameters:
loggedInUser - the user performing operation
user - the user to delete

removeUser

public void removeUser(ApplicationUser loggedInUser,
                       ApplicationUser user)
Description copied from interface: UserUtil
This will remove the user and removes the user from all the groups. All components lead by user will have lead cleared.

Specified by:
removeUser in interface UserUtil
Parameters:
loggedInUser - the user performing operation
user - the user to delete

getNumberOfReportedIssuesIgnoreSecurity

public long getNumberOfReportedIssuesIgnoreSecurity(com.atlassian.crowd.embedded.api.User loggedInUser,
                                                    com.atlassian.crowd.embedded.api.User user)
                                             throws SearchException
Description copied from interface: UserUtil
Returns number of issues reported by user

Specified by:
getNumberOfReportedIssuesIgnoreSecurity in interface UserUtil
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

getNumberOfReportedIssuesIgnoreSecurity

public long getNumberOfReportedIssuesIgnoreSecurity(ApplicationUser loggedInUser,
                                                    ApplicationUser user)
                                             throws SearchException
Description copied from interface: UserUtil
Returns number of issues reported by user

Specified by:
getNumberOfReportedIssuesIgnoreSecurity in interface UserUtil
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

public long getNumberOfAssignedIssuesIgnoreSecurity(com.atlassian.crowd.embedded.api.User loggedInUser,
                                                    com.atlassian.crowd.embedded.api.User user)
                                             throws SearchException
Description copied from interface: UserUtil
Returns number of issues assigned to user

Specified by:
getNumberOfAssignedIssuesIgnoreSecurity in interface UserUtil
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

getNumberOfAssignedIssuesIgnoreSecurity

public long getNumberOfAssignedIssuesIgnoreSecurity(ApplicationUser loggedInUser,
                                                    ApplicationUser user)
                                             throws SearchException
Description copied from interface: UserUtil
Returns number of issues assigned to user

Specified by:
getNumberOfAssignedIssuesIgnoreSecurity in interface UserUtil
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

getComponentsUserLeads

public Collection<ProjectComponent> getComponentsUserLeads(com.atlassian.crowd.embedded.api.User user)
Description copied from interface: UserUtil
Retrieve a collection of ProjectComponents - where the lead of each component is the specified user.

Specified by:
getComponentsUserLeads in interface UserUtil
Parameters:
user - User leading components
Returns:
Collection of project components

getComponentsUserLeads

public Collection<ProjectComponent> getComponentsUserLeads(ApplicationUser user)
Description copied from interface: UserUtil
Retrieve a collection of ProjectComponents - where the lead of each component is the specified user.

Specified by:
getComponentsUserLeads in interface UserUtil
Parameters:
user - User leading components
Returns:
Collection of project components

getProjectsLeadBy

public Collection<Project> getProjectsLeadBy(com.atlassian.crowd.embedded.api.User user)
Description copied from interface: UserUtil
Returns all the projects that leadUser is the project lead for.

Specified by:
getProjectsLeadBy in interface UserUtil
Parameters:
user - the user in play
Returns:
A collection of project GenericValues

getProjectsLeadBy

public Collection<Project> getProjectsLeadBy(ApplicationUser user)
Description copied from interface: UserUtil
Returns all the projects that leadUser is the project lead for.

Specified by:
getProjectsLeadBy in interface UserUtil
Parameters:
user - the user in play
Returns:
A collection of project GenericValues

isNonSysAdminAttemptingToDeleteSysAdmin

public boolean isNonSysAdminAttemptingToDeleteSysAdmin(com.atlassian.crowd.embedded.api.User loggedInUser,
                                                       com.atlassian.crowd.embedded.api.User user)
Description copied from interface: UserUtil
Checking if user without SYSTEM_ADMIN rights tries to remove user with SYSTEM_ADMIN rights.

Specified by:
isNonSysAdminAttemptingToDeleteSysAdmin in interface UserUtil
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

isNonSysAdminAttemptingToDeleteSysAdmin

public boolean isNonSysAdminAttemptingToDeleteSysAdmin(ApplicationUser loggedInUser,
                                                       ApplicationUser user)
Description copied from interface: UserUtil
Checking if user without SYSTEM_ADMIN rights tries to remove user with SYSTEM_ADMIN rights.

Specified by:
isNonSysAdminAttemptingToDeleteSysAdmin in interface UserUtil
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

addUserToGroup

public void addUserToGroup(com.atlassian.crowd.embedded.api.Group group,
                           com.atlassian.crowd.embedded.api.User userToAdd)
                    throws PermissionException,
                           AddException
Description copied from interface: UserUtil
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.

Specified by:
addUserToGroup in interface UserUtil
Parameters:
group - the group to add the user to.
userToAdd - the user to add to the group.
Throws:
PermissionException
AddException

addUserToGroups

public void addUserToGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups,
                            com.atlassian.crowd.embedded.api.User userToAdd)
                     throws PermissionException,
                            AddException
Description copied from interface: UserUtil
This is used to add a user to many groups at once.

Specified by:
addUserToGroups in interface UserUtil
Parameters:
groups - a list containing the groups to add the user to.
userToAdd - the user to add to the group.
Throws:
PermissionException
AddException

removeUserFromGroup

public void removeUserFromGroup(com.atlassian.crowd.embedded.api.Group group,
                                com.atlassian.crowd.embedded.api.User userToRemove)
                         throws PermissionException,
                                RemoveException
Description copied from interface: UserUtil
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.

Specified by:
removeUserFromGroup in interface UserUtil
Parameters:
group - the group to add the user to.
userToRemove - the user to add to the group.
Throws:
PermissionException
RemoveException

removeUserFromGroups

public void removeUserFromGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups,
                                 com.atlassian.crowd.embedded.api.User userToRemove)
                          throws PermissionException,
                                 RemoveException
Description copied from interface: UserUtil
This is used to remove a user from many groups at once.

Specified by:
removeUserFromGroups in interface UserUtil
Parameters:
groups - a list containing the groups to add the user to.
userToRemove - the user to add to the group.
Throws:
PermissionException
RemoveException

generatePasswordResetToken

public UserUtil.PasswordResetToken generatePasswordResetToken(com.atlassian.crowd.embedded.api.User user)
Description copied from interface: UserUtil
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.

Specified by:
generatePasswordResetToken in interface UserUtil
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(com.atlassian.crowd.embedded.api.User user,
                                                                        String token)
Description copied from interface: UserUtil
This can be called to validate a token against the user.

Specified by:
validatePasswordResetToken in interface UserUtil
Parameters:
user - the user in play
token - the token they provided
Returns:
a Validation object that describes how the option went

changePassword

public void changePassword(com.atlassian.crowd.embedded.api.User user,
                           String newPassword)
                    throws PermissionException
Description copied from interface: UserUtil
Can be called to set the password for a user. This will delete any password request tokens associated with that user

Specified by:
changePassword in interface UserUtil
Parameters:
user - the user in play
newPassword - their new password
Throws:
PermissionException

getActiveUserCount

public int getActiveUserCount()
Description copied from interface: UserUtil
Returns the number of users that are currently 'active'. For a user to be active, means that it must belong to a group that has either the JIRA-users, JIRA-administrators or JIRA-Systemadministartors global permission. Implementations of this method should take performance into consideration, and ensure that the value is cached. Use UserUtil.clearActiveUserCount() to clear the cache.

Please note that the calculation will be run if the license does not specify a user limit.

Specified by:
getActiveUserCount in interface UserUtil
Returns:
the active user count
See Also:
Permissions

clearActiveUserCount

public void clearActiveUserCount()
Description copied from interface: UserUtil
Clears the cache of the active user count so that it can be recalculated. This method should be used when performing operations that will modify the number of active users in the system.

Specified by:
clearActiveUserCount in interface UserUtil

hasExceededUserLimit

public boolean hasExceededUserLimit()
Description copied from interface: UserUtil
Returns true if this JIRA instance has more active users, than allowed by the license. If the license does not require a user limit, this method will return false immediately.

Specified by:
hasExceededUserLimit in interface UserUtil
Returns:
True if the number of active users is greater than the limit enforced by the license. False otherwise.

canActivateNumberOfUsers

public boolean canActivateNumberOfUsers(int numUsers)
Description copied from interface: UserUtil
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. If the license does not require a user limit, this method will return true immediately.

Specified by:
canActivateNumberOfUsers in interface UserUtil
Parameters:
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!
Returns:
False if the number of active users + the number of users to add is greater than the limit enforced by the license. True otherwise.

canActivateUsers

public boolean canActivateUsers(Collection<String> userNames)
Description copied from interface: UserUtil
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. If a user specified is already active, or cannot be found, they are not counted towards the user limit. If the limit has already been exceeded, but none of the users specified are inactive, the result will still be true, as these users are already active and thus nothing changes. If the license does not require a user limit, this method will return true immediately.

Specified by:
canActivateUsers in interface UserUtil
Parameters:
userNames - the names of the users to add to the JIRA instance. Must not be null!
Returns:
False if the number of active users + the number of users to add is greater than the limit enforced by the license. True otherwise.

getAllUsers

public Set<com.atlassian.crowd.embedded.api.User> getAllUsers()
Description copied from interface: UserUtil
Returns the all users defined in JIRA, regardless of whether they are active or not.

Specified by:
getAllUsers in interface UserUtil
Returns:
the set of all users defined in JIRA

getUsers

public Collection<com.atlassian.crowd.embedded.api.User> getUsers()
Description copied from interface: UserUtil
Returns the all users defined in JIRA, regardless of whether they are active or not.

Specified by:
getUsers in interface UserUtil
Returns:
the set of all users defined in JIRA

getAllApplicationUsers

public Collection<ApplicationUser> getAllApplicationUsers()
Description copied from interface: UserUtil
Returns the all users defined in JIRA, regardless of whether they are active or not.

Specified by:
getAllApplicationUsers in interface UserUtil
Returns:
the set of all users defined in JIRA

getTotalUserCount

public int getTotalUserCount()
Description copied from interface: UserUtil
Returns the total number of users defined in JIRA, regardless of whether they are active or not.

Specified by:
getTotalUserCount in interface UserUtil
Returns:
the total number of users defined in JIRA

getUser

public com.atlassian.crowd.embedded.api.User getUser(String userName)
Get a User by name.

Specified by:
getUser in interface UserUtil
Parameters:
userName - the name of the user
Returns:
a User

getUserByKey

public ApplicationUser getUserByKey(String key)
Description copied from interface: UserUtil
Returns a user based on key.

Specified by:
getUserByKey in interface UserUtil
Parameters:
key - the key of the user
Returns:
the User object, or null if the user cannot be found including null userkey.

getUserByName

public ApplicationUser getUserByName(String username)
Description copied from interface: UserUtil
Returns a user based on user name.

Specified by:
getUserByName in interface UserUtil
Parameters:
username - the user name of the user
Returns:
the User object, or null if the user cannot be found including null userName.

getUserObject

public com.atlassian.crowd.embedded.api.User getUserObject(String userName)
Description copied from interface: UserUtil
Returns a user based on user name.

Specified by:
getUserObject in interface UserUtil
Parameters:
userName - the user name of the user
Returns:
the User object, or null if the user cannot be found including null userName.

userExists

public boolean userExists(String userName)
Description copied from interface: UserUtil
Returns true if the a user exists with the specified userName

Specified by:
userExists in interface UserUtil
Parameters:
userName - the name of the user
Returns:
true if t a user exists with the specified name or false if not

getAdministrators

public Collection<com.atlassian.crowd.embedded.api.User> getAdministrators()
Description copied from interface: UserUtil
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.

Specified by:
getAdministrators in interface UserUtil
Returns:
a list of JIRA admin Users.

getJiraAdministrators

public Collection<com.atlassian.crowd.embedded.api.User> getJiraAdministrators()
Description copied from interface: UserUtil
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.

Specified by:
getJiraAdministrators in interface UserUtil
Returns:
a list of JIRA admin Users.

getSystemAdministrators

public Collection<com.atlassian.crowd.embedded.api.User> getSystemAdministrators()
Description copied from interface: UserUtil
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.

Specified by:
getSystemAdministrators in interface UserUtil
Returns:
a collection of User's that are associated with the Permissions.SYSTEM_ADMIN permission.

getJiraSystemAdministrators

public Collection<com.atlassian.crowd.embedded.api.User> getJiraSystemAdministrators()
Description copied from interface: UserUtil
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.

Specified by:
getJiraSystemAdministrators in interface UserUtil
Returns:
a collection of User's that are associated with the Permissions.SYSTEM_ADMIN permission.

addToJiraUsePermission

public void addToJiraUsePermission(com.atlassian.crowd.embedded.api.User user)
Description copied from interface: UserUtil
Takes the given user and adds him/her to all the groups that grant a user the global JIRA use permission. (see 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)

Specified by:
addToJiraUsePermission in interface UserUtil
Parameters:
user - The user to be added to the USE permission

getDisplayableNameSafely

public String getDisplayableNameSafely(com.atlassian.crowd.embedded.api.User user)
Description copied from interface: UserUtil
Takes the given user and returns a "displayable name" by cautiously checking the different edge cases for users.

Specified by:
getDisplayableNameSafely in interface UserUtil
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.

getDisplayableNameSafely

public String getDisplayableNameSafely(ApplicationUser user)
Description copied from interface: UserUtil
Takes the given user and returns a "displayable name" by cautiously checking the different edge cases for users.

Specified by:
getDisplayableNameSafely in interface UserUtil
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<com.atlassian.crowd.embedded.api.User> getAllUsersInGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups)
Description copied from interface: UserUtil
Returns a collection of User objects that are found within the passed in collection of Group objects.

Specified by:
getAllUsersInGroups in interface UserUtil
Parameters:
groups - a collection of Group objects
Returns:
the set of users that are in the groups, sorted in UserCachingComparator order

getUsersInGroups

public SortedSet<com.atlassian.crowd.embedded.api.User> getUsersInGroups(Collection<com.atlassian.crowd.embedded.api.Group> groups)
Description copied from interface: UserUtil
Returns a collection of 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.

Specified by:
getUsersInGroups in interface UserUtil
Parameters:
groups - a collection of Group objects
Returns:
the set of users that are in the groups, sorted in UserCachingComparator order

getAllUsersInGroupNames

public SortedSet<com.atlassian.crowd.embedded.api.User> getAllUsersInGroupNames(Collection<String> groupNames)
Description copied from interface: UserUtil
Returns a collection of 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.

Specified by:
getAllUsersInGroupNames in interface UserUtil
Parameters:
groupNames - a collection of group name strings
Returns:
the set of users that are in the named groups, sorted in UserCachingComparator order

getAllUsersInGroupNamesUnsorted

public Set<com.atlassian.crowd.embedded.api.User> getAllUsersInGroupNamesUnsorted(Collection<String> groupNames)
Description copied from interface: UserUtil
Returns a collection of User objects that belong to any of the passed in collection of group names.

Specified by:
getAllUsersInGroupNamesUnsorted in interface UserUtil
Parameters:
groupNames - a collection of group name strings
Returns:
the set of users that are in the named groups

getUsersInGroupNames

public SortedSet<com.atlassian.crowd.embedded.api.User> getUsersInGroupNames(Collection<String> groupNames)
Description copied from interface: UserUtil
Returns a collection of 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.

Specified by:
getUsersInGroupNames in interface UserUtil
Parameters:
groupNames - a collection of group name strings
Returns:
the set of users that are in the named groups.

getGroupsForUser

public SortedSet<com.atlassian.crowd.embedded.api.Group> getGroupsForUser(String userName)
Description copied from interface: UserUtil
Returns a collection of Group objects that the user belongs to.

Specified by:
getGroupsForUser in interface UserUtil
Parameters:
userName - A User name
Returns:
the set of groups that the user belongs to

getGroupNamesForUser

public SortedSet<String> getGroupNamesForUser(String userName)
Description copied from interface: UserUtil
Returns a collection of the names of the groups that the user belongs to.

Specified by:
getGroupNamesForUser in interface UserUtil
Parameters:
userName - A User name
Returns:
the set of groups that the user belongs to

getGroup

public com.atlassian.crowd.embedded.api.Group getGroup(String groupName)
Get a Group by name.

Specified by:
getGroup in interface UserUtil
Parameters:
groupName - the name of the group
Returns:
a Group

getGroupObject

public com.atlassian.crowd.embedded.api.Group getGroupObject(@Nullable
                                                             String groupName)
Description copied from interface: UserUtil
Returns a Group based on user name.

WARNING: This method will be changed in the future to return a Crowd Group object. Since v4.3.

Specified by:
getGroupObject in interface UserUtil
Parameters:
groupName - the user name of the group
Returns:
the Group object, or null if the user cannot be found including null groupName.


Copyright © 2002-2014 Atlassian. All Rights Reserved.