Class UsersController
java.lang.Object
com.atlassian.crowd.plugin.rest.service.controller.AbstractResourceController
com.atlassian.crowd.plugin.rest.service.controller.UsersController
Controller responsible for user management.
-
Constructor Summary
ConstructorsConstructorDescriptionUsersController
(ApplicationService applicationService, ForgottenLoginManager forgottenLoginManager, AuthenticatedApplicationHolder authenticatedApplicationHolder) -
Method Summary
Modifier and TypeMethodDescriptionaddUser
(UserEntity userEntity, com.atlassian.plugins.rest.api.model.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
Expires all passwords for all directories which are part of this application, regardless of group mapping.findUserByKey
(String key, com.atlassian.plugins.rest.api.model.Link userLink, boolean expandAttributes) findUserByName
(String name, com.atlassian.plugins.rest.api.model.Link userLink, boolean expandAttributes) Returns a UserEntity specified by the name.getAvatarForUser
(String username, int sizeHint) getDirectGroup
(String userName, String groupName, URI baseUri) Returns the specified group that the user is a direct member of.getDirectGroups
(String userName, boolean expandGroups, boolean expandAttributes, int maxResults, int startIndex, URI baseUri) Returns the groups that the user is a direct member of.getNestedGroup
(String userName, String groupName, URI baseUri) Returns the specified group that the user is a nested member of.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.renameUser
(String oldUsername, com.atlassian.plugins.rest.api.model.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.updateUser
(UserEntity userEntity) Updates a user.void
updateUserPassword
(String username, String password) Updates a user's password.Methods inherited from class com.atlassian.crowd.plugin.rest.service.controller.AbstractResourceController
getAuthenticatedApplication
-
Constructor Details
-
UsersController
@Inject public UsersController(ApplicationService applicationService, ForgottenLoginManager forgottenLoginManager, AuthenticatedApplicationHolder authenticatedApplicationHolder)
-
-
Method Details
-
findUserByName
public UserEntity findUserByName(String name, com.atlassian.plugins.rest.api.model.Link userLink, boolean expandAttributes) throws UserNotFoundException Returns a UserEntity specified by the name.- Parameters:
name
- name of the user to retrieveuserLink
- link to the user resourceexpandAttributes
- set to true if the attributes field should be expanded- Returns:
- UserEntity
- Throws:
UserNotFoundException
- if the user could not be found
-
findUserByKey
public UserEntity findUserByKey(String key, com.atlassian.plugins.rest.api.model.Link userLink, boolean expandAttributes) throws UserNotFoundException - Throws:
UserNotFoundException
-
addUser
public UserEntity addUser(UserEntity userEntity, com.atlassian.plugins.rest.api.model.Link userLink) throws ApplicationPermissionException, InvalidUserException, InvalidCredentialException, OperationFailedException Adds a new user.- Parameters:
userEntity
- new user to adduserLink
- preliminary link to the user resource- Returns:
- the created
UserWithAttributes
represented within aUserEntity
- Throws:
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 exists
-
updateUser
public String updateUser(UserEntity userEntity) throws ApplicationPermissionException, InvalidUserException, UserNotFoundException, OperationFailedException Updates a user.- Parameters:
userEntity
- updated user information- Returns:
- canonical username
- Throws:
ApplicationPermissionException
- 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 reason
-
storeUserAttributes
public void storeUserAttributes(String username, MultiValuedAttributeEntityList attributes) throws ApplicationPermissionException, UserNotFoundException, OperationFailedException Stores (add/replace) the user attributes. Attribute values will not be overwritten if not specified in attributes.- Parameters:
username
- name of the userattributes
- attributes of the user- Throws:
ApplicationPermissionException
- 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 found
-
removeUserAttribute
public void removeUserAttribute(String username, String attributeName) throws ApplicationPermissionException, UserNotFoundException, OperationFailedException Removes the user attribute.- Parameters:
username
- name of the userattributeName
- name of attribute to remove- Throws:
ApplicationPermissionException
- 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 found
-
requestPasswordReset
public void requestPasswordReset(String username) throws InvalidEmailAddressException, ApplicationPermissionException, UserNotFoundException, OperationFailedException Requests a password reset.- Parameters:
username
- name of the user- Throws:
UserNotFoundException
- 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 passwordOperationFailedException
-
requestUsernames
Requests an email to be sent containing usernames associated with the given email address.- Parameters:
email
- email address of the user- Returns:
true
if any users with that address were found.- Throws:
InvalidEmailAddressException
- if theemail
is not valid
-
removeUser
public void removeUser(String username) throws ApplicationPermissionException, UserNotFoundException, OperationFailedException Removes the user.- Parameters:
username
- name of the user- Throws:
ApplicationPermissionException
- 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 found
-
renameUser
public UserEntity renameUser(String oldUsername, com.atlassian.plugins.rest.api.model.Link userLink, String newUsername) throws ApplicationPermissionException, InvalidUserException, UserNotFoundException, OperationFailedException Renames a user.- Parameters:
oldUsername
- current name of the user to renamenewUsername
- the intended new name of the user- Returns:
- the renamed user
- Throws:
ApplicationPermissionException
- 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 reason
-
updateUserPassword
public void updateUserPassword(String username, String password) throws ApplicationPermissionException, UserNotFoundException, InvalidCredentialException, OperationFailedException Updates a user's password.- Parameters:
username
- name of the userpassword
- new password- Throws:
ApplicationPermissionException
- 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 valid
-
clearUserPassword
public void clearUserPassword(String username) throws ApplicationPermissionException, UserNotFoundException, InvalidCredentialException, OperationFailedException Clears a user's password, so that the user cannot authenticate with any password.- Parameters:
username
- name of the user- Throws:
ApplicationPermissionException
- 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 valid
-
expireAllPasswords
Expires all passwords for all directories which are part of this application, regardless of group mapping.- Throws:
OperationFailedException
- if any of the directories fail to expire all passwords. This can lead to only some of the users having expired passwords.
-
getDirectGroups
public GroupEntityList getDirectGroups(String userName, boolean expandGroups, boolean expandAttributes, int maxResults, int startIndex, URI baseUri) throws UserNotFoundException Returns the groups that the user is a direct member of.- Parameters:
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 service- Returns:
- groups that the user is a direct member of
- Throws:
UserNotFoundException
-
getDirectGroup
public GroupEntity getDirectGroup(String userName, String groupName, URI baseUri) throws MembershipNotFoundException, UserNotFoundException Returns the specified group that the user is a direct member of.- Parameters:
userName
- name of the usergroupName
- name of the group the user is a member ofbaseUri
- base URI of the REST service- Returns:
- group that the user is a direct member of
- Throws:
MembershipNotFoundException
- if the membership was not foundUserNotFoundException
-
addUserToGroup
public void addUserToGroup(String userName, String groupName) throws ApplicationPermissionException, UserNotFoundException, GroupNotFoundException, OperationFailedException, MembershipAlreadyExistsException Adds a user to a group.- Parameters:
userName
- name of the usergroupName
- name of the group- Throws:
ApplicationPermissionException
- if none of the application's associated directories are allowed to perform operations of typeOperationType.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 reason
-
removeUserFromGroup
public void removeUserFromGroup(String userName, String groupName) throws ApplicationPermissionException, MembershipNotFoundException, UserNotFoundException, GroupNotFoundException, OperationFailedException Removes a user from a group.- Parameters:
userName
- name of the usergroupName
- name of the group- Throws:
ApplicationPermissionException
- if none of the application's associated directories are allowed to perform operations of typeOperationType.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 reason
-
getNestedGroups
public GroupEntityList getNestedGroups(String userName, boolean expandGroups, int maxResults, int startIndex, URI baseUri) throws UserNotFoundException Returns the groups that the user is a nested member of.- Parameters:
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 service- Returns:
- groups that the user is a nested member of
- Throws:
UserNotFoundException
-
getNestedGroup
public GroupEntity getNestedGroup(String userName, String groupName, URI baseUri) throws MembershipNotFoundException, UserNotFoundException Returns the specified group that the user is a nested member of.- Parameters:
userName
- name of the usergroupName
- name of the group the user is a member ofbaseUri
- base URI of the REST service- Returns:
- group that the user is a nested member of
- Throws:
MembershipNotFoundException
- if the membership was not foundUserNotFoundException
-
getAvatarForUser
@Nullable public URI getAvatarForUser(String username, int sizeHint) throws UserNotFoundException, DirectoryNotFoundException, OperationFailedException
-