Class JCASaltedHashService

java.lang.Object
org.exoplatform.web.security.hash.JCASaltedHashService
All Implemented Interfaces:
SaltedHashService

public class JCASaltedHashService extends Object implements SaltedHashService
A SaltedHashService implementation using a SecretKeyFactory for salted hashing.
Author:
Peter Palaga
  • Field Details

  • Constructor Details

    • JCASaltedHashService

      public JCASaltedHashService(String algorithm, int iterationCount, int saltLength, int hashLength, SaltedHashCodec codec)
      Parameters:
      algorithm -
      iterationCount -
      saltLength -
      hashLength -
      codec -
    • JCASaltedHashService

      public JCASaltedHashService()
  • Method Details

    • getSaltedHash

      public String getSaltedHash(String password) throws SaltedHashException
      Description copied from interface: SaltedHashService
      Computes a salted hash of given plaintext password suitable for storing in a database.
      Specified by:
      getSaltedHash in interface SaltedHashService
      Throws:
      SaltedHashException
    • validate

      public boolean validate(String password, String encodedSaltedHash) throws SaltedHashException
      Description copied from interface: SaltedHashService
      Checks whether given plaintext password corresponds to the given saltedHash.
      Specified by:
      validate in interface SaltedHashService
      Parameters:
      password -
      encodedSaltedHash -
      Returns:
      true if the given password matches the given saltedHash; false otherwise.
      Throws:
      SaltedHashException - if the saltedHash cannot be parsed or if the hashing algorithm is not available.
    • getIterationCount

      public int getIterationCount()
      Returns:
      the iterationCount
      See Also:
      • iterationCount
    • setIterationCount

      public void setIterationCount(int iterationCount)
      Parameters:
      iterationCount - the iterationCount to set
      See Also:
      • iterationCount
    • getSaltByteLength

      public int getSaltByteLength()
      Returns:
      the saltLength
      See Also:
      • saltByteLength
    • setSaltLength

      public void setSaltLength(int saltLength)
      Parameters:
      saltLength - the saltLength to set
      See Also:
      • saltByteLength
    • getHashByteLength

      public int getHashByteLength()
      Returns:
      the hashLength
      See Also:
      • hashByteLength
    • setHashLength

      public void setHashLength(int hashLength)
      Parameters:
      hashLength - the hashLength to set
      See Also:
      • hashByteLength
    • getAlgorithm

      public String getAlgorithm()
      Returns:
      the algorithm
      See Also:
      • algorithm
    • setAlgorithm

      public void setAlgorithm(String algorithm)
      Parameters:
      algorithm - the algorithm to set
      See Also:
      • algorithm
    • getCodec

      public SaltedHashCodec getCodec()
      Returns:
      the codec
      See Also:
      • codec
    • setCodec

      public void setCodec(SaltedHashCodec codec)
      Parameters:
      codec - the codec to set
      See Also:
      • codec