Class JCASaltedHashService
java.lang.Object
org.exoplatform.web.security.hash.JCASaltedHashService
- All Implemented Interfaces:
SaltedHashService
A
SaltedHashService implementation using a SecretKeyFactory for salted hashing.- Author:
- Peter Palaga
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionJCASaltedHashService(String algorithm, int iterationCount, int saltLength, int hashLength, SaltedHashCodec codec) -
Method Summary
Modifier and TypeMethodDescriptiongetCodec()intintintgetSaltedHash(String password) Computes a salted hash of given plaintext password suitable for storing in a database.voidsetAlgorithm(String algorithm) voidsetCodec(SaltedHashCodec codec) voidsetHashLength(int hashLength) voidsetIterationCount(int iterationCount) voidsetSaltLength(int saltLength) booleanChecks whether given plaintextpasswordcorresponds to the givensaltedHash.
-
Field Details
-
PBKDF2_WITH_HMAC_SHA1
- See Also:
-
DEFAULT_SALT_BYTE_LENGTH
public static final int DEFAULT_SALT_BYTE_LENGTH- See Also:
-
DEFAULT_HASH_BYTE_LENGTH
public static final int DEFAULT_HASH_BYTE_LENGTH- See Also:
-
DEFAULT_ITERATION_COUNT
public static final int DEFAULT_ITERATION_COUNT- See Also:
-
-
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
Description copied from interface:SaltedHashServiceComputes a salted hash of given plaintext password suitable for storing in a database.- Specified by:
getSaltedHashin interfaceSaltedHashService- Throws:
SaltedHashException
-
validate
Description copied from interface:SaltedHashServiceChecks whether given plaintextpasswordcorresponds to the givensaltedHash.- Specified by:
validatein interfaceSaltedHashService- Parameters:
password-encodedSaltedHash-- Returns:
trueif the givenpasswordmatches the givensaltedHash;falseotherwise.- Throws:
SaltedHashException- if thesaltedHashcannot be parsed or if the hashing algorithm is not available.
-
getIterationCount
public int getIterationCount()- Returns:
- the iterationCount
- See Also:
-
setIterationCount
public void setIterationCount(int iterationCount) - Parameters:
iterationCount- the iterationCount to set- See Also:
-
getSaltByteLength
public int getSaltByteLength()- Returns:
- the saltLength
- See Also:
-
setSaltLength
public void setSaltLength(int saltLength) - Parameters:
saltLength- the saltLength to set- See Also:
-
getHashByteLength
public int getHashByteLength()- Returns:
- the hashLength
- See Also:
-
setHashLength
public void setHashLength(int hashLength) - Parameters:
hashLength- the hashLength to set- See Also:
-
getAlgorithm
- Returns:
- the algorithm
- See Also:
-
setAlgorithm
- Parameters:
algorithm- the algorithm to set- See Also:
-
getCodec
- Returns:
- the codec
- See Also:
-
setCodec
- Parameters:
codec- the codec to set- See Also:
-