public class JCASaltedHashService extends Object implements SaltedHashService
SaltedHashService implementation using a SecretKeyFactory for salted hashing.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_HASH_BYTE_LENGTH |
static int |
DEFAULT_ITERATION_COUNT |
static int |
DEFAULT_SALT_BYTE_LENGTH |
static String |
PBKDF2_WITH_HMAC_SHA1 |
| Constructor and Description |
|---|
JCASaltedHashService() |
JCASaltedHashService(String algorithm,
int iterationCount,
int saltLength,
int hashLength,
SaltedHashCodec codec) |
| Modifier and Type | Method and Description |
|---|---|
String |
getAlgorithm() |
SaltedHashCodec |
getCodec() |
int |
getHashByteLength() |
int |
getIterationCount() |
int |
getSaltByteLength() |
String |
getSaltedHash(String password)
Computes a salted hash of given plaintext password suitable for storing in a database.
|
void |
setAlgorithm(String algorithm) |
void |
setCodec(SaltedHashCodec codec) |
void |
setHashLength(int hashLength) |
void |
setIterationCount(int iterationCount) |
void |
setSaltLength(int saltLength) |
boolean |
validate(String password,
String encodedSaltedHash)
Checks whether given plaintext
password corresponds to the given saltedHash. |
public static final String PBKDF2_WITH_HMAC_SHA1
public static final int DEFAULT_SALT_BYTE_LENGTH
public static final int DEFAULT_HASH_BYTE_LENGTH
public static final int DEFAULT_ITERATION_COUNT
public JCASaltedHashService(String algorithm, int iterationCount, int saltLength, int hashLength, SaltedHashCodec codec)
algorithm - iterationCount - saltLength - hashLength - codec - public JCASaltedHashService()
public String getSaltedHash(String password) throws SaltedHashException
SaltedHashServicegetSaltedHash in interface SaltedHashServiceSaltedHashExceptionpublic boolean validate(String password, String encodedSaltedHash) throws SaltedHashException
SaltedHashServicepassword corresponds to the given saltedHash.validate in interface SaltedHashServicetrue if the given password matches the given saltedHash; false otherwise.SaltedHashException - if the saltedHash cannot be parsed or if the hashing algorithm is not available.public int getIterationCount()
iterationCountpublic void setIterationCount(int iterationCount)
iterationCount - the iterationCount to setiterationCountpublic int getSaltByteLength()
saltByteLengthpublic void setSaltLength(int saltLength)
saltLength - the saltLength to setsaltByteLengthpublic int getHashByteLength()
hashByteLengthpublic void setHashLength(int hashLength)
hashLength - the hashLength to sethashByteLengthpublic void setAlgorithm(String algorithm)
algorithm - the algorithm to setalgorithmpublic SaltedHashCodec getCodec()
codecpublic void setCodec(SaltedHashCodec codec)
codec - the codec to setcodecCopyright © 2018 JBoss by Red Hat. All Rights Reserved.