Class ForgottenLoginManagerImpl
java.lang.Object
com.atlassian.crowd.manager.login.ForgottenLoginManagerImpl
- All Implemented Interfaces:
ForgottenLoginManager
@Transactional
public class ForgottenLoginManagerImpl
extends Object
implements ForgottenLoginManager
-
Field Summary
Fields inherited from interface com.atlassian.crowd.manager.login.ForgottenLoginManager
DEFAULT_TOKEN_EXPIRY -
Constructor Summary
ConstructorsConstructorDescriptionForgottenLoginManagerImpl(ApplicationService applicationService, DirectoryManager directoryManager, PermissionManager permissionManager, ExpirableUserTokenDao expirableUserTokenDao, com.atlassian.security.random.SecureTokenGenerator tokenGenerator, com.atlassian.event.api.EventPublisher eventPublisher, com.atlassian.sal.api.ApplicationProperties applicationProperties, ForgottenLoginMailer forgottenLoginMailer, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptioncreateAndStoreResetToken(long directoryId, String username, String email, int tokenExpirySeconds) Creates anExpirableUserTokenfor a given username in the given directory.getResetLink(ExpirableUserToken resetToken) Returns password reset token for given user.booleanisUserActive(long directoryId, String username) Check if user is activebooleanisValidResetToken(long directoryId, String username, String token) Returnstrueif the password reset token for the user with the specified username and directory ID are valid and not expired.booleanremoveByDirectoryAndUsername(long directoryId, String username) Removes the password reset tokens associated to a username in a directory.voidresetUserCredential(long directoryId, String username, PasswordCredential credential, String token) Resets the user credentials and invalidates the token.voidsendResetLink(long directoryId, String username, int tokenExpirySeconds) Sends a reset link to the user with specified username and directory ID.voidsendResetLink(Application application, String username, int tokenExpirySeconds) Sends a reset link to the first user with the matchingusernamefrom all the active directories assigned to the application.booleansendUsernames(Application application, String email) Sends the usernames associated with the given email address.
-
Constructor Details
-
ForgottenLoginManagerImpl
public ForgottenLoginManagerImpl(ApplicationService applicationService, DirectoryManager directoryManager, PermissionManager permissionManager, ExpirableUserTokenDao expirableUserTokenDao, com.atlassian.security.random.SecureTokenGenerator tokenGenerator, com.atlassian.event.api.EventPublisher eventPublisher, com.atlassian.sal.api.ApplicationProperties applicationProperties, ForgottenLoginMailer forgottenLoginMailer, Clock clock)
-
-
Method Details
-
sendResetLink
public void sendResetLink(Application application, String username, int tokenExpirySeconds) throws UserNotFoundException, InvalidEmailAddressException, ApplicationPermissionException, MailSendException Description copied from interface:ForgottenLoginManagerSends a reset link to the first user with the matchingusernamefrom all the active directories assigned to the application.- Specified by:
sendResetLinkin interfaceForgottenLoginManager- Parameters:
application- user is searched inapplication's assigned directoriesusername- username of the user to send the password reset linktokenExpirySeconds- number of seconds before generated token expires, or DEFAULT_TOKEN_EXPIRY_SECONDS- Throws:
UserNotFoundException- if no user with the supplied username existsInvalidEmailAddressException- if the user does not have a valid email address to send the password reset email toApplicationPermissionException- if the application does not have permission to modify the userMailSendException
-
sendUsernames
public boolean sendUsernames(Application application, String email) throws InvalidEmailAddressException Description copied from interface:ForgottenLoginManagerSends the usernames associated with the given email address. No email will be sent if there are no usernames associated with a given
email.The method returns a boolean, which should only ever be passed to authenticated applications to avoid leaking information.
- Specified by:
sendUsernamesin interfaceForgottenLoginManager- Parameters:
application- search application's assigned directories for usernames associated with theemailemail- email address of the user- Returns:
trueif any users with that address were found.- Throws:
InvalidEmailAddressException- if theemailis not valid
-
sendResetLink
public void sendResetLink(long directoryId, String username, int tokenExpirySeconds) throws DirectoryNotFoundException, InvalidEmailAddressException, UserNotFoundException, OperationFailedException, MailSendException Description copied from interface:ForgottenLoginManagerSends a reset link to the user with specified username and directory ID.Similar to
ForgottenLoginManager.sendResetLink(Application, String, int)except applying to a directory-specific user.- Specified by:
sendResetLinkin interfaceForgottenLoginManager- Parameters:
directoryId- directory ID of the user to modifyusername- username of the user to send the password reset linktokenExpirySeconds- number of seconds before generated token expires, or DEFAULT_TOKEN_EXPIRY_SECONDS- Throws:
DirectoryNotFoundException- if the directory specified bydirectoryIdcould not be foundInvalidEmailAddressException- if the user does not have a valid email address to send the password reset email toUserNotFoundException- if the user specified byusernamecould not be foundOperationFailedExceptionMailSendException
-
isValidResetToken
Description copied from interface:ForgottenLoginManagerReturnstrueif the password reset token for the user with the specified username and directory ID are valid and not expired. The valid password reset token is created byForgottenLoginManager.sendResetLink(com.atlassian.crowd.model.application.Application, java.lang.String, int).- Specified by:
isValidResetTokenin interfaceForgottenLoginManager- Parameters:
directoryId- directory ID of the user to validateusername- username of the user to verify thetokentoken- password reset token- Returns:
trueif the username and reset token are a valid combination and the reset token has not expired.
-
getResetLink
- Specified by:
getResetLinkin interfaceForgottenLoginManager
-
getToken
Description copied from interface:ForgottenLoginManagerReturns password reset token for given user. For testing purposes only.- Specified by:
getTokenin interfaceForgottenLoginManager
-
createAndStoreResetToken
public ExpirableUserToken createAndStoreResetToken(long directoryId, String username, String email, int tokenExpirySeconds) Description copied from interface:ForgottenLoginManagerCreates anExpirableUserTokenfor a given username in the given directory. Note: no check is done to verify that the user actually exists in the given directory; if this is not the case, the returned token will be useless.- Specified by:
createAndStoreResetTokenin interfaceForgottenLoginManager- Parameters:
directoryId- the directory id associated with the userusername- the username of the user to create the token foremail- the email of the user to create the token fortokenExpirySeconds- number of seconds before generated token expires, or DEFAULT_TOKEN_EXPIRY_SECONDS- Returns:
- The ExpirableUserToken
-
removeByDirectoryAndUsername
Description copied from interface:ForgottenLoginManagerRemoves the password reset tokens associated to a username in a directory.- Specified by:
removeByDirectoryAndUsernamein interfaceForgottenLoginManager- Parameters:
directoryId- directory where the user livesusername- username- Returns:
trueif some tokens were removed
-
isUserActive
Description copied from interface:ForgottenLoginManagerCheck if user is active- Specified by:
isUserActivein interfaceForgottenLoginManager- Parameters:
directoryId- directory where the user livesusername- username- Returns:
trueif user is active
-
resetUserCredential
public void resetUserCredential(long directoryId, String username, PasswordCredential credential, String token) throws DirectoryNotFoundException, UserNotFoundException, InvalidResetPasswordTokenException, OperationFailedException, InvalidCredentialException, DirectoryPermissionException Description copied from interface:ForgottenLoginManagerResets the user credentials and invalidates the token.- Specified by:
resetUserCredentialin interfaceForgottenLoginManager- Parameters:
directoryId- directory ID of the userusername- user name of the user to perform a credential resetcredential- new credentialstoken- password reset token- Throws:
DirectoryNotFoundException- if the directory could not be found.UserNotFoundException- if the user could not be found in the given directory.InvalidResetPasswordTokenException- if the reset token is not valid.OperationFailedException- if there was an error performing the operation or instantiating the backend directory.InvalidCredentialException- if the user's credential does not meet the validation requirements for an associated directory.DirectoryPermissionException- if the directory is not allowed to perform the operation
-