Class DefaultUserManager
- All Implemented Interfaces:
UserManager
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.jira.user.util.UserManager
UserManager.UserState -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final long -
Constructor Summary
ConstructorsConstructorDescriptionDefaultUserManager(com.atlassian.crowd.embedded.api.CrowdService crowdService, com.atlassian.crowd.embedded.api.CrowdDirectoryService crowdDirectoryService, com.atlassian.crowd.manager.directory.DirectoryManager directoryManager, UserKeyStore userKeyStore, com.atlassian.crowd.manager.application.ApplicationManager applicationManager, ApplicationProperties applicationProperties, ExtendedUserDao userDao, DuplicatedUsersService duplicatedUsersService) -
Method Summary
Modifier and TypeMethodDescriptionbooleancanDirectoryUpdateUserPassword(com.atlassian.crowd.embedded.api.Directory directory) Checks if the given directory is able to update user passwords.booleancanRenameUser(ApplicationUser user) Test if this user can be renamed.booleanTest if this user's group membership can be updated, i.e.booleancanUpdateUser(ApplicationUser user) Test if this user can be updated, i.e.booleanTest if this user's password can be updated, i.e.createUser(UserDetails userData) Creates a user in the specified directory (userDirectoryId).findUserInDirectory(String userName, Long directoryId) Returns aUserbased on user name and directoryIdGenerates a random password that can be used when the admin has entered a blank password.Returns all users defined in JIRA, regardless of whether they are active or not.Optional<com.atlassian.crowd.embedded.api.Directory>Get theDirectoryin which users will be created by defaultcom.atlassian.crowd.embedded.api.DirectorygetDirectory(Long directoryId) This method returns a mapping of duplicated users to the directories they have their accounts in together with information on whether the accounts are active.com.atlassian.crowd.embedded.api.GroupReturns aGroupbased on user name.com.atlassian.crowd.embedded.api.GroupgetGroupObject(String groupName) Returns aGroupbased on user name.intReturns the total number of users defined in JIRA, regardless of whether they are active or not.getUserById(Long id) Returns a user based in id.getUserByKey(String key) Returns anApplicationUserbased on user key.getUserByKeyEvenWhenUnknown(String userKey) Returns anApplicationUserbased on user key.getUserByName(String username) Returns anApplicationUserbased on user name.getUserByNameEvenWhenUnknown(String userName) Returns anApplicationUserbased on user name.Returns an identity of the user with the specified id.Returns an identity of the user with the specified key.getUserIdentityByUsername(String username) Returns an identity of the user with the specified username.getUserState(ApplicationUser user) This convenience method is equivalent togetUserState(user.getUsername(), user.getDirectoryId())except that anulluser is permitted and returnsUserManager.UserState.INVALID_USER.getUserState(String username, long queryDirectoryId) Checks for the existence of this user across all directories to determine whether or not the user exists in the specified directory and whether or not it is shadowing or shadowed by a user with the same username in another active user directory.List<com.atlassian.crowd.embedded.api.Directory>Returns an ordered list of directories that have "read-write" permission.booleanReturns true if any of the directories have permission to update groups.booleanReturns true if any of the directories have permission to update user passwords, false if otherwise.booleanReturns true if at least one User Directory has "read-write" permission.booleanisUserDeleted(ApplicationUser user) Checks if given user is deleted user.booleanChecks if given user is existing uservoidupdateUser(ApplicationUser user) Updates theApplicationUser.booleanCheck if this user is allowed to update their own user details.
-
Field Details
-
UNKNOWN_USER_ID
public static final long UNKNOWN_USER_ID- See Also:
-
UNKNOWN_DIRECTORY_ID
public static final long UNKNOWN_DIRECTORY_ID- See Also:
-
-
Constructor Details
-
DefaultUserManager
public DefaultUserManager(com.atlassian.crowd.embedded.api.CrowdService crowdService, com.atlassian.crowd.embedded.api.CrowdDirectoryService crowdDirectoryService, com.atlassian.crowd.manager.directory.DirectoryManager directoryManager, UserKeyStore userKeyStore, com.atlassian.crowd.manager.application.ApplicationManager applicationManager, ApplicationProperties applicationProperties, ExtendedUserDao userDao, DuplicatedUsersService duplicatedUsersService)
-
-
Method Details
-
getTotalUserCount
public int getTotalUserCount()Description copied from interface:UserManagerReturns the total number of users defined in JIRA, regardless of whether they are active or not.- Specified by:
getTotalUserCountin interfaceUserManager- Returns:
- the total number of users defined in JIRA
-
getAllApplicationUsers
Description copied from interface:UserManagerReturns all users defined in JIRA, regardless of whether they are active or not.- Specified by:
getAllApplicationUsersin interfaceUserManager- Returns:
- the set of all users
-
findUserInDirectory
Description copied from interface:UserManagerReturns aUserbased on user name and directoryId- Specified by:
findUserInDirectoryin interfaceUserManager- Parameters:
userName- the user name of the userdirectoryId- the Directory to look in- Returns:
- the User object, or null if the user cannot be found including null userName.
-
getUserById
Description copied from interface:UserManagerReturns a user based in id.- Specified by:
getUserByIdin interfaceUserManager- Parameters:
id- user id- Returns:
- user if found or none
-
getUserByKey
Description copied from interface:UserManagerReturns anApplicationUserbased on user key.- Specified by:
getUserByKeyin interfaceUserManager- Parameters:
key- the key of the user- Returns:
- the ApplicationUser object
-
getUserByName
Description copied from interface:UserManagerReturns anApplicationUserbased on user name.- Specified by:
getUserByNamein interfaceUserManager- Parameters:
username- the user name of the user- Returns:
- the ApplicationUser object
-
getUserByKeyEvenWhenUnknown
Description copied from interface:UserManagerReturns anApplicationUserbased on user key.If you want to check if given user is known user - please use
UserManager.isUserExisting(com.atlassian.jira.user.ApplicationUser)- Specified by:
getUserByKeyEvenWhenUnknownin interfaceUserManager- Parameters:
userKey- the key of the user- Returns:
- the ApplicationUser object, or proxy unknown immutable ApplicationUser object (null if the key is null).
-
getUserByNameEvenWhenUnknown
Description copied from interface:UserManagerReturns anApplicationUserbased on user name.If you want to check if given user is known user - please use
UserManager.isUserExisting(com.atlassian.jira.user.ApplicationUser)- Specified by:
getUserByNameEvenWhenUnknownin interfaceUserManager- Parameters:
userName- the user name of the user- Returns:
- the ApplicationUser object, or proxy unknown immutable ApplicationUser object (null iff the username is null).
-
canUpdateUser
Description copied from interface:UserManagerTest 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.- Specified by:
canUpdateUserin interfaceUserManager- Parameters:
user- The user to update.- Returns:
- true if the user can be updated.
-
userCanUpdateOwnDetails
Description copied from interface:UserManagerCheck if this user is allowed to update their own user details.Returns true if the given user is in a read-write directory AND the "External user management" setting is off.
- Specified by:
userCanUpdateOwnDetailsin interfaceUserManager- Parameters:
user- The user- Returns:
- true if the given user is in a read-write directory AND the "External user management" setting is off.
-
canRenameUser
Description copied from interface:UserManagerTest if this user can be renamed. In addition to the constraints ofUserManager.canUpdateUser(ApplicationUser), renaming a user is only allowed when:- The user is in either an
INTERNALorDELEGATINGuser directory; AND - Either JIRA is not configured as a crowd server, or
APKeys.JIRA_OPTION_USER_CROWD_ALLOW_RENAMEis enabled to bypass this check.
- Specified by:
canRenameUserin interfaceUserManager- Parameters:
user- The user to rename.- Returns:
- true if the user is not
nulland can be renamed.
- The user is in either an
-
updateUser
Description copied from interface:UserManagerUpdates theApplicationUser. The user must have non-null names and email address. If the user's name does not match the name that is currently associated with thekey, then this is implicitly treated as a request to rename the user.- Specified by:
updateUserin interfaceUserManager- Parameters:
user- The user to update.
-
canUpdateUserPassword
Description copied from interface:UserManagerTest 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.
- Specified by:
canUpdateUserPasswordin interfaceUserManager- Parameters:
user- The user to update.- Returns:
- true if the user is not
nulland the user's password can be updated.
-
canUpdateGroupMembershipForUser
Description copied from interface:UserManagerTest 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.- Specified by:
canUpdateGroupMembershipForUserin interfaceUserManager- Parameters:
user- The user to update.- Returns:
- true if the user is not
nulland can be updated.
-
getGroup
Description copied from interface:UserManagerReturns aGroupbased 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.- Specified by:
getGroupin interfaceUserManager- Parameters:
groupName- the user name of the group- Returns:
- the Group object, or null if the group cannot be found including null groupName.
-
getGroupObject
Description copied from interface:UserManagerReturns aGroupbased on user name.Legacy synonym for
UserManager.getGroup(String).- Specified by:
getGroupObjectin interfaceUserManager- Parameters:
groupName- the user name of the group- Returns:
- the Group object, or null if the group cannot be found including null groupName.
- See Also:
-
getWritableDirectories
Description copied from interface:UserManagerReturns an ordered list of directories that have "read-write" permission. ie those directories that we can add a user to.- Specified by:
getWritableDirectoriesin interfaceUserManager- Returns:
- an ordered list of directories that have "read-write" permission.
- See Also:
-
getDefaultCreateDirectory
Description copied from interface:UserManagerGet theDirectoryin which users will be created by default- Specified by:
getDefaultCreateDirectoryin interfaceUserManager- Returns:
DirectoryorOption.none()in case there is no writable directories
-
hasWritableDirectory
public boolean hasWritableDirectory()Description copied from interface:UserManagerReturns true if at least one User Directory has "read-write" permission.This is equivalent to:
getWritableDirectories().size() > 0- Specified by:
hasWritableDirectoryin interfaceUserManager- Returns:
- true if at least one User Directory has "read-write" permission.
- See Also:
-
hasPasswordWritableDirectory
public boolean hasPasswordWritableDirectory()Description copied from interface:UserManagerReturns true if any of the directories have permission to update user passwords, false if otherwise.Note that this is not quite the same as
UserManager.hasWritableDirectory()because of "Internal with LDAP Authentication" directories. These directories are generally read-write but passwords are read-only.- Specified by:
hasPasswordWritableDirectoryin interfaceUserManager- Returns:
- true if any of the directories have permission to update user passwords, false if otherwise.
- See Also:
-
hasGroupWritableDirectory
public boolean hasGroupWritableDirectory()Description copied from interface:UserManagerReturns true if any of the directories have permission to update groups.Note that this will not always return the same results as
UserManager.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.- Specified by:
hasGroupWritableDirectoryin interfaceUserManager- Returns:
- true if any of the directories have permission to update groups, false if otherwise.
- See Also:
-
getDirectory
- Specified by:
getDirectoryin interfaceUserManager
-
isUserExisting
Description copied from interface:UserManagerChecks if given user is existing user- Specified by:
isUserExistingin interfaceUserManager- Parameters:
user- possible existing user object - i.e. received fromUserManager.getUserByKeyEvenWhenUnknown(String)orUserManager.getUserByNameEvenWhenUnknown(String)- Returns:
trueif given user is real user,falseotherwise (also when given object isnull)- See Also:
-
isUserDeleted
Description copied from interface:UserManagerChecks if given user is deleted user. Deleted user exists in jira app_users DB table (has user key and username) but does not exist in crowd (no user data eg. Full name, email etc.).- Specified by:
isUserDeletedin interfaceUserManager- Parameters:
user- possible deleted user object - i.e. received fromUserManager.getUserByKeyEvenWhenUnknown(String)orUserManager.getUserByNameEvenWhenUnknown(String)- Returns:
trueif given user is user existing in app_users DB table but does not exist in crowd,falseotherwise (also when given object isnull)- See Also:
-
generateRandomPassword
Description copied from interface:UserManagerGenerates a random password that can be used when the admin 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.
- Specified by:
generateRandomPasswordin interfaceUserManager- Returns:
- a random password.
-
canDirectoryUpdateUserPassword
public boolean canDirectoryUpdateUserPassword(com.atlassian.crowd.embedded.api.Directory directory) Description copied from interface:UserManagerChecks if the given directory is able to update user passwords.- Specified by:
canDirectoryUpdateUserPasswordin interfaceUserManager- Parameters:
directory- the Directory- Returns:
- true if the directory can update user passwords, false if otherwise.
-
getUserState
Description copied from interface:UserManagerThis convenience method is equivalent togetUserState(user.getUsername(), user.getDirectoryId())except that anulluser is permitted and returnsUserManager.UserState.INVALID_USER.- Specified by:
getUserStatein interfaceUserManager- Parameters:
user- the user to check- Returns:
- the shadowing state of the specified user
-
getUserState
Description copied from interface:UserManagerChecks for the existence of this user across all directories to determine whether or not the user exists in the specified directory and whether or not it is shadowing or shadowed by a user with the same username in another active user directory.- Specified by:
getUserStatein interfaceUserManager- Parameters:
username- the username to checkqueryDirectoryId- the directory ID of the user directory that the user came from- Returns:
- the shadowing state of the specified user
-
createUser
@Nonnull public ApplicationUser createUser(@Nonnull UserDetails userData) throws CreateException, PermissionException Description copied from interface:UserManagerCreates a user in the specified directory (userDirectoryId). If the directory isOption.none(), the user is created in the default directory (usually an Embedded Crowd internal directory).- Specified by:
createUserin interfaceUserManager- Parameters:
userData- the user request containing user details.- Returns:
- the newly created user.
- Throws:
CreateException- unable to create user.PermissionException- unable to create user due to permission error.
-
getUserIdentityById
Description copied from interface:UserManagerReturns an identity of the user with the specified id.- Specified by:
getUserIdentityByIdin interfaceUserManager- Parameters:
id- user id- Returns:
- user identity or none if no user with the specified key exists.
-
getUserIdentityByKey
Description copied from interface:UserManagerReturns an identity of the user with the specified key.- Specified by:
getUserIdentityByKeyin interfaceUserManager- Parameters:
key- user key- Returns:
- user identity or none if no user with the specified key exists.
-
getUserIdentityByUsername
Description copied from interface:UserManagerReturns an identity of the user with the specified username.- Specified by:
getUserIdentityByUsernamein interfaceUserManager- Parameters:
username- user name- Returns:
- user identity or none if no user with the specified username exists.
-
getDuplicatedUserMapping
Description copied from interface:UserManagerThis method returns a mapping of duplicated users to the directories they have their accounts in together with information on whether the accounts are active. Duplicated means that the user has an account in more than one directory and either more than one account is active or the only active account does not belong to the directory with the highest priority.- Specified by:
getDuplicatedUserMappingin interfaceUserManager- Returns:
- map of users who have duplicated accounts and their directories.
-