@Named public class UsersController extends AbstractResourceController
Constructor and Description |
---|
UsersController(ApplicationService applicationService,
ForgottenLoginManager forgottenLoginManager,
AuthenticatedApplicationHolder authenticatedApplicationHolder) |
Modifier and Type | Method and Description |
---|---|
UserEntity |
addUser(UserEntity userEntity,
com.atlassian.plugins.rest.common.Link userLink)
Adds a new user.
|
void |
addUserToGroup(String userName,
String groupName)
Adds a user to a group.
|
void |
clearUserPassword(String username)
Clears a user's password, so that the user cannot authenticate with any password.
|
void |
expireAllPasswords()
Expires all passwords for all directories which are part of this application, regardless of
group mapping.
|
UserEntity |
findUserByKey(String key,
com.atlassian.plugins.rest.common.Link userLink,
boolean expandAttributes) |
UserEntity |
findUserByName(String name,
com.atlassian.plugins.rest.common.Link userLink,
boolean expandAttributes)
Returns a UserEntity specified by the name.
|
URI |
getAvatarForUser(String username,
int sizeHint) |
GroupEntity |
getDirectGroup(String userName,
String groupName,
URI baseUri)
Returns the specified group that the user is a direct member of.
|
GroupEntityList |
getDirectGroups(String userName,
boolean expandGroups,
boolean expandAttributes,
int maxResults,
int startIndex,
URI baseUri)
Returns the groups that the user is a direct member of.
|
GroupEntity |
getNestedGroup(String userName,
String groupName,
URI baseUri)
Returns the specified group that the user is a nested member of.
|
GroupEntityList |
getNestedGroups(String userName,
boolean expandGroups,
int maxResults,
int startIndex,
URI baseUri)
Returns the groups that the user is a nested member of.
|
void |
removeUser(String username)
Removes the user.
|
void |
removeUserAttribute(String username,
String attributeName)
Removes the user attribute.
|
void |
removeUserFromGroup(String userName,
String groupName)
Removes a user from a group.
|
UserEntity |
renameUser(String oldUsername,
com.atlassian.plugins.rest.common.Link userLink,
String newUsername)
Renames a user.
|
void |
requestPasswordReset(String username)
Requests a password reset.
|
boolean |
requestUsernames(String email)
Requests an email to be sent containing usernames associated with the given email address.
|
void |
storeUserAttributes(String username,
MultiValuedAttributeEntityList attributes)
Stores (add/replace) the user attributes.
|
String |
updateUser(UserEntity userEntity)
Updates a user.
|
void |
updateUserPassword(String username,
String password)
Updates a user's password.
|
getAuthenticatedApplication
@Inject public UsersController(ApplicationService applicationService, ForgottenLoginManager forgottenLoginManager, AuthenticatedApplicationHolder authenticatedApplicationHolder)
public UserEntity findUserByName(String name, com.atlassian.plugins.rest.common.Link userLink, boolean expandAttributes) throws UserNotFoundException
name
- name of the user to retrieveuserLink
- link to the user resourceexpandAttributes
- set to true if the attributes field should be expandedUserNotFoundException
- if the user could not be foundpublic UserEntity findUserByKey(String key, com.atlassian.plugins.rest.common.Link userLink, boolean expandAttributes) throws UserNotFoundException
UserNotFoundException
public UserEntity addUser(UserEntity userEntity, com.atlassian.plugins.rest.common.Link userLink) throws ApplicationPermissionException, InvalidUserException, InvalidCredentialException, OperationFailedException
userEntity
- new user to adduserLink
- preliminary link to the user resourceUserWithAttributes
represented within a UserEntity
ApplicationPermissionException
- if none of the application's underlying directories are allowed to perform this operationOperationFailedException
- if the operation failed for any other reasonInvalidCredentialException
- if the password is not validInvalidUserException
- if the user is not valid or already existspublic String updateUser(UserEntity userEntity) throws ApplicationPermissionException, InvalidUserException, UserNotFoundException, OperationFailedException
userEntity
- updated user informationApplicationPermissionException
- if none of the application's underlying directories are allowed to perform this operationInvalidUserException
- if the user template does not have the required properties populated.UserNotFoundException
- if the user was not foundOperationFailedException
- if the operation failed for any other reasonpublic void storeUserAttributes(String username, MultiValuedAttributeEntityList attributes) throws ApplicationPermissionException, UserNotFoundException, OperationFailedException
username
- name of the userattributes
- attributes of the userApplicationPermissionException
- if none of the application's underlying directories are allowed to perform this operationOperationFailedException
- if the operation failed for any other reasonUserNotFoundException
- if the user could not be foundpublic void removeUserAttribute(String username, String attributeName) throws ApplicationPermissionException, UserNotFoundException, OperationFailedException
username
- name of the userattributeName
- name of attribute to removeApplicationPermissionException
- if none of the application's underlying directories have permission to perform the operationOperationFailedException
- if the operation failed for any other reasonUserNotFoundException
- if the user could not be foundpublic void requestPasswordReset(String username) throws InvalidEmailAddressException, ApplicationPermissionException, UserNotFoundException
username
- name of the userUserNotFoundException
- if the user could not be foundInvalidEmailAddressException
- if the user does not have a valid email to send the reset password link toApplicationPermissionException
- if none of the application's underlying directories can update the user's passwordpublic boolean requestUsernames(String email) throws InvalidEmailAddressException
email
- email address of the usertrue
if any users with that address were found.InvalidEmailAddressException
- if the email
is not validpublic void removeUser(String username) throws ApplicationPermissionException, UserNotFoundException, OperationFailedException
username
- name of the userApplicationPermissionException
- if none of the application's underlying directories can update the user's passwordOperationFailedException
- if the operation failed for any other reasonUserNotFoundException
- if the user could not be foundpublic UserEntity renameUser(String oldUsername, com.atlassian.plugins.rest.common.Link userLink, String newUsername) throws ApplicationPermissionException, InvalidUserException, UserNotFoundException, OperationFailedException
oldUsername
- current name of the user to renamenewUsername
- the intended new name of the userApplicationPermissionException
- if none of the application's underlying directories are allowed to perform this operationInvalidUserException
- if the user template does not have the required properties populated.UserNotFoundException
- if the user was not foundOperationFailedException
- if the operation failed for any other reasonpublic void updateUserPassword(String username, String password) throws ApplicationPermissionException, UserNotFoundException, InvalidCredentialException, OperationFailedException
username
- name of the userpassword
- new passwordApplicationPermissionException
- if none of the application's underlying directories are allowed to perform this operationUserNotFoundException
- if the user was not foundOperationFailedException
- if the operation failed for any other reasonInvalidCredentialException
- if the new password is not validpublic void clearUserPassword(String username) throws ApplicationPermissionException, UserNotFoundException, InvalidCredentialException, OperationFailedException
username
- name of the userApplicationPermissionException
- if none of the application's underlying directories are allowed to perform this operationUserNotFoundException
- if the user was not foundOperationFailedException
- if the operation failed for any other reasonInvalidCredentialException
- if the new password is not validpublic void expireAllPasswords() throws OperationFailedException
OperationFailedException
- if any of the directories fail to expire all passwords. This
can lead to only some of the users having expired passwords.public GroupEntityList getDirectGroups(String userName, boolean expandGroups, boolean expandAttributes, int maxResults, int startIndex, URI baseUri) throws UserNotFoundException
userName
- name of the userexpandGroups
- should groups be expandedexpandAttributes
- should the attributes of the group be expandedmaxResults
- maximum number of results returned. If -1, then all the results are returned.startIndex
- starting index of the resultsbaseUri
- base URI of the REST serviceUserNotFoundException
public GroupEntity getDirectGroup(String userName, String groupName, URI baseUri) throws MembershipNotFoundException, UserNotFoundException
userName
- name of the usergroupName
- name of the group the user is a member ofbaseUri
- base URI of the REST serviceMembershipNotFoundException
- if the membership was not foundUserNotFoundException
public void addUserToGroup(String userName, String groupName) throws ApplicationPermissionException, UserNotFoundException, GroupNotFoundException, OperationFailedException, MembershipAlreadyExistsException
userName
- name of the usergroupName
- name of the groupApplicationPermissionException
- if none of the application's associated directories are allowed to perform operations of type OperationType.UPDATE_GROUP
.UserNotFoundException
- if the user could not be foundGroupNotFoundException
- if the group could not be foundMembershipAlreadyExistsException
- if the user is already a member of the groupOperationFailedException
- if the operation failed for any other reasonpublic void removeUserFromGroup(String userName, String groupName) throws ApplicationPermissionException, MembershipNotFoundException, UserNotFoundException, GroupNotFoundException, OperationFailedException
userName
- name of the usergroupName
- name of the groupApplicationPermissionException
- if none of the application's associated directories are allowed to perform operations of type OperationType.UPDATE_GROUP
.GroupNotFoundException
- if the group could not be foundMembershipNotFoundException
- if the membership does not existUserNotFoundException
- if the user could not be foundOperationFailedException
- if the operation failed for any other reasonpublic GroupEntityList getNestedGroups(String userName, boolean expandGroups, int maxResults, int startIndex, URI baseUri) throws UserNotFoundException
userName
- name of the userexpandGroups
- should groups be expandedmaxResults
- maximum number of results returned. If -1, then all the results are returned.startIndex
- starting index of the resultsbaseUri
- base URI of the REST serviceUserNotFoundException
public GroupEntity getNestedGroup(String userName, String groupName, URI baseUri) throws MembershipNotFoundException, UserNotFoundException
userName
- name of the usergroupName
- name of the group the user is a member ofbaseUri
- base URI of the REST serviceMembershipNotFoundException
- if the membership was not foundUserNotFoundException
@Nullable public URI getAvatarForUser(String username, int sizeHint) throws UserNotFoundException, DirectoryNotFoundException, OperationFailedException
Copyright © 2020 Atlassian. All rights reserved.