@PublicApi
public interface UserManager
Modifier and Type | Interface and Description |
---|---|
static class |
UserManager.UserState
The current state of a user with regard to the same username existing in other
user directories.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDirectoryUpdateUserPassword(com.atlassian.crowd.embedded.api.Directory directory)
Checks if the given directory is able to update user passwords.
|
boolean |
canRenameUser(ApplicationUser user)
Test if this user can be renamed.
|
boolean |
canUpdateGroupMembershipForUser(ApplicationUser user)
Test if this user's group membership can be updated, i.e.
|
boolean |
canUpdateUser(ApplicationUser user)
Test if this user can be updated, i.e.
|
boolean |
canUpdateUserPassword(ApplicationUser user)
Test if this user's password can be updated, i.e.
|
ApplicationUser |
createUser(UserDetails userData)
Creates a user in the specified directory (userDirectoryId).
|
ApplicationUser |
findUserInDirectory(String userName,
Long directoryId)
Returns a
User based on user name and directoryId |
String |
generateRandomPassword()
Generates a random password that can be used when the admin has entered a blank password.
|
Collection<ApplicationUser> |
getAllApplicationUsers()
Deprecated.
Since v7.0. Only retrieve the users you really need. See
UserSearchService |
Set<com.atlassian.crowd.embedded.api.Group> |
getAllGroups()
Deprecated.
Since v7.0. Only retrieve the groups you really need. See
GroupPickerSearchService |
Set<ApplicationUser> |
getAllUsers()
Deprecated.
Since v7.0. Only retrieve the users you really need. See
UserSearchService |
Optional<com.atlassian.crowd.embedded.api.Directory> |
getDefaultCreateDirectory()
Get the
Directory in which users will be created by default |
com.atlassian.crowd.embedded.api.Directory |
getDirectory(Long directoryId) |
com.atlassian.crowd.embedded.api.Group |
getGroup(String groupName)
Returns a
Group based on user name. |
com.atlassian.crowd.embedded.api.Group |
getGroupObject(String groupName)
Returns a
Group based on user name. |
Collection<com.atlassian.crowd.embedded.api.Group> |
getGroups()
Deprecated.
Since v7.0. Only retrieve the users you really need. See
GroupPickerSearchService |
int |
getTotalUserCount()
Returns the total number of users defined in JIRA, regardless of whether they are active or not.
|
ApplicationUser |
getUser(String userName)
Deprecated.
Use
getUserByKey(String) or getUserByName(String) instead. Since v6.0. |
Optional<ApplicationUser> |
getUserById(Long id)
Returns a user based in id.
|
ApplicationUser |
getUserByKey(String userKey)
Returns an
ApplicationUser based on user key. |
ApplicationUser |
getUserByKeyEvenWhenUnknown(String userKey)
Returns an
ApplicationUser based on user key. |
ApplicationUser |
getUserByName(String userName)
Returns an
ApplicationUser based on user name. |
ApplicationUser |
getUserByNameEvenWhenUnknown(String userName)
Returns an
ApplicationUser based on user name. |
ApplicationUser |
getUserEvenWhenUnknown(String userName)
Deprecated.
Use
getUserByKeyEvenWhenUnknown(String) or getUserByNameEvenWhenUnknown(String) instead. Since v6.0. |
Optional<UserIdentity> |
getUserIdentityById(Long id)
Returns an identity of the user with the specified id.
|
Optional<UserIdentity> |
getUserIdentityByKey(String key)
Returns an identity of the user with the specified key.
|
Optional<UserIdentity> |
getUserIdentityByUsername(String username)
Returns an identity of the user with the specified username.
|
ApplicationUser |
getUserObject(String userName)
Deprecated.
Use
getUserByKey(String) or getUserByName(String) instead. Since v6.0. |
Collection<ApplicationUser> |
getUsers()
Deprecated.
Since v7.0. Only retrieve the users you really need. See
UserSearchService |
UserManager.UserState |
getUserState(ApplicationUser user)
This convenience method is equivalent to
getUserState(user.getUsername(), user.getDirectoryId())
except that a null user is permitted and returns UserManager.UserState.INVALID_USER . |
UserManager.UserState |
getUserState(String username,
long directoryId)
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> |
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.
|
boolean |
isUserExisting(ApplicationUser user)
Checks if given user is existing user
|
void |
updateUser(ApplicationUser user)
Updates the
ApplicationUser . |
boolean |
userCanUpdateOwnDetails(ApplicationUser user)
Check if this user is allowed to update their own user details.
|
int getTotalUserCount()
@Nonnull @Deprecated Set<ApplicationUser> getAllUsers()
UserSearchService
@Nonnull @Deprecated Collection<ApplicationUser> getUsers()
UserSearchService
Legacy synonym for getAllUsers()
.
getAllUsers()
@Nonnull @Deprecated Collection<ApplicationUser> getAllApplicationUsers()
UserSearchService
ApplicationUser getUser(@Nullable String userName)
getUserByKey(String)
or getUserByName(String)
instead. Since v6.0.User
based on user name.
userName
- the user name of the userApplicationUser getUserObject(@Nullable String userName)
getUserByKey(String)
or getUserByName(String)
instead. Since v6.0.User
based on user name.
userName
- the user name of the userOptional<ApplicationUser> getUserById(Long id)
id
- user id@Nullable ApplicationUser getUserByKey(@Nullable String userKey)
ApplicationUser
based on user key.userKey
- the key of the user@Nullable ApplicationUser getUserByName(@Nullable String userName)
ApplicationUser
based on user name.userName
- the user name of the userIllegalStateException
- if the CrowdService
is able to resolve userName
to a User
, but the
UserKeyService
does not have a key mapped for it.
This is not a valid configuration.@Nullable ApplicationUser getUserByKeyEvenWhenUnknown(@Nullable String userKey)
ApplicationUser
based on user key.
If you want to check if given user is known user - please use isUserExisting(com.atlassian.jira.user.ApplicationUser)
userKey
- the key of the user@Nullable ApplicationUser getUserByNameEvenWhenUnknown(@Nullable String userName)
ApplicationUser
based on user name.
If you want to check if given user is known user - please use isUserExisting(com.atlassian.jira.user.ApplicationUser)
userName
- the user name of the userIllegalStateException
- if the CrowdService
is able to resolve userName
to a User
, but the
UserKeyService
does not have a key mapped for it.
This is not a valid configuration.@Nullable ApplicationUser findUserInDirectory(@Nullable String userName, Long directoryId)
User
based on user name and directoryIduserName
- the user name of the userdirectoryId
- the Directory to look in@Nullable ApplicationUser getUserEvenWhenUnknown(@Nullable String userName)
getUserByKeyEvenWhenUnknown(String)
or getUserByNameEvenWhenUnknown(String)
instead. Since v6.0.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.
userName
- the user name of the userboolean canUpdateUser(@Nonnull ApplicationUser user)
user
- The user to update.@ExperimentalApi boolean userCanUpdateOwnDetails(@Nonnull ApplicationUser user)
Returns true if the given user is in a read-write directory AND the "External user management" setting is off.
user
- The userboolean canRenameUser(@Nullable ApplicationUser user)
canUpdateUser(ApplicationUser)
,
renaming a user is only allowed when:
INTERNAL
or DELEGATING
user directory;
ANDAPKeys.JIRA_OPTION_USER_CROWD_ALLOW_RENAME
is enabled to bypass this check.user
- The user to rename.null
and can be renamed.void updateUser(ApplicationUser user)
ApplicationUser
. 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 the key
, then
this is implicitly treated as a request to rename the user.user
- The user to update.com.atlassian.crowd.exception.runtime.UserNotFoundException
- If the supplied user does not exist in the directory
.com.atlassian.crowd.exception.runtime.OperationFailedException
- If the underlying directory implementation failed to execute the operation.IllegalArgumentException
- If something is wrong with the provided user objectboolean canUpdateUserPassword(@Nullable ApplicationUser user)
If the "External user management", or "External password management" setting is on, then you cannot update the password.
user
- The user to update.null
and the user's password can be updated.boolean canUpdateGroupMembershipForUser(ApplicationUser user)
user
- The user to update.null
and can be updated.@IncompatibleReturnType(since="5.0", was="java.util.Set<com.opensymphony.user.Group>") @Deprecated Set<com.atlassian.crowd.embedded.api.Group> getAllGroups()
GroupPickerSearchService
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.
@Deprecated Collection<com.atlassian.crowd.embedded.api.Group> getGroups()
GroupPickerSearchService
Legacy synonym for getAllGroups()
.
getAllGroups()
@IncompatibleReturnType(since="5.0", was="com.opensymphony.user.User") com.atlassian.crowd.embedded.api.Group getGroup(@Nullable String groupName)
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.
groupName
- the user name of the groupcom.atlassian.crowd.embedded.api.Group getGroupObject(@Nullable String groupName)
Group
based on user name.
Legacy synonym for getGroup(String)
.
groupName
- the user name of the groupgetGroup(String)
@Nonnull List<com.atlassian.crowd.embedded.api.Directory> getWritableDirectories()
hasWritableDirectory()
@Nonnull Optional<com.atlassian.crowd.embedded.api.Directory> getDefaultCreateDirectory()
Directory
in which users will be created by defaultDirectory
or Option.none()
in case there is no writable directoriesboolean hasWritableDirectory()
This is equivalent to:
getWritableDirectories().size() > 0
getWritableDirectories()
,
hasPasswordWritableDirectory()
,
hasGroupWritableDirectory()
boolean hasPasswordWritableDirectory()
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.
hasWritableDirectory()
boolean hasGroupWritableDirectory()
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.
hasWritableDirectory()
boolean canDirectoryUpdateUserPassword(@Nullable com.atlassian.crowd.embedded.api.Directory directory)
directory
- the Directorycom.atlassian.crowd.embedded.api.Directory getDirectory(Long directoryId)
boolean isUserExisting(@Nullable ApplicationUser user)
user
- possible existing user object - i.e. recieved from getUserByKeyEvenWhenUnknown(String)
or getUserByNameEvenWhenUnknown(String)
true
if given user is real user, false
otherwise (also when given object is null
)getUserByKeyEvenWhenUnknown(String)
,
getUserByNameEvenWhenUnknown(String)
@Nonnull String generateRandomPassword()
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.
@ExperimentalApi @Nonnull UserManager.UserState getUserState(@Nonnull String username, long directoryId)
username
- the username to checkdirectoryId
- the directory ID of the user directory that the user came from@ExperimentalApi @Nonnull UserManager.UserState getUserState(@Nullable ApplicationUser user)
getUserState(user.getUsername(), user.getDirectoryId())
except that a null
user is permitted and returns UserManager.UserState.INVALID_USER
.user
- the user to check@Nonnull @ExperimentalApi ApplicationUser createUser(@Nonnull UserDetails userData) throws CreateException, PermissionException
Option.none()
,
the user is created in the default directory (usually an Embedded Crowd internal directory).userData
- the user request containing user details.CreateException
- unable to create user.PermissionException
- unable to create user due to permission error.Optional<UserIdentity> getUserIdentityById(Long id)
id
- user idOptional<UserIdentity> getUserIdentityByKey(String key)
key
- user keyOptional<UserIdentity> getUserIdentityByUsername(String username)
username
- user nameCopyright © 2002-2018 Atlassian. All Rights Reserved.