| com.atlassian.stash.user.UserService |
Provides methods for querying users and managing authentication. This service also offers limited
ability to update the current user.
comments and
pull requests.
Because the Crowd user store is a cache of users managed elsewhere, be they in LDAP, JIRA, etc., it is possible
for users to be deleted from that user store but still exist in the system's secondary user table. Such users are
termed "deleted", and, when retrieved, will only offer a minimal set of data. Generally, after deletion, only a
user's username is still available. Display names, e-mail addresses and other data
are managed by Crowd and are lost when the user is deleted.
In addition to deleted users, Crowd has the concept of an inactive user. These users cannot log into Stash and
may or may not have an associated StashUser. Inactive users are handled consistently as deleted and
both are taken into consideration when determining isActive().
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Attempts to authenticate the specified user given their password.
| |||||||||||
Delete the avatar associated with a user.
| |||||||||||
Retrieves a flag indicating whether the specified group exists.
| |||||||||||
Retrieves a page of groups.
| |||||||||||
Retrieves a page of groups, optionally filtering the returned results to those containing the specified
groupName. | |||||||||||
Retrieves a page of groups, optionally filtering the returned results to those beginning with the specified
groupPrefix. | |||||||||||
Retrieves a page of groups which the specified user is a member of.
| |||||||||||
Retrieves a page of
active users which are members of the specified group. | |||||||||||
Retrieves the current avatar for the specified user at a requested size.
| |||||||||||
This method is deprecated.
in 3.5, this method will be retained in 4.0 with the return type changed to
Set<StashUser>.
The upper bounded wildcard will be removed.
| |||||||||||
This method is deprecated.
in 3.5, this method will be retained in 4.0 with the return type changed to
Set<StashUser>.
The upper bounded wildcard will be removed.
| |||||||||||
Retrieves a flag indicating whether the specified user is a member of the specified group.
| |||||||||||
Retrieves a flag indicating whether the specified user is a member of the specified group.
| |||||||||||
Authenticate as user
username, without checking passwords. | |||||||||||
Clears the
authentication for the current user, logging
them out. | |||||||||||
Updates the specified user's avatar, replacing it with the one contained in the provided
supplier. | |||||||||||
Updates the specified user's avatar, replacing it with the one contained in the provided data URI.
| |||||||||||
Updates the password for the current user.
| |||||||||||
Updates the
display name and e-mail address for the current user. | |||||||||||
Attempts to authenticate the specified user given their password.
| username | the username |
|---|---|
| password | the user's password |
StashUser representing the authenticated user| AuthenticationSystemException | if a failure occurs in Crowd |
|---|---|
| ExpiredPasswordAuthenticationException | if the user's password has expired and must be changed |
| InactiveUserAuthenticationException | if the specified user is inactive |
| IncorrectPasswordAuthenticationException | if the provided password is incorrect |
| NoSuchUserException | if the specified user does not exist or their user details cannot be retrieved |
Delete the avatar associated with a user.
This will revert the avatar of the user in the UI to his/her Gravatar image (if the Gravatar integration is enabled) or to the default user avatar (if the Gravatar integration is disabled)| user | the user whose (local) avatar will be removed |
|---|
Retrieves a flag indicating whether the specified group exists.
| groupName | the group name |
|---|
true if a group with the specified name exists in any directory; otherwise, false
Retrieves a page of groups.
Note: To filter the retrieved groups by name, usefindGroupsByName(String, PageRequest) instead.| pageRequest | defines the page of groups to retrieve |
|---|
nullRetrieves a page of groups, optionally filtering the returned results to those containing the specified
groupName. If the provided groupName is null, this method behaves identically to
findGroups(PageRequest).
| groupName | 0 or more characters to apply as a filter on returned groups |
|---|---|
| pageRequest | defines the page of groups to retrieve |
nullRetrieves a page of groups, optionally filtering the returned results to those beginning with the specified
groupPrefix. If the provided groupPrefix is null, this method behaves identically to
findGroups(PageRequest).
findGroupsByName(String, PageRequest), which will match the specified
name at the beginning of any word boundary in the group. For example, "test-group" will match "group". With this
method, a prefix of "group" will not match "test-group".| groupPrefix | 0 or more characters defining a prefix which returned group names must start with |
|---|---|
| pageRequest | defines the page of groups to retrieve |
nullRetrieves a page of groups which the specified user is a member of. The username provided must match
exactly in order for any results to be returned.
| username | the exact name of the user to retrieve groups for |
|---|---|
| pageRequest | defines the page of groups to retrieve |
nullRetrieve the first active normal user whose username or
e-mail address exactly matches the provided value.
| value | the value to match, first against usernames and then against e-mail addresses |
|---|
null if no matching user
was foundRetrieves a page of active normal users.
findUsersByName(String, PageRequest) instead.| pageRequest | defines the page of users to retrieve |
|---|
nullRetrieves a page of active users which are members of the specified group.
The groupName provided must match exactly in order for any results to be returned.
| groupName | the exact name of the group to retrieve members for |
|---|---|
| pageRequest | defines the page of users to retrieve |
nullRetrieves a page of active normal users, optionally
filtering the returned results to those containing the specified username. If the provided
username is null, this method behaves identically to findUsers(PageRequest).
Otherwise, the username is matched against:
| username | 0 or more characters to apply as a filter on returned users |
|---|---|
| pageRequest | defines the page of users to retrieve |
nullRetrieves the current avatar for the specified user at a requested size. Avatars are square, so the size provided here is used as both height and width for the avatar.
The requested size will be normalised to fall within a well-defined set sizes. The supported sizes are:| user | the user whose avatar should be retrieved |
|---|---|
| size | the desired height and width for the avatar |
| id | the ID of the user to retrieve |
|---|---|
| inactive | true if deleted and inactive users should be returned, false otherwise. |
null if no matching user existsRetrieves a StashUser by its ID.
getUserById(int, boolean) instead if deleted users are desired.
See the class documentation for more details about what "deleted" means in this context.| id | the ID of the user to retrieve |
|---|
null if no matching user existsRetrieves an active StashUser by its username.
getUserByName(String, boolean) instead if
deleted users are desired. See the class documentation for more details about what "deleted" means in this
context.| username | the exact username of the user to retrieve |
|---|
null if no matching user exists or the matching
user has been deleted from the user storeRetrieves a StashUser by its username, optionally returning the user even
if it has been removed from the underlying user store.
| username | the exact username of the user to retrieve |
|---|---|
| inactive | true if deleted and inactive users should be returned, false otherwise. |
null if no matching user exists or the matching
user has been deleted from the user store and deleted users were not requestedRetrieves an active StashUser by its
exact (case-sensitive) slug.
| slug | the exact slug of the user to retrieve |
|---|
null if no matching user exists or the matching
user has been deleted or is inactive
This method is deprecated.
in 3.5, this method will be retained in 4.0 with the return type changed to Set<StashUser>.
The upper bounded wildcard will be removed.
Retrieves a set of active StashUsers by their IDs.
getUsersById(Set, boolean)
instead if deleted users are desired.
See the class documentation for more details about what "deleted" means in this context.| ids | the IDs of the users to retrieve |
|---|
This method is deprecated.
in 3.5, this method will be retained in 4.0 with the return type changed to Set<StashUser>.
The upper bounded wildcard will be removed.
Retrieves a set of StashUsers by their IDs, optionally including users who
have been removed from the underlying user store.
| ids | the IDs of the users to retrieve |
|---|---|
| inactive | true if deleted and inactive users should be returned, false otherwise |
Retrieves a set of StashUsers by their usernames, optionally including users
who have been removed from the underlying user store.
| usernames | the exact usernames of the users to retrieve |
|---|---|
| inactive | true if deleted and inactive users should be returned, false otherwise |
Retrieves a set of active StashUsers by
their usernames.
getUsersByName(Set, boolean) instead if deleted
users are desired. See the class documentation for more details about what "deleted" means in this context.| usernames | the exact usernames of the users to retrieve |
|---|
Retrieves a flag indicating whether the specified user is a member of the specified group. If the user or group
does not exist, false is returned in preference to throwing an exception.
| username | the exact name of the user to query group membership for |
|---|---|
| groupName | the exact name of the group to query membership in |
true if the specified user is a member of the specified group; otherwise, false if the
user does not exist, the group does not exist or the user is not a member of the groupRetrieves a flag indicating whether the specified user is a member of the specified group. If the provided user
does not exist in the user store, or if the group does not exist, false is returned in preference to
throwing an exception.
| user | the user to query group membership for |
|---|---|
| groupName | the exact name of the group to query membership in |
true if the specified user is a member of the specified group; otherwise, false if the
user does not exist in the backing store, the group does not exist or the user is not a member of the
groupAuthenticate as user username, without checking passwords. Should only be used for trusted logins.
| username | the username |
|---|
StashUser representing the authenticated user.
| request | a request object describing the users to return |
|---|---|
| pageRequest | the bounds of the page |
Updates the specified user's avatar, replacing it with the one contained in the provided
supplier. Updating a user's avatar also updates the avatar for their
personal project.
| user | the user to update the avatar for |
|---|---|
| supplier | a supplier providing access to the new avatar to use |
Updates the specified user's avatar, replacing it with the one contained in the provided data URI. Updating a
user's avatar also updates the avatar for their personal
project.
data:(content type, e.g. image/png);base64,(data)
If the data is not Base64-encoded, or if a character set is defined in the URI, it will be rejected.
Previous avatars are not retained. When a project's avatar is updated, the previous avatar is removed.
To reuse a previous avatar, it must be provided again.| user | the user to update the avatar for |
|---|---|
| uri | a data URI containing a Base64-encoded avatar image |
Updates the password for the current user.
The current user always has permission to modify their own password. However, the underlying user store may not support the operation, or it may apply specific requirements to the complexity of the new password. If the user store is read-only, or the password does not meet complexity requirements, aServerException is thrown.| currentPassword | the current user's current password |
|---|---|
| newPassword | the current user's desired new password |
| IncorrectPasswordAuthenticationException | if the current password provided does not match the user's current password |
|---|---|
| ServerException | if the underlying user store does not support updating users' passwords |
Updates the display name and e-mail address for the current user.
ServerException will be thrown if the user store is read-only.| displayName | the new display name for the current user |
|---|---|
| emailAddress | the new e-mail address for the current user |
| ServerException | if the underlying user store does not support updating users' details |
|---|