public class

DefaultUserManager

extends Object
implements UserManager
java.lang.Object
   ↳ com.atlassian.jira.user.util.DefaultUserManager

Summary

Public Constructors
DefaultUserManager(CrowdService crowdService, CrowdDirectoryService crowdDirectoryService, DirectoryManager directoryManager)
Public Methods
boolean canDirectoryUpdateUserPassword(Directory directory)
Checks if the given directory is able to update user passwords.
boolean canUpdateGroupMembershipForUser(User user)
Test if this user's group membership can be updated, i.e.
boolean canUpdateUser(User user)
Test if this user can be updated, i.e.
boolean canUpdateUserPassword(User user)
Test if this user's password can be updated, i.e.
User findUserInDirectory(String userName, Long directoryId)
Returns a User based on user name and directoryId
Set<Group> getAllGroups()
Returns all groups defined in JIRA.
Set<User> getAllUsers()
Returns all users defined in JIRA, regardless of whether they are active or not.
Directory getDirectory(Long directoryId)
Group getGroup(String groupName)
Returns a Group based on user name.
Group getGroupObject(String groupName)
Returns a Group based on user name.
Collection<Group> getGroups()
Returns all groups defined in JIRA.
int getTotalUserCount()
Returns the total number of users defined in JIRA, regardless of whether they are active or not.
User getUser(String userName)
Returns a User based on user name.
ApplicationUser getUserByKey(String userKey)
Returns an ApplicationUser based on user key.
ApplicationUser getUserByName(String userName)
Returns an ApplicationUser based on user name.
User getUserEvenWhenUnknown(String userName)
Returns a User based on user name.
User getUserObject(String userName)
Returns a User based on user name.
Collection<User> getUsers()
Returns all users defined in JIRA, regardless of whether they are active or not.
List<Directory> getWritableDirectories()
Returns an ordered list of directories that have "read-write" permission.
boolean hasGroupWritableDirectory()
Returns true if any of the directories have permission to update groups.
boolean hasPasswordWritableDirectory()
Returns true if any of the directories have permission to update user passwords, false if otherwise.
boolean hasWritableDirectory()
Returns true if at least one User Directory has "read-write" permission.
void updateUser(User user)
Updates the User.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.user.util.UserManager

Public Constructors

public DefaultUserManager (CrowdService crowdService, CrowdDirectoryService crowdDirectoryService, DirectoryManager directoryManager)

Public Methods

public boolean canDirectoryUpdateUserPassword (Directory directory)

Checks if the given directory is able to update user passwords.

Parameters
directory the Directory
Returns
  • true if the directory can update user passwords, false if otherwise.

public boolean canUpdateGroupMembershipForUser (User user)

Test if this user's group membership can be updated, i.e. is in a writable directory or a directory with Local Group support. This relies upon the local directory configuration and does not guarantee that the actual remote directory, e.g. the remote LDAP directory, will actually allow the user membership to be updated.

Parameters
user The user to update.
Returns
  • true if the user can be updated.

public boolean canUpdateUser (User user)

Test if this user can be updated, i.e. is in a writable directory. This relies upon the local directory configuration and does not guarantee that the actual remote directory, e.g. the remote LDAP directory, will actually allow the user to be updated.

If the "External user management" setting is on, then you cannot update the user.

Parameters
user The user to update.
Returns
  • true if the user can be updated.

public boolean canUpdateUserPassword (User user)

Test if this user's password can be updated, i.e. is in a writable directory which is not a Delegated LDAP directory. This relies upon the local directory configuration and does not guarantee that the actual remote directory, e.g. the remote LDAP directory, will actually allow the user to be updated.

If the "External user management", or "External password management" setting is on, then you cannot update the password.

Parameters
user The user to update.
Returns
  • true if the user's password can be updated.

public User findUserInDirectory (String userName, Long directoryId)

Returns a User based on user name and directoryId

Parameters
userName the user name of the user
directoryId the Directory to look in
Returns
  • the User object, or null if the user cannot be found including null userName.

public Set<Group> getAllGroups ()

Returns all groups defined in JIRA.

Warning: previous incarnations of this method returned com.opensymphony.user.User. This class has now been removed from the JIRA API, meaning that the 5.0 version is not binary or source compatible with earlier versions.

Returns
  • the set of all groups

public Set<User> getAllUsers ()

Returns all users defined in JIRA, regardless of whether they are active or not.

Warning: previous incarnations of this method returned com.opensymphony.user.User. This class has now been removed from the JIRA API, meaning that the 5.0 version is not binary or source compatible with earlier versions.

Returns
  • the set of all users

public Directory getDirectory (Long directoryId)

public Group getGroup (String groupName)

Returns a Group based on user name.

Warning: previous incarnations of this method returned com.opensymphony.user.User. This class has now been removed from the JIRA API, meaning that the 5.0 version is not binary or source compatible with earlier versions.

Parameters
groupName the user name of the group
Returns
  • the Group object, or null if the user cannot be found including null groupName.

public Group getGroupObject (String groupName)

Returns a Group based on user name.

Legacy synonym for getGroup(String).

Parameters
groupName the user name of the group
Returns
  • the Group object, or null if the user cannot be found including null groupName.

public Collection<Group> getGroups ()

Returns all groups defined in JIRA.

Legacy synonym for getAllGroups().

Returns
  • the set of all groups

public int getTotalUserCount ()

Returns the total number of users defined in JIRA, regardless of whether they are active or not.

Returns
  • the total number of users defined in JIRA

public User getUser (String userName)

Returns a User based on user name.

Warning: previous incarnations of this method returned com.opensymphony.user.User. This class has now been removed from the JIRA API, meaning that the 5.0 version is not binary or source compatible with earlier versions.

Parameters
userName the user name of the user
Returns
  • the User object, or null if the user cannot be found including null userName.

public ApplicationUser getUserByKey (String userKey)

Returns an ApplicationUser based on user key.

If a null key is passed, then null is returned, but it is guaranteed to return a non-null ApplicationUser in all other cases.
If the key is not null, but the user is not found then a proxy unknown immutable ApplicationUser object is returned.

Parameters
userKey the key of the user
Returns
  • the ApplicationUser object, or proxy unknown immutable ApplicationUser object (null iff the key is null).

public ApplicationUser getUserByName (String userName)

Returns an ApplicationUser based on user name.

If a null username is passed, then null is returned, but it is guaranteed to return a non-null ApplicationUser in all other cases.
If the username is not null, but the user is not found then a proxy unknown immutable ApplicationUser object is returned.

Parameters
userName the user name of the user
Returns
  • the ApplicationUser object, or proxy unknown immutable ApplicationUser object (null iff the username is null).

public User getUserEvenWhenUnknown (String userName)

Returns a User based on user name.

If a null username is passed, then a null User object is returned, but it is guaranteed to return a non-null User in all other cases.
If the username is not null, but the User is not found then a proxy unknown immutable User object is returned.

Parameters
userName the user name of the user
Returns
  • the User object, or proxy unknown immutable User object (null iff the username is null).

public User getUserObject (String userName)

Returns a User based on user name.

Legacy synonym for getUser(String).

Parameters
userName the user name of the user
Returns
  • the User object, or null if the user cannot be found including null userName.

public Collection<User> getUsers ()

Returns all users defined in JIRA, regardless of whether they are active or not.

Legacy synonym for getAllUsers().

Returns
  • the collection of all users

public List<Directory> getWritableDirectories ()

Returns an ordered list of directories that have "read-write" permission. ie those directories that we can add a user to.

Returns
  • an ordered list of directories that have "read-write" permission.

public boolean hasGroupWritableDirectory ()

Returns true if any of the directories have permission to update groups.

Note that this will not always return the same results as hasWritableDirectory() because you can set "Read-Only with Local Groups" to LDAP directories. These directories are generally read-only but you can create local gropus and assign users to them.

Returns
  • true if any of the directories have permission to update groups, false if otherwise.

public boolean hasPasswordWritableDirectory ()

Returns true if any of the directories have permission to update user passwords, false if otherwise.

Note that this is not quite the same as hasWritableDirectory() because of "Internal with LDAP Authentication" directories. These directories are generally read-write but passwords are read-only.

Returns
  • true if any of the directories have permission to update user passwords, false if otherwise.

public boolean hasWritableDirectory ()

Returns true if at least one User Directory has "read-write" permission.

This is equivalent to:
  getWritableDirectories().size() > 0

Returns
  • true if at least one User Directory has "read-write" permission.

public void updateUser (User user)

Updates the User. The user must have non-null names and email address.

Parameters
user The user to update.