org.appng.core.security

## Interface PasswordHandler

- All Known Implementing Classes:
    BCryptPasswordHandler, Sha1PasswordHandler

      public interface PasswordHandler

  Provides methods to handle passwords. Different implementations of this interface can provide different algorithms to hash, salt and store a password. It can be expected that the constructor of an implementation of this interface requires an `AuthSubject` as argument.
  Author:
    Matthias Herlitzius

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `applyPassword(String password)` Hashes and sets the password, clears the salt, sets the last changed date for the password
    `String` | `calculatePasswordResetDigest()` Calculates, sets and returns a salted digest which can be used for the "Forgot password?" function.
    `default String` | `getPasswordResetDigest()` Deprecated. will be removed in 2.x
    `boolean` | `isValidPassword(String password)` Checks whether the password is valid for the current `AuthSubject`.
    `boolean` | `isValidPasswordResetDigest(String digest)` Checks whether the digest is valid for the current `AuthSubject`.
    `void` | `migrate(CoreService service, String password)` Migrates passwords of the current `PasswordHandler` instance to passwords handled by `CoreService.getDefaultPasswordHandler(org.appng.api.model.AuthSubject)`.
    `default void` | `savePassword(String password)` Deprecated. will be removed in 2.x
    `default void` | `updateSubject(CoreService service)` Deprecated. will be removed in 2.x

- - ### Method Detail

    - #### applyPassword

          void applyPassword(String password)

      Hashes and sets the password, clears the salt, sets the last changed date for the password
      Parameters:
        `password` - The cleartext password.
      See Also:
        `AuthSubject.setDigest(String)`, `AuthSubject.setSalt(String)`, `AuthSubject.setPasswordLastChanged(java.util.Date)`

    - #### isValidPassword

          boolean isValidPassword(String password)

      Checks whether the password is valid for the current `AuthSubject`.
      Parameters:
        `password` - The cleartext password.
      Returns:
        `true` if the password is valid, false if it is invalid.
      See Also:
        `AuthSubject.getDigest()`

    - #### calculatePasswordResetDigest

          String calculatePasswordResetDigest()

      Calculates, sets and returns a salted digest which can be used for the "Forgot password?" function.
      Returns:
        A digest.
      See Also:
        `AuthSubject.setSalt(String)`, `isValidPasswordResetDigest(String)`

    - #### isValidPasswordResetDigest

          boolean isValidPasswordResetDigest(String digest)

      Checks whether the digest is valid for the current `AuthSubject`.
      Parameters:
        `digest` - The digest.
      Returns:
        `true` if the digest is valid, false if it is invalid.
      See Also:
        `AuthSubject.getSalt()`, `calculatePasswordResetDigest()`

    - #### migrate

          void migrate(CoreService service,
                       String password)

      Migrates passwords of the current `PasswordHandler` instance to passwords handled by `CoreService.getDefaultPasswordHandler(org.appng.api.model.AuthSubject)`.
      Parameters:
        `service` - Instance of `CoreService`
        `password` - The current password.

    - #### updateSubject

          @Deprecated
          default void updateSubject(CoreService service)
                                          throws BusinessException

      Deprecated. will be removed in 2.x
      Throws:
        `BusinessException`

    - #### getPasswordResetDigest

          @Deprecated
          default String getPasswordResetDigest()

      Deprecated. will be removed in 2.x

    - #### savePassword

          @Deprecated
          default void savePassword(String password)

      Deprecated. will be removed in 2.x

Copyright © 2011–2023 aiticon GmbH. All rights reserved.