Class MessageDigestPasswordEncoder

java.lang.Object
io.gravitee.am.service.authentication.crypto.password.MessageDigestPasswordEncoder
All Implemented Interfaces:
PasswordEncoder
Direct Known Subclasses:
MD5PasswordEncoder, SHAPasswordEncoder

public abstract class MessageDigestPasswordEncoder extends Object implements PasswordEncoder
Author:
Titouan COMPIEGNE (titouan.compiegne at graviteesource.com), GraviteeSource Team
  • Constructor Details

    • MessageDigestPasswordEncoder

      public MessageDigestPasswordEncoder(String algorithm)
  • Method Details

    • encode

      public String encode(CharSequence rawPassword)
      Description copied from interface: PasswordEncoder
      Encode the raw password. Generally, a good encoding algorithm applies a SHA-1 or greater hash combined with an 8-byte or greater randomly generated salt.
      Specified by:
      encode in interface PasswordEncoder
      Parameters:
      rawPassword - the raw password to encode
    • encode

      public String encode(CharSequence rawPassword, byte[] salt)
      Description copied from interface: PasswordEncoder
      Encode the raw password. Generally, a good encoding algorithm applies a SHA-1 or greater hash combined with an 8-byte or greater randomly generated salt.
      Specified by:
      encode in interface PasswordEncoder
      Parameters:
      rawPassword - the raw password to encode
      salt - the salt use to encode the rawPassword
    • matches

      public boolean matches(CharSequence rawPassword, String encodedPassword)
      Description copied from interface: PasswordEncoder
      Verify the encoded password obtained from storage matches the submitted raw password after it too is encoded. Returns true if the passwords match, false if they do not. The stored password itself is never decoded.
      Specified by:
      matches in interface PasswordEncoder
      Parameters:
      rawPassword - the raw password to encode and match
      encodedPassword - the encoded password from storage to compare with
      Returns:
      true if the raw password, after encoding, matches the encoded password from storage
    • matches

      public boolean matches(CharSequence rawPassword, String encodedPassword, byte[] salt)
      Description copied from interface: PasswordEncoder
      Verify the encoded password obtained from storage matches the submitted raw password after it too is encoded. Returns true if the passwords match, false if they do not. The stored password itself is never decoded.
      Specified by:
      matches in interface PasswordEncoder
      Parameters:
      rawPassword - the raw password to encode and match
      encodedPassword - the encoded password from storage to compare with
      salt - the salt use to compare the rawPassword and the encodedPassword
      Returns:
    • matches

      public boolean matches(CharSequence rawPassword, String encodedPassword, String salt)
      Description copied from interface: PasswordEncoder
      Verify the encoded password obtained from storage matches the submitted raw password after it too is encoded. Returns true if the passwords match, false if they do not. The stored password itself is never decoded.
      Specified by:
      matches in interface PasswordEncoder
      Parameters:
      rawPassword - the raw password to encode and match
      encodedPassword - the encoded password from storage to compare with
      salt - the salt use to compare the rawPassword and the encodedPassword
      Returns:
    • setAlgorithm

      public void setAlgorithm(String algorithm)
    • setEncodeSaltAsBase64

      public void setEncodeSaltAsBase64(boolean encodeSaltAsBase64)
    • setSaltLength

      public void setSaltLength(int saltLength)
    • setPasswordSaltFormat

      public void setPasswordSaltFormat(String passwordSaltFormat)