@PublicApi
public interface UserService
Modifier and Type | Interface and Description |
---|---|
static class |
UserService.AddUserToApplicationValidationResult |
static class |
UserService.CreateUsernameValidationResult |
static class |
UserService.CreateUserRequest
This request contains all the instructions and user details that should be used during user validation and user
creation.
|
static class |
UserService.CreateUserValidationResult |
static class |
UserService.DeleteUserValidationResult |
static class |
UserService.FieldName |
static class |
UserService.RemoveUserFromApplicationValidationResult |
static class |
UserService.UpdateUserValidationResult |
UserService.CreateUserValidationResult validateCreateUser(UserService.CreateUserRequest createUserRequest)
UserService.CreateUserRequest
.
Typical validations are:
createUser(CreateUserValidationResult)
should only be called when the validationResult.isValid().
Usage example:
final CreateUserRequest createUserRequest = CreateUserRequest.withUserDetails(currentApplicationUser,
username, password, email, displayName)
result = userService.validateCreateUser(createUserRequest);
if(result.isValid())
{
userService.createUser(createUserRequest);
}
This request indicates that the user should be created in the default user directory with access to the default
applications.
createUserRequest
- user creation request containing new user details and validation instructions.ApplicationUser createUser(UserService.CreateUserValidationResult createUserValidationResult) throws PermissionException, CreateException
ServiceResultImpl.isValid()
. This is typically
called after performing validateCreateUser(CreateUserRequest)
and verifying that the ServiceResultImpl.isValid()
. If the request is not valid or validateCreateUser(CreateUserRequest)
was not called prior to this method an IllegalStateException
would get thrown.createUserValidationResult
- create user validation result returned from validateCreateUser(CreateUserRequest)
, this contains the user details and instructions used to create new
user.PermissionException
- when the logged in user does not have permissions to perform user creation or when
the user directory is read-only.CreateException
- if the user could not be created for any reason, eg username already existsvalidateCreateUser(CreateUserRequest)
@Nonnull @ExperimentalApi ApplicationUserBuilder newUserBuilder(@Nonnull ApplicationUser user)
ApplicationUser
for validateUpdateUser(ApplicationUser)
UserService.CreateUserValidationResult validateCreateUserForSignup(ApplicationUser loggedInUser, String username, String password, String confirmPassword, String email, String fullname)
validateCreateUser(CreateUserRequest)
instead. Since v7.0.This validation differs from the 'ForAdminPasswordRequired' and 'ForAdmin' validations as follows:
loggedInUser
- The remote user trying to add a new userusername
- The username of the new user. Needs to be lowercase and unique.password
- The password for the new user.confirmPassword
- The password confirmation. Needs to match password.email
- The email for the new user. Needs to be a valid email address.fullname
- The full name for the new userUserService.CreateUserValidationResult validateCreateUserForSetup(ApplicationUser loggedInUser, String username, String password, String confirmPassword, String email, String fullname)
validateCreateUser(CreateUserRequest)
instead. Since v7.0.This validation differs from the 'ForAdminPasswordRequired' and 'ForAdmin' validations as follows:
loggedInUser
- The remote user trying to add a new userusername
- The username of the new user. Needs to be lowercase and unique.password
- The password for the new user.confirmPassword
- The password confirmation. Needs to match password.email
- The email for the new user. Needs to be a valid email address.fullname
- The full name for the new userUserService.CreateUserValidationResult validateCreateUserForSignupOrSetup(ApplicationUser user, String username, String password, String confirmPassword, String email, String fullname)
validateCreateUser(CreateUserRequest)
instead. Since v7.0.This validation differs from the 'ForAdminPasswordRequired' and 'ForAdmin' validations as follows:
user
- The remote user trying to add a new userusername
- The username of the new user. Needs to be lowercase and unique.password
- The password for the new user.confirmPassword
- The password confirmation. Needs to match password.email
- The email for the new user. Needs to be a valid email address.fullname
- The full name for the new userUserService.CreateUserValidationResult validateCreateUserForAdmin(ApplicationUser loggedInUser, String username, String password, String confirmPassword, String email, String fullname)
validateCreateUser(CreateUserRequest)
instead. Since v7.0.This validation differs from the 'ForSetup' and 'ForAdminPasswordRequired' validations as follows:
loggedInUser
- The remote user trying to add a new userusername
- The username of the new user. Needs to be lowercase and unique.password
- The password for the new user.confirmPassword
- The password confirmation. Needs to match password.email
- The email for the new user. Needs to be a valid email address.fullname
- The full name for the new userUserService.CreateUserValidationResult validateCreateUserForAdmin(ApplicationUser loggedInUser, String username, String password, String confirmPassword, String email, String fullname, @Nullable Long directoryId)
validateCreateUser(CreateUserRequest)
instead. Since v7.0.This method allows the caller to name a directory to create the user in and the directoryId must be valid and represent a Directory with "create user" permission.
This validation differs from the 'ForSetup' and 'ForAdminPasswordRequired' validations as follows:
loggedInUser
- The remote user trying to add a new userusername
- The username of the new user. Needs to be lowercase and unique.password
- The password for the new user.confirmPassword
- The password confirmation. Needs to match password.email
- The email for the new user. Needs to be a valid email address.fullname
- The full name for the new userdirectoryId
- The User DirectoryUserService.CreateUsernameValidationResult validateCreateUsername(ApplicationUser loggedInUser, String username)
loggedInUser
- The remote user trying to add a new userusername
- The username of the new user. Needs to be lowercase and unique.UserService.CreateUsernameValidationResult validateCreateUsername(ApplicationUser loggedInUser, String username, Long directoryId)
loggedInUser
- The remote user trying to add a new userusername
- The username of the new user. Needs to be lowercase and unique.directoryId
- The directory which the new user is intended to be created in.ApplicationUser createUserFromSignup(UserService.CreateUserValidationResult result) throws PermissionException, CreateException
createUser(CreateUserValidationResult)
instead. Since v7.0.result
- The validation resultCreateException
- if the user could not be created, eg username already existsPermissionException
- If you cannot create users in this directory (it is read-only).ApplicationUser createUserWithNotification(UserService.CreateUserValidationResult result) throws PermissionException, CreateException
createUser(CreateUserValidationResult)
instead. Since v7.0.result
- The validation resultCreateException
- if the user could not be created, eg username already existsPermissionException
- If you cannot create users in this directory (it is read-only).ApplicationUser createUserNoNotification(UserService.CreateUserValidationResult result) throws PermissionException, CreateException
createUser(CreateUserValidationResult)
instead. Since v7.0.result
- The validation resultCreateException
- if the user could not be created, eg username already existsPermissionException
- If you cannot create users in this directory (it is read-only).UserService.UpdateUserValidationResult validateUpdateUser(ApplicationUser user)
user
- The user details to updatevoid updateUser(UserService.UpdateUserValidationResult updateUserValidationResult)
validateUpdateUser(ApplicationUser)
.updateUserValidationResult
- Result from the validation, which also contains all the user's details.IllegalStateException
- if the validation result contains any errors.UserService.DeleteUserValidationResult validateDeleteUser(ApplicationUser loggedInUser, String username)
See validateDeleteUser(ApplicationUser, ApplicationUser)
for restrictions.
loggedInUser
- The remote user trying to remove a userusername
- The username of the user to remove. Needs to be validUserService.DeleteUserValidationResult validateDeleteUser(ApplicationUser loggedInUser, ApplicationUser userForDelete)
Removing the user is not allowed if:
PreDeleteUserErrors
rejects the requestloggedInUser
- The remote user trying to remove a useruserForDelete
- The user to remove. Needs to be validvoid removeUser(ApplicationUser loggedInUser, UserService.DeleteUserValidationResult result)
removeUser(ApplicationUser, DeleteUserValidationResult)
instead. Since v6.0.loggedInUser
- the user performing operationresult
- The validation resultUserService.AddUserToApplicationValidationResult validateAddUserToApplication(ApplicationUser user, com.atlassian.application.api.ApplicationKey applicationKey)
validateAddUserToApplication(ApplicationUser, ApplicationUser, ApplicationKey)
instead. Since v7.0user
- the user to be associated with the applicationapplicationKey
- the key of the applicationUserService.AddUserToApplicationValidationResult validateAddUserToApplication(ApplicationUser loggedInUser, ApplicationUser user, com.atlassian.application.api.ApplicationKey applicationKey)
loggedInUser
- The logged in useruser
- the user to be associated with the applicationapplicationKey
- the key of the applicationvoid addUserToApplication(UserService.AddUserToApplicationValidationResult result) throws AddException, PermissionException
If the user is already associated with the application but is not the member of all the default groups, that user will be added to the default groups which that user does not belong to yet.
If any of the default groups assigned to this application are also assigned to other application(s), the user will also be associated with those applications as well.
This method is not the exact opposite to removeUserFromApplication(com.atlassian.jira.bc.user.UserService.RemoveUserFromApplicationValidationResult)
.
While this method only adds user to the default groups assigned to an application, removeUserFromApplication
method removes user from all the group assigned to an application.
result
- the validation resultAddException
- the underlying directory implementation failed to add user to groupPermissionException
- the underlying directory has been configured to not allow
user to be added to group, or the directory/group is read-only@Deprecated @Internal UserService.RemoveUserFromApplicationValidationResult validateRemoveUserFromApplication(ApplicationUser user, com.atlassian.application.api.ApplicationKey applicationKey)
validateRemoveUserFromApplication(com.atlassian.jira.user.ApplicationUser, com.atlassian.jira.user.ApplicationUser, com.atlassian.application.api.ApplicationKey)
instead. Since v 7.0.0.
Method expects for loggedInUser to be available via JiraAuthenticationContext.getLoggedInUser()
.
user
- the user to be disassociated with the applicationapplicationKey
- the key of the applicationUserService.RemoveUserFromApplicationValidationResult validateRemoveUserFromApplication(ApplicationUser loggedInUser, ApplicationUser user, com.atlassian.application.api.ApplicationKey applicationKey)
loggedInUser
- application user performing the application access removaluser
- the user to be disassociated with the applicationapplicationKey
- the key of the applicationvoid removeUserFromApplication(UserService.RemoveUserFromApplicationValidationResult result) throws RemoveException, PermissionException
If the group set assigned to this application is a superset of the group set assigned to other application(s), the user will also be disassociated with those applications as well.
This method is not the exact opposite to addUserToApplication(com.atlassian.jira.bc.user.UserService.AddUserToApplicationValidationResult)
.
While this method removes user from all the group assigned to an application, addUserToApplication method
only adds user to the default groups assigned to an application
result
- The validation resultRemoveException
- the underlying directory implementation failed to remove user from groupPermissionException
- the underlying directory has been configured to not allow
user to be removed from group, or the directory/group is read-onlyCopyright © 2002-2021 Atlassian. All Rights Reserved.