Class SaltedSimpleDigestPasswordImpl
- java.lang.Object
-
- org.wildfly.security.password.impl.AbstractPasswordImpl
-
- org.wildfly.security.password.impl.SaltedSimpleDigestPasswordImpl
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Key
,SaltedSimpleDigestPassword
,OneWayPassword
,Password
class SaltedSimpleDigestPasswordImpl extends AbstractPasswordImpl implements SaltedSimpleDigestPassword
APassword
implementation forSaltedSimpleDigestPassword
.- Author:
- Darran Lofthouse
-
-
Field Summary
Fields Modifier and Type Field Description private String
algorithm
private byte[]
digest
private byte[]
salt
private static long
serialVersionUID
-
Fields inherited from interface org.wildfly.security.password.interfaces.SaltedSimpleDigestPassword
ALGORITHM_PASSWORD_SALT_DIGEST_MD5, ALGORITHM_PASSWORD_SALT_DIGEST_SHA_1, ALGORITHM_PASSWORD_SALT_DIGEST_SHA_256, ALGORITHM_PASSWORD_SALT_DIGEST_SHA_384, ALGORITHM_PASSWORD_SALT_DIGEST_SHA_512, ALGORITHM_SALT_PASSWORD_DIGEST_MD5, ALGORITHM_SALT_PASSWORD_DIGEST_SHA_1, ALGORITHM_SALT_PASSWORD_DIGEST_SHA_256, ALGORITHM_SALT_PASSWORD_DIGEST_SHA_384, ALGORITHM_SALT_PASSWORD_DIGEST_SHA_512, DEFAULT_SALT_SIZE
-
-
Constructor Summary
Constructors Modifier Constructor Description (package private)
SaltedSimpleDigestPasswordImpl(String algorithm, byte[] salt, byte[] digest)
private
SaltedSimpleDigestPasswordImpl(String algorithm, byte[] salt, char[] password, Charset hashCharset)
(package private)
SaltedSimpleDigestPasswordImpl(String algorithm, char[] password, Charset hashCharset)
(package private)
SaltedSimpleDigestPasswordImpl(String algorithm, char[] password, SaltedPasswordAlgorithmSpec spec, Charset hashCharset)
(package private)
SaltedSimpleDigestPasswordImpl(String algorithm, ClearPasswordSpec spec)
(package private)
SaltedSimpleDigestPasswordImpl(String algorithm, SaltedHashPasswordSpec spec)
(package private)
SaltedSimpleDigestPasswordImpl(SaltedSimpleDigestPassword password)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SaltedSimpleDigestPasswordImpl
clone()
Creates and returns a copy of thisPassword
.(package private) <T extends KeySpec>
booleanconvertibleTo(Class<T> keySpecType)
private static byte[]
digestOf(String algorithm, byte[] salt, char[] password, Charset hashCharset)
boolean
equals(Object obj)
String
getAlgorithm()
byte[]
getDigest()
Get the digest represented by this password.(package private) <S extends KeySpec>
SgetKeySpec(Class<S> keySpecType)
private static MessageDigest
getMessageDigest(String algorithm)
byte[]
getSalt()
Get the salt used to generate the digest.int
hashCode()
private static boolean
isSaltFirst(String algorithm)
private void
readObject(ObjectInputStream ignored)
(package private) boolean
verify(char[] guess)
(package private) boolean
verify(char[] guess, Charset hashCharset)
(package private) Object
writeReplace()
-
Methods inherited from class org.wildfly.security.password.impl.AbstractPasswordImpl
getEncoded, getFormat, getNormalizedPasswordBytes, getNormalizedPasswordBytes, translate
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.security.Key
getEncoded, getFormat
-
Methods inherited from interface org.wildfly.security.password.Password
castAndApply, castAndApply, castAs, castAs
-
Methods inherited from interface org.wildfly.security.password.interfaces.SaltedSimpleDigestPassword
getParameterSpec, impliesParameters
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
algorithm
private final String algorithm
-
digest
private final byte[] digest
-
salt
private final byte[] salt
-
-
Constructor Detail
-
SaltedSimpleDigestPasswordImpl
SaltedSimpleDigestPasswordImpl(String algorithm, byte[] salt, byte[] digest)
-
SaltedSimpleDigestPasswordImpl
SaltedSimpleDigestPasswordImpl(String algorithm, SaltedHashPasswordSpec spec)
-
SaltedSimpleDigestPasswordImpl
SaltedSimpleDigestPasswordImpl(SaltedSimpleDigestPassword password)
-
SaltedSimpleDigestPasswordImpl
SaltedSimpleDigestPasswordImpl(String algorithm, ClearPasswordSpec spec) throws InvalidKeySpecException
- Throws:
InvalidKeySpecException
-
SaltedSimpleDigestPasswordImpl
SaltedSimpleDigestPasswordImpl(String algorithm, char[] password, SaltedPasswordAlgorithmSpec spec, Charset hashCharset) throws InvalidKeySpecException
- Throws:
InvalidKeySpecException
-
SaltedSimpleDigestPasswordImpl
SaltedSimpleDigestPasswordImpl(String algorithm, char[] password, Charset hashCharset) throws InvalidKeySpecException
- Throws:
InvalidKeySpecException
-
SaltedSimpleDigestPasswordImpl
private SaltedSimpleDigestPasswordImpl(String algorithm, byte[] salt, char[] password, Charset hashCharset) throws InvalidKeySpecException
- Throws:
InvalidKeySpecException
-
-
Method Detail
-
getAlgorithm
public String getAlgorithm()
- Specified by:
getAlgorithm
in interfaceKey
-
getDigest
public byte[] getDigest()
Description copied from interface:SaltedSimpleDigestPassword
Get the digest represented by this password.- Specified by:
getDigest
in interfaceSaltedSimpleDigestPassword
- Returns:
- the digest represented by this password
-
getSalt
public byte[] getSalt()
Description copied from interface:SaltedSimpleDigestPassword
Get the salt used to generate the digest.- Specified by:
getSalt
in interfaceSaltedSimpleDigestPassword
- Returns:
- the salt used to generate the digest
-
getKeySpec
<S extends KeySpec> S getKeySpec(Class<S> keySpecType) throws InvalidKeySpecException
- Specified by:
getKeySpec
in classAbstractPasswordImpl
- Throws:
InvalidKeySpecException
-
verify
boolean verify(char[] guess) throws InvalidKeyException
- Specified by:
verify
in classAbstractPasswordImpl
- Throws:
InvalidKeyException
-
verify
boolean verify(char[] guess, Charset hashCharset) throws InvalidKeyException
- Overrides:
verify
in classAbstractPasswordImpl
- Throws:
InvalidKeyException
-
convertibleTo
<T extends KeySpec> boolean convertibleTo(Class<T> keySpecType)
- Specified by:
convertibleTo
in classAbstractPasswordImpl
-
digestOf
private static byte[] digestOf(String algorithm, byte[] salt, char[] password, Charset hashCharset) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
getMessageDigest
private static MessageDigest getMessageDigest(String algorithm) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
isSaltFirst
private static boolean isSaltFirst(String algorithm) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
hashCode
public int hashCode()
- Specified by:
hashCode
in classAbstractPasswordImpl
-
equals
public boolean equals(Object obj)
- Specified by:
equals
in classAbstractPasswordImpl
-
readObject
private void readObject(ObjectInputStream ignored) throws NotSerializableException
- Throws:
NotSerializableException
-
writeReplace
Object writeReplace()
-
clone
public SaltedSimpleDigestPasswordImpl clone()
Description copied from interface:Password
Creates and returns a copy of thisPassword
.- Specified by:
clone
in interfaceOneWayPassword
- Specified by:
clone
in interfacePassword
- Specified by:
clone
in interfaceSaltedSimpleDigestPassword
- Specified by:
clone
in classAbstractPasswordImpl
- Returns:
- a copy of this
Password
.
-
-