Class EmailChangeManagerImpl
java.lang.Object
com.atlassian.crowd.service.email.EmailChangeManagerImpl
- All Implemented Interfaces:
EmailChangeManager
-
Constructor Summary
ConstructorsConstructorDescriptionEmailChangeManagerImpl(ChangeEmailLinkMailer changeEmailLinkMailer, com.atlassian.security.random.SecureTokenGenerator tokenGenerator, ExpirableUserTokenDao expirableUserTokenDao, ApplicationService applicationService, com.atlassian.sal.api.ApplicationProperties applicationProperties, Clock clock, ApplicationManager applicationManager, ClientProperties clientProperties, com.atlassian.event.api.EventPublisher eventPublisher, DirectoryManager directoryManager, MailConfigurationService mailConfigurationService, PermissionManager permissionManager, EmailAddressValidator emailValidator) -
Method Summary
Modifier and TypeMethodDescriptionvoidAborts a pending e-mail validation for a given user in crowd app.voidchangeEmail(String token, String username) Changes e-mail for a user in crowd app.getPendingNewEmailByToken(String token) Returns new e-mail address for a e-mail change token.getPendingNewEmailByUser(String username, long directoryId) Returns new e-mail address for a user in crowd app for whom there's a pending e-mail verification.booleanhasUserEmailChangePending(String username, long directoryId) Returns true if there is a pending e-mail verification for a user in crowd app, false otherwise.booleanisAvailableForDirectory(long dirId) Returns true if e-mail change by end-user feature is available for a given directory.booleanisTokenValid(String token) Returns true if a given token is a valid e-mail change verification token.voidresendEmail(String username, long directoryId) Resends an e-mail with a new token for a user in crowd app that has a pending e-mail verification.voidsendEmailAuthorization(String username, String password, long directoryId, String newEmail) Starts e-mail change flow for a user in crowd app, by sending two e-mails.
-
Constructor Details
-
EmailChangeManagerImpl
public EmailChangeManagerImpl(ChangeEmailLinkMailer changeEmailLinkMailer, com.atlassian.security.random.SecureTokenGenerator tokenGenerator, ExpirableUserTokenDao expirableUserTokenDao, ApplicationService applicationService, com.atlassian.sal.api.ApplicationProperties applicationProperties, Clock clock, ApplicationManager applicationManager, ClientProperties clientProperties, com.atlassian.event.api.EventPublisher eventPublisher, DirectoryManager directoryManager, MailConfigurationService mailConfigurationService, PermissionManager permissionManager, EmailAddressValidator emailValidator)
-
-
Method Details
-
sendEmailAuthorization
public void sendEmailAuthorization(String username, String password, long directoryId, String newEmail) throws InvalidAuthenticationException, InvalidEmailAddressException, MailSendException, OperationNotPermittedException, ApplicationNotFoundException, SameEmailAddressException Description copied from interface:EmailChangeManagerStarts e-mail change flow for a user in crowd app, by sending two e-mails. First one to the current user's e-mail and the second one to thenewEmail. The first one contains info for an ongoing e-mail change. The second one contains a link with a token which is required to change an e-mail. In order to do change an e-mail,EmailChangeManager.changeEmail(java.lang.String, java.lang.String)needs to be called with the aforementioned token passed as an argument.- Specified by:
sendEmailAuthorizationin interfaceEmailChangeManager- Parameters:
username- username of the user for whom we're changing an e-mailpassword- password of the user for whom we're changing an e-maildirectoryId- directory ID of the user for whom we're changing an e-mailnewEmail- e-mail to which we'll replace an old email of the user- Throws:
InvalidAuthenticationException- if authentication fails for givenusernameandpasswordInvalidEmailAddressException- if passednewEmailis not a valid e-mail addressMailSendException- if Crowd failed to send e-mail with a tokenOperationNotPermittedException- if feature is not availableApplicationNotFoundException- if 'crowd' app has not been foundSameEmailAddressException- if passednewEmailis the same as the one currently used by a user
-
changeEmail
public void changeEmail(String token, String username) throws UserNotFoundException, InvalidChangeEmailTokenException, InvalidAuthenticationException, OperationFailedException, ApplicationNotFoundException, OperationNotPermittedException Description copied from interface:EmailChangeManagerChanges e-mail for a user in crowd app.This method SHALL only be called after calling
EmailChangeManager.sendEmailAuthorization(java.lang.String, java.lang.String, long, java.lang.String).- Specified by:
changeEmailin interfaceEmailChangeManager- Parameters:
token- token sent in email byEmailChangeManager.sendEmailAuthorization(java.lang.String, java.lang.String, long, java.lang.String)username- username of the user for whom we're changing an e-mail- Throws:
UserNotFoundException- if user does not existInvalidChangeEmailTokenException- if providetokenis not validInvalidAuthenticationException- if user identified byusernameis not the one who generated a tokenOperationFailedException- if Crowd failed to update e-mailApplicationNotFoundException- if 'crowd' app has not been foundOperationNotPermittedException- if feature is not available
-
hasUserEmailChangePending
Description copied from interface:EmailChangeManagerReturns true if there is a pending e-mail verification for a user in crowd app, false otherwise.- Specified by:
hasUserEmailChangePendingin interfaceEmailChangeManager- Parameters:
username- username of the userdirectoryId- directory ID of the user- Returns:
- true if there is a pending e-mail verification for a user, false otherwise
-
getPendingNewEmailByUser
Description copied from interface:EmailChangeManagerReturns new e-mail address for a user in crowd app for whom there's a pending e-mail verification.- Specified by:
getPendingNewEmailByUserin interfaceEmailChangeManager- Parameters:
username- username of the userdirectoryId- directory ID of the user- Returns:
- new e-mail address
-
getPendingNewEmailByToken
Description copied from interface:EmailChangeManagerReturns new e-mail address for a e-mail change token.- Specified by:
getPendingNewEmailByTokenin interfaceEmailChangeManager- Parameters:
token- e-mail change token- Returns:
- new e-mail address
-
resendEmail
public void resendEmail(String username, long directoryId) throws InvalidEmailAddressException, MailSendException, UserNotFoundException, ApplicationNotFoundException Description copied from interface:EmailChangeManagerResends an e-mail with a new token for a user in crowd app that has a pending e-mail verification. Old token is invalidated.- Specified by:
resendEmailin interfaceEmailChangeManager- Parameters:
username- of the userdirectoryId- directory ID of the user- Throws:
InvalidEmailAddressException- if pending e-mail address is not a valid e-mail addressMailSendException- if Crowd failed to re-send e-mail with a tokenUserNotFoundException- if user does not existApplicationNotFoundException- if 'crowd' app has not been found
-
abort
Description copied from interface:EmailChangeManagerAborts a pending e-mail validation for a given user in crowd app.- Specified by:
abortin interfaceEmailChangeManager- Parameters:
username- username of the userdirectoryId- directory ID of the user
-
isTokenValid
Description copied from interface:EmailChangeManagerReturns true if a given token is a valid e-mail change verification token. False otherwise.- Specified by:
isTokenValidin interfaceEmailChangeManager- Parameters:
token- e-mail change token- Returns:
- true if a given token is a valid e-mail change verification token, false otherwise
-
isAvailableForDirectory
public boolean isAvailableForDirectory(long dirId) Description copied from interface:EmailChangeManagerReturns true if e-mail change by end-user feature is available for a given directory. False otherwise.Feature might be disabled for a given directory because: - Crowd's e-mail server is NOT configured - Directory does not have permissions to change user e-mail
- Specified by:
isAvailableForDirectoryin interfaceEmailChangeManager- Parameters:
dirId- ID of the directory- Returns:
- true if e-mail change by end-user feature is available for a given directory, false otherwise.
-