com.atlassian.jira.bc.user
Class DefaultUserService

java.lang.Object
  extended by com.atlassian.jira.bc.user.DefaultUserService
All Implemented Interfaces:
UserService

public class DefaultUserService
extends Object
implements UserService

Default implementation of UserService interface. Contains metohods to create/delete users hiding UserUtil internals.

Since:
v4.0

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.atlassian.jira.bc.user.UserService
UserService.CreateUsernameValidationResult, UserService.CreateUserValidationResult, UserService.DeleteUserValidationResult, UserService.FieldName, UserService.UpdateUserValidationResult
 
Constructor Summary
DefaultUserService(UserUtil userUtil, PermissionManager permissionManager, UserManager userManager, JiraContactHelper jiraContactHelper, I18nHelper.BeanFactory i18nFactory, JiraAuthenticationContext jiraAuthenticationContext)
           
 
Method Summary
 com.atlassian.crowd.embedded.api.User createUserFromSignup(UserService.CreateUserValidationResult result)
          Given a valid validation result, this will create the user using the details provided in the validation result.
 com.atlassian.crowd.embedded.api.User createUserNoNotification(UserService.CreateUserValidationResult result)
          Given a valid validation result, this will create the user using the details provided in the validation result.
 com.atlassian.crowd.embedded.api.User createUserWithNotification(UserService.CreateUserValidationResult result)
          Given a valid validation result, this will create the user using the details provided in the validation result.
 void removeUser(com.atlassian.crowd.embedded.api.User loggedInUser, UserService.DeleteUserValidationResult result)
          Given a valid validation result, this will remove the user and removes the user from all the groups.
 void updateUser(UserService.UpdateUserValidationResult updateUserValidationResult)
          Execute the update using the validation result from UserService.validateUpdateUser(User).
 UserService.CreateUserValidationResult validateCreateUserForAdmin(com.atlassian.crowd.embedded.api.User user, String username, String password, String confirmPassword, String email, String fullname)
          Validates creating a user for the admin section.
 UserService.CreateUserValidationResult validateCreateUserForAdmin(com.atlassian.crowd.embedded.api.User user, String username, String password, String confirmPassword, String email, String fullname, Long directoryId)
          Validates creating a user for the admin section.
 UserService.CreateUserValidationResult validateCreateUserForAdminPasswordRequired(com.atlassian.crowd.embedded.api.User user, String username, String password, String confirmPassword, String email, String fullname)
          Validates creating a user for RPC calls.
 UserService.CreateUserValidationResult validateCreateUserForSetup(com.atlassian.crowd.embedded.api.User loggedInUser, String username, String password, String confirmPassword, String email, String fullname)
          Validates creating a user during setup of JIRA.
 UserService.CreateUserValidationResult validateCreateUserForSignup(com.atlassian.crowd.embedded.api.User loggedInUser, String username, String password, String confirmPassword, String email, String fullname)
          Validates creating a user during public signup.
 UserService.CreateUserValidationResult validateCreateUserForSignupOrSetup(com.atlassian.crowd.embedded.api.User 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(com.atlassian.crowd.embedded.api.User loggedInUser, String username)
          Validates the username for a new user.
 UserService.CreateUsernameValidationResult validateCreateUsername(com.atlassian.crowd.embedded.api.User loggedInUser, String username, Long directoryId)
          Validates the username for a new user.
 UserService.DeleteUserValidationResult validateDeleteUser(com.atlassian.crowd.embedded.api.User loggedInUser, String username)
          Validates removing a user for the admin section.
 UserService.UpdateUserValidationResult validateUpdateUser(com.atlassian.crowd.embedded.api.User user)
          Validates updating a user's details.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultUserService

public DefaultUserService(UserUtil userUtil,
                          PermissionManager permissionManager,
                          UserManager userManager,
                          JiraContactHelper jiraContactHelper,
                          I18nHelper.BeanFactory i18nFactory,
                          JiraAuthenticationContext jiraAuthenticationContext)
Method Detail

validateCreateUserForSignup

public UserService.CreateUserValidationResult validateCreateUserForSignup(com.atlassian.crowd.embedded.api.User loggedInUser,
                                                                          String username,
                                                                          String password,
                                                                          String confirmPassword,
                                                                          String email,
                                                                          String fullname)
Description copied from interface: UserService
Validates creating a user during public signup. This method checks that there is a writable User Directory available. It also validates that all parameters (username, email, fullname, password) have been provided. Email is also checked to ensure that it is a valid email address. The username is required to be lowercase characters only and unique. The confirmPassword has to match the password provided.

This validation differs from the 'ForAdminPasswordRequired' and 'ForAdmin' validations as follows:


validateCreateUserForSetup

public UserService.CreateUserValidationResult validateCreateUserForSetup(com.atlassian.crowd.embedded.api.User loggedInUser,
                                                                         String username,
                                                                         String password,
                                                                         String confirmPassword,
                                                                         String email,
                                                                         String fullname)
Description copied from interface: UserService
Validates creating a user during setup of JIRA. This method does not check for a writable User Directory because the embedded crowd subsystem will not be initialised, and we know we will just have an Internal Directory during Setup. It also validates that all parameters (username, email, fullname, password) have been provided. Email is also checked to ensure that it is a valid email address. The username is required to be lowercase characters only and unique. The confirmPassword has to match the password provided.

This validation differs from the 'ForAdminPasswordRequired' and 'ForAdmin' validations as follows:


validateCreateUserForSignupOrSetup

public UserService.CreateUserValidationResult validateCreateUserForSignupOrSetup(com.atlassian.crowd.embedded.api.User loggedInUser,
                                                                                 String username,
                                                                                 String password,
                                                                                 String confirmPassword,
                                                                                 String email,
                                                                                 String fullname)
Description copied from interface: UserService
Validates creating a user during setup of JIRA or during public signup. This method checks that there is a writable User Directory available. It also validates that all parameters (username, email, fullname, password) have been provided. Email is also checked to ensure that it is a valid email address. The username is required to be lowercase characters only and unique. The confirmPassword has to match the password provided.

This validation differs from the 'ForAdminPasswordRequired' and 'ForAdmin' validations as follows:


validateCreateUserForAdminPasswordRequired

public UserService.CreateUserValidationResult validateCreateUserForAdminPasswordRequired(com.atlassian.crowd.embedded.api.User user,
                                                                                         String username,
                                                                                         String password,
                                                                                         String confirmPassword,
                                                                                         String email,
                                                                                         String fullname)
Description copied from interface: UserService
Validates creating a user for RPC calls. This method checks that external user management is disabled and that the user performing the operation has global admin rights. It also validates that all parameters (username, email, fullname, password) have been provided. Email is also checked to ensure that it is a valid email address. The username is required to be lowercase characters only and unique. The confirmPassword has to match the password provided.

This validation differs from the 'ForSetup' and 'ForAdmin' validations as follows:


validateCreateUserForAdmin

public UserService.CreateUserValidationResult validateCreateUserForAdmin(com.atlassian.crowd.embedded.api.User user,
                                                                         String username,
                                                                         String password,
                                                                         String confirmPassword,
                                                                         String email,
                                                                         String fullname)
Description copied from interface: UserService
Validates creating a user for the admin section. This method checks that external user management is disabled and that the user performing the operation has global admin rights. It also validates that all parameters (username, email, fullname) except for the password have been provided. Email is also checked to ensure that it is a valid email address. The username is required to be lowercase characters only and unique. The confirmPassword has to match the password provided.

This validation differs from the 'ForSetup' and 'ForAdminPasswordRequired' validations as follows:

Specified by:
validateCreateUserForAdmin in interface UserService
Parameters:
user - The remote user trying to add a new user
username - 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 user
Returns:
a validation result containing appropriate errors or the new user's details

validateCreateUserForAdmin

public UserService.CreateUserValidationResult validateCreateUserForAdmin(com.atlassian.crowd.embedded.api.User user,
                                                                         String username,
                                                                         String password,
                                                                         String confirmPassword,
                                                                         String email,
                                                                         String fullname,
                                                                         @Nullable
                                                                         Long directoryId)
Description copied from interface: UserService
Validates creating a user for the admin section. This method checks that external user management is disabled and that the user performing the operation has global admin rights. It also validates that all parameters (username, email, fullname) except for the password have been provided. Email is also checked to ensure that it is a valid email address. The username is required to be lowercase characters only and unique. The confirmPassword has to match the password provided.

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:

Specified by:
validateCreateUserForAdmin in interface UserService
Parameters:
user - The remote user trying to add a new user
username - 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 user
directoryId - The User Directory
Returns:
a validation result containing appropriate errors or the new user's details

validateCreateUsername

public UserService.CreateUsernameValidationResult validateCreateUsername(com.atlassian.crowd.embedded.api.User loggedInUser,
                                                                         String username)
Description copied from interface: UserService
Validates the username for a new user. The username is required to be lowercase characters only and unique across all directories.

Specified by:
validateCreateUsername in interface UserService
Parameters:
loggedInUser - The remote user trying to add a new user
username - The username of the new user. Needs to be lowercase and unique.
Returns:
a validation result containing appropriate errors

validateCreateUsername

public UserService.CreateUsernameValidationResult validateCreateUsername(com.atlassian.crowd.embedded.api.User loggedInUser,
                                                                         String username,
                                                                         Long directoryId)
Description copied from interface: UserService
Validates the username for a new user. The username is required to be lowercase characters only and unique in the given directory.

Specified by:
validateCreateUsername in interface UserService
Parameters:
loggedInUser - The remote user trying to add a new user
username - 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.
Returns:
a validation result containing appropriate errors

createUserNoNotification

public com.atlassian.crowd.embedded.api.User createUserNoNotification(UserService.CreateUserValidationResult result)
                                                               throws PermissionException,
                                                                      CreateException
Description copied from interface: UserService
Given a valid validation result, this will create the user using the details provided in the validation result. No email notification will be send to created user.

Specified by:
createUserNoNotification in interface UserService
Parameters:
result - The validation result
Returns:
The new user object that was created
Throws:
PermissionException - If you cannot create users in this directory (it is read-only).
CreateException - if the user could not be created, eg username already exists

createUserFromSignup

public com.atlassian.crowd.embedded.api.User createUserFromSignup(UserService.CreateUserValidationResult result)
                                                           throws PermissionException,
                                                                  CreateException
Description copied from interface: UserService
Given a valid validation result, this will create the user using the details provided in the validation result. Email notification will be send to created user - via UserEventType.USER_SIGNUP event.

Specified by:
createUserFromSignup in interface UserService
Parameters:
result - The validation result
Returns:
The new user object that was created
Throws:
PermissionException - If you cannot create users in this directory (it is read-only).
CreateException - if the user could not be created, eg username already exists

createUserWithNotification

public com.atlassian.crowd.embedded.api.User createUserWithNotification(UserService.CreateUserValidationResult result)
                                                                 throws PermissionException,
                                                                        CreateException
Description copied from interface: UserService
Given a valid validation result, this will create the user using the details provided in the validation result. Email notification will be send to created user - via UserEventType.USER_CREATED event.

Specified by:
createUserWithNotification in interface UserService
Parameters:
result - The validation result
Returns:
The new user object that was created
Throws:
PermissionException - If you cannot create users in this directory (it is read-only).
CreateException - if the user could not be created, eg username already exists

validateUpdateUser

public UserService.UpdateUserValidationResult validateUpdateUser(com.atlassian.crowd.embedded.api.User user)
Description copied from interface: UserService
Validates updating a user's details.

Specified by:
validateUpdateUser in interface UserService
Parameters:
user - The user details to update
Returns:
A validation result containing any errors and all user details

updateUser

public void updateUser(UserService.UpdateUserValidationResult updateUserValidationResult)
Description copied from interface: UserService
Execute the update using the validation result from UserService.validateUpdateUser(User).

Specified by:
updateUser in interface UserService
Parameters:
updateUserValidationResult - Result from the validation, which also contains all the user's details.

validateDeleteUser

public UserService.DeleteUserValidationResult validateDeleteUser(com.atlassian.crowd.embedded.api.User loggedInUser,
                                                                 String username)
Description copied from interface: UserService
Validates removing a user for the admin section. This method checks that external user management is disabled and that the user performing the operation has global admin rights. It also validates that username have been provided.

Removing the user is not allowed if:

Specified by:
validateDeleteUser in interface UserService
Parameters:
loggedInUser - The remote user trying to remove a user
username - The username of the user to remove. Needs to be valid
Returns:
a validation result containing appropriate errors or the user object for delete

removeUser

public void removeUser(com.atlassian.crowd.embedded.api.User loggedInUser,
                       UserService.DeleteUserValidationResult result)
Description copied from interface: UserService
Given a valid validation result, this will remove the user and removes the user from all the groups. All components lead by user will have lead cleared.

Specified by:
removeUser in interface UserService
Parameters:
loggedInUser - the user performing operation
result - The validation result


Copyright © 2002-2012 Atlassian. All Rights Reserved.