public class DefaultUserService extends Object implements UserService
UserService interface. Contains methods to create/delete
users hiding UserUtil internals.UserService.AddUserToApplicationValidationResult, UserService.CreateUsernameValidationResult, UserService.CreateUserRequest, UserService.CreateUserValidationResult, UserService.DeleteUserValidationResult, UserService.FieldName, UserService.RemoveUserFromApplicationValidationResult, UserService.UpdateUserValidationResult| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
log |
| Constructor and Description |
|---|
DefaultUserService(UserUtil userUtil,
UserDeleteVeto userDeleteVeto,
PermissionManager permissionManager,
UserManager userManager,
I18nHelper.BeanFactory i18nFactory,
JiraAuthenticationContext jiraAuthenticationContext,
com.atlassian.event.api.EventPublisher eventPublisher,
PreDeleteUserErrorsManager preDeleteUserErrorsManager,
CreateUserApplicationHelper applicationHelper,
ApplicationRoleManager applicationRoleManager,
UserValidationHelper validationHelper,
GlobalPermissionGroupAssociationUtil globalPermissionGroupAssociationUtil,
GlobalPermissionManager globalPermissionManager,
UserEventFactory userEventFactory,
GroupManager groupManager) |
| Modifier and Type | Method and Description |
|---|---|
void |
addUserToApplication(UserService.AddUserToApplicationValidationResult result)
Given a valid validation result, this will associate a user with an application by adding that user to all the
default groups assigned to that application (regardless of the license).
|
ApplicationUser |
createUser(UserService.CreateUserValidationResult result)
Create a new application user if the provided
ServiceResultImpl.isValid(). |
ApplicationUser |
createUserFromSignup(UserService.CreateUserValidationResult result)
Given a valid validation result, this will create the user using the details provided in the validation result.
|
ApplicationUser |
createUserNoNotification(UserService.CreateUserValidationResult result)
Given a valid validation result, this will create the user using the details provided in the validation result.
|
ApplicationUser |
createUserWithNotification(UserService.CreateUserValidationResult result)
Given a valid validation result, this will create the user using the details provided in the validation result.
|
ApplicationUserBuilder |
newUserBuilder(ApplicationUser user)
Allows you to construct
ApplicationUser for UserService.validateUpdateUser(ApplicationUser) |
void |
removeUser(ApplicationUser loggedInUser,
UserService.DeleteUserValidationResult result)
Given a valid validation result, this will remove the user and removes the user from all the groups.
|
void |
removeUserFromApplication(UserService.RemoveUserFromApplicationValidationResult result)
Given a valid validation result, this will disassociate a user from an application by removing that user from all
the groups assigned to that application.
|
void |
updateUser(UserService.UpdateUserValidationResult updateUserValidationResult)
Execute the update using the validation result from
UserService.validateUpdateUser(ApplicationUser). |
UserService.AddUserToApplicationValidationResult |
validateAddUserToApplication(ApplicationUser user,
com.atlassian.application.api.ApplicationKey applicationKey)
Validates associating a user with an application.
|
UserService.AddUserToApplicationValidationResult |
validateAddUserToApplication(ApplicationUser loggedInUser,
ApplicationUser user,
com.atlassian.application.api.ApplicationKey applicationKey)
Validates associating a user with an application.
|
UserService.CreateUserValidationResult |
validateCreateUser(UserService.CreateUserRequest createUserRequest)
Validate that a new user can be created.
|
UserService.CreateUserValidationResult |
validateCreateUserForAdmin(ApplicationUser loggedInUser,
String username,
String password,
String confirmPassword,
String email,
String fullname)
Validates creating a user for the admin section.
|
UserService.CreateUserValidationResult |
validateCreateUserForAdmin(ApplicationUser loggedInUser,
String username,
String password,
String confirmPassword,
String email,
String fullname,
Long directoryId)
Validates creating a user for the admin section.
|
UserService.CreateUserValidationResult |
validateCreateUserForSetup(ApplicationUser loggedInUser,
String username,
String password,
String confirmPassword,
String email,
String fullname)
Validates creating a user during setup of JIRA.
|
UserService.CreateUserValidationResult |
validateCreateUserForSignup(ApplicationUser loggedInUser,
String username,
String password,
String confirmPassword,
String email,
String fullname)
Validates creating a user during public signup.
|
UserService.CreateUserValidationResult |
validateCreateUserForSignupOrSetup(ApplicationUser loggedInUser,
String username,
String password,
String confirmPassword,
String email,
String fullname)
Validates creating a user during setup of JIRA or during public signup.
|
UserService.CreateUsernameValidationResult |
validateCreateUsername(ApplicationUser loggedInUser,
String username)
Validates the username for a new user.
|
UserService.CreateUsernameValidationResult |
validateCreateUsername(ApplicationUser loggedInUser,
String username,
Long directoryId)
Validates the username for a new user.
|
UserService.DeleteUserValidationResult |
validateDeleteUser(ApplicationUser loggedInUser,
ApplicationUser userForDelete)
Validates removing a user for the admin section.
|
UserService.DeleteUserValidationResult |
validateDeleteUser(ApplicationUser loggedInUser,
String username)
Validates removing a user for the admin section.
|
UserService.RemoveUserFromApplicationValidationResult |
validateRemoveUserFromApplication(ApplicationUser user,
com.atlassian.application.api.ApplicationKey applicationKey)
Validates disassociating a user from an application.
|
UserService.RemoveUserFromApplicationValidationResult |
validateRemoveUserFromApplication(ApplicationUser loggedInUser,
ApplicationUser user,
com.atlassian.application.api.ApplicationKey applicationKey)
Validates disassociating a user from an application.
|
UserService.UpdateUserValidationResult |
validateUpdateUser(ApplicationUser user)
Validates updating a user's details.
|
public DefaultUserService(UserUtil userUtil, UserDeleteVeto userDeleteVeto, PermissionManager permissionManager, UserManager userManager, I18nHelper.BeanFactory i18nFactory, JiraAuthenticationContext jiraAuthenticationContext, com.atlassian.event.api.EventPublisher eventPublisher, PreDeleteUserErrorsManager preDeleteUserErrorsManager, CreateUserApplicationHelper applicationHelper, ApplicationRoleManager applicationRoleManager, UserValidationHelper validationHelper, GlobalPermissionGroupAssociationUtil globalPermissionGroupAssociationUtil, GlobalPermissionManager globalPermissionManager, UserEventFactory userEventFactory, GroupManager groupManager)
@Nonnull public ApplicationUserBuilder newUserBuilder(@Nonnull ApplicationUser user)
UserServiceApplicationUser for UserService.validateUpdateUser(ApplicationUser)newUserBuilder in interface UserServicepublic UserService.CreateUserValidationResult validateCreateUserForSignup(ApplicationUser loggedInUser, String username, String password, String confirmPassword, String email, String fullname)
UserServiceThis validation differs from the 'ForAdminPasswordRequired' and 'ForAdmin' validations as follows:
validateCreateUserForSignup in interface UserServiceloggedInUser - 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 userpublic UserService.CreateUserValidationResult validateCreateUserForSetup(ApplicationUser loggedInUser, String username, String password, String confirmPassword, String email, String fullname)
UserServiceThis validation differs from the 'ForAdminPasswordRequired' and 'ForAdmin' validations as follows:
validateCreateUserForSetup in interface UserServiceloggedInUser - 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 userpublic UserService.CreateUserValidationResult validateCreateUserForSignupOrSetup(ApplicationUser loggedInUser, String username, String password, String confirmPassword, String email, String fullname)
UserServiceThis validation differs from the 'ForAdminPasswordRequired' and 'ForAdmin' validations as follows:
validateCreateUserForSignupOrSetup in interface UserServiceloggedInUser - 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 userpublic UserService.CreateUserValidationResult validateCreateUser(UserService.CreateUserRequest createUserRequest)
UserServiceUserService.CreateUserRequest.
Typical validations are:
UserService.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.
validateCreateUser in interface UserServicecreateUserRequest - user creation request containing new user details and validation instructions.public UserService.CreateUserValidationResult validateCreateUserForAdmin(ApplicationUser loggedInUser, String username, String password, String confirmPassword, String email, String fullname)
UserServiceThis validation differs from the 'ForSetup' and 'ForAdminPasswordRequired' validations as follows:
validateCreateUserForAdmin in interface UserServiceloggedInUser - 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 userpublic UserService.CreateUserValidationResult validateCreateUserForAdmin(ApplicationUser loggedInUser, String username, String password, String confirmPassword, String email, String fullname, @Nullable Long directoryId)
UserServiceThis 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:
validateCreateUserForAdmin in interface UserServiceloggedInUser - 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 Directorypublic UserService.CreateUsernameValidationResult validateCreateUsername(ApplicationUser loggedInUser, String username)
UserServicevalidateCreateUsername in interface UserServiceloggedInUser - The remote user trying to add a new userusername - The username of the new user. Needs to be lowercase and unique.public UserService.CreateUsernameValidationResult validateCreateUsername(ApplicationUser loggedInUser, String username, Long directoryId)
UserServicevalidateCreateUsername in interface UserServiceloggedInUser - 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.public ApplicationUser createUser(@Nonnull UserService.CreateUserValidationResult result) throws PermissionException, CreateException
UserServiceServiceResultImpl.isValid(). This is typically
called after performing UserService.validateCreateUser(CreateUserRequest) and verifying that the ServiceResultImpl.isValid(). If the request is not valid or UserService.validateCreateUser(CreateUserRequest) was not called prior to this method an IllegalStateException
would get thrown.createUser in interface UserServiceresult - create user validation result returned from UserService.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 existsUserService.validateCreateUser(CreateUserRequest)public ApplicationUser createUserNoNotification(UserService.CreateUserValidationResult result) throws PermissionException, CreateException
UserServicecreateUserNoNotification in interface UserServiceresult - The validation resultPermissionException - If you cannot create users in this directory (it is read-only).CreateException - if the user could not be created, eg username already existspublic ApplicationUser createUserFromSignup(UserService.CreateUserValidationResult result) throws PermissionException, CreateException
UserServicecreateUserFromSignup in interface UserServiceresult - The validation resultPermissionException - If you cannot create users in this directory (it is read-only).CreateException - if the user could not be created, eg username already existspublic ApplicationUser createUserWithNotification(UserService.CreateUserValidationResult result) throws PermissionException, CreateException
UserServicecreateUserWithNotification in interface UserServiceresult - The validation resultPermissionException - If you cannot create users in this directory (it is read-only).CreateException - if the user could not be created, eg username already existspublic UserService.UpdateUserValidationResult validateUpdateUser(ApplicationUser user)
UserServicevalidateUpdateUser in interface UserServiceuser - The user details to updatepublic void updateUser(UserService.UpdateUserValidationResult updateUserValidationResult)
UserServiceUserService.validateUpdateUser(ApplicationUser).updateUser in interface UserServiceupdateUserValidationResult - Result from the validation, which also contains all the user's details.public UserService.DeleteUserValidationResult validateDeleteUser(ApplicationUser loggedInUser, String username)
UserService
See UserService.validateDeleteUser(ApplicationUser, ApplicationUser) for restrictions.
validateDeleteUser in interface UserServiceloggedInUser - The remote user trying to remove a userusername - The username of the user to remove. Needs to be validpublic UserService.DeleteUserValidationResult validateDeleteUser(ApplicationUser loggedInUser, ApplicationUser userForDelete)
UserServiceRemoving the user is not allowed if:
PreDeleteUserErrors rejects the requestvalidateDeleteUser in interface UserServiceloggedInUser - The remote user trying to remove a useruserForDelete - The user to remove. Needs to be validpublic void removeUser(ApplicationUser loggedInUser, UserService.DeleteUserValidationResult result)
UserServiceremoveUser in interface UserServiceloggedInUser - the user performing operationresult - The validation resultpublic UserService.AddUserToApplicationValidationResult validateAddUserToApplication(ApplicationUser user, com.atlassian.application.api.ApplicationKey applicationKey)
UserServicevalidateAddUserToApplication in interface UserServiceuser - the user to be associated with the applicationapplicationKey - the key of the applicationpublic UserService.AddUserToApplicationValidationResult validateAddUserToApplication(ApplicationUser loggedInUser, ApplicationUser user, com.atlassian.application.api.ApplicationKey applicationKey)
UserServicevalidateAddUserToApplication in interface UserServiceloggedInUser - The logged in useruser - the user to be associated with the applicationapplicationKey - the key of the applicationpublic void addUserToApplication(UserService.AddUserToApplicationValidationResult result) throws AddException, PermissionException
UserServiceIf 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 UserService.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.
addUserToApplication in interface UserServiceresult - 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-onlypublic UserService.RemoveUserFromApplicationValidationResult validateRemoveUserFromApplication(ApplicationUser user, com.atlassian.application.api.ApplicationKey applicationKey)
UserService
Method expects for loggedInUser to be available via JiraAuthenticationContext.getLoggedInUser().
validateRemoveUserFromApplication in interface UserServiceuser - the user to be disassociated with the applicationapplicationKey - the key of the applicationpublic UserService.RemoveUserFromApplicationValidationResult validateRemoveUserFromApplication(ApplicationUser loggedInUser, ApplicationUser user, com.atlassian.application.api.ApplicationKey applicationKey)
UserServicevalidateRemoveUserFromApplication in interface UserServiceloggedInUser - application user performing the application access removaluser - the user to be disassociated with the applicationapplicationKey - the key of the applicationpublic void removeUserFromApplication(UserService.RemoveUserFromApplicationValidationResult result) throws RemoveException, PermissionException
UserServiceIf 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 UserService.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
removeUserFromApplication in interface UserServiceresult - 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-2024 Atlassian. All Rights Reserved.