Class PKCS5S2PasswordHashGenerator

java.lang.Object
com.atlassian.security.password.PKCS5S2PasswordHashGenerator
All Implemented Interfaces:
PasswordHashGenerator

public final class PKCS5S2PasswordHashGenerator extends Object implements PasswordHashGenerator
Encodes passwords using PKCS 5 version 2, as published by RSA and implemented in BouncyCastle. The iteration count is 10000 and the provided salt must be exactly 16 bytes. The generated hash will be 256 bits (32 bytes) long.

Clients should not use this class directly, but pass an instance to DefaultPasswordEncoder.

This generator is safe for use on multiple threads because it creates a new instance of the underlying generator for each call to generateHash(byte[], byte[]).

See Also:
  • Constructor Details

    • PKCS5S2PasswordHashGenerator

      public PKCS5S2PasswordHashGenerator()
  • Method Details

    • generateHash

      public byte[] generateHash(byte[] rawPassword, byte[] salt)
      Description copied from interface: PasswordHashGenerator
      Encodes the rawPassword bytes and salt according to their method specified by the implementation. The encoded bytes should be returned without including the salt.
      Specified by:
      generateHash in interface PasswordHashGenerator
      Parameters:
      rawPassword - the password to be encoded
      salt - a salt which may be used by some algorithms
      Returns:
      the encoded password bytes (without appending or prepending the salt)
    • getRequiredSaltLength

      public int getRequiredSaltLength()
      Description copied from interface: PasswordHashGenerator
      Returns the required salt length for this hash generator, zero if this generator does not require a salt or -1 if the generator accepts salts of varying length.
      Specified by:
      getRequiredSaltLength in interface PasswordHashGenerator