Interface PasswordHasher

All Known Implementing Classes:
SpringPasswordHasher

public interface PasswordHasher
Port that hashes and checks passwords. The implementation chooses the algorithm; an encoded password carries its own prefix so that older encodings can still be checked and upgraded. Never used with a null argument.
  • Method Summary

    Modifier and Type
    Method
    Description
    encode(CharSequence rawPassword)
    Encodes a clear-text password (or a client secret) with the current algorithm.
    boolean
    matches(CharSequence rawPassword, String encodedPassword)
    Checks a clear-text password against an encoded one.
    boolean
    upgradeEncoding(String encodedPassword)
    Tells whether a stored encoding is weaker than the current algorithm and should be replaced the next time the clear-text password is known.
  • Method Details

    • encode

      String encode(CharSequence rawPassword)
      Encodes a clear-text password (or a client secret) with the current algorithm.
      Parameters:
      rawPassword - the clear-text value.
      Returns:
      the encoded value, including its encoding prefix.
    • matches

      boolean matches(CharSequence rawPassword, String encodedPassword)
      Checks a clear-text password against an encoded one.
      Parameters:
      rawPassword - the clear-text value.
      encodedPassword - the stored encoded value.
      Returns:
      true when they match.
    • upgradeEncoding

      boolean upgradeEncoding(String encodedPassword)
      Tells whether a stored encoding is weaker than the current algorithm and should be replaced the next time the clear-text password is known.
      Parameters:
      encodedPassword - the stored encoded value.
      Returns:
      true when the password should be re-encoded.