Class SunUnixMD5CryptPasswordImpl
- java.lang.Object
-
- org.wildfly.security.password.impl.AbstractPasswordImpl
-
- org.wildfly.security.password.impl.SunUnixMD5CryptPasswordImpl
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Key
,SunUnixMD5CryptPassword
,OneWayPassword
,Password
final class SunUnixMD5CryptPasswordImpl extends AbstractPasswordImpl implements SunUnixMD5CryptPassword
Implementation of the Sun variant of the Unix MD5 Crypt password.- Author:
- Farah Juma
-
-
Field Summary
Fields Modifier and Type Field Description private String
algorithm
(package private) static int
BASIC_ROUND_COUNT
private static String
HAMLET_EXCERPT
private byte[]
hash
private int
iterationCount
(package private) static byte[]
MAGIC_BYTES
(package private) static byte[]
MAGIC_BYTES_WITH_ROUNDS
(package private) static String
MD5
private byte[]
salt
(package private) static byte[]
SEPARATOR_BYTES
private static long
serialVersionUID
-
Fields inherited from interface org.wildfly.security.password.interfaces.SunUnixMD5CryptPassword
ALGORITHM_SUN_CRYPT_MD5, ALGORITHM_SUN_CRYPT_MD5_BARE_SALT, DEFAULT_ITERATION_COUNT, DEFAULT_SALT_SIZE
-
-
Constructor Summary
Constructors Modifier Constructor Description (package private)
SunUnixMD5CryptPasswordImpl(String algorithm, byte[] clonedHash, byte[] clonedSalt, int iterationCount)
private
SunUnixMD5CryptPasswordImpl(String algorithm, char[] password, byte[] clonedSalt, int iterationCount, Charset hashCharset)
(package private)
SunUnixMD5CryptPasswordImpl(String algorithm, char[] password, Charset hashCharset)
(package private)
SunUnixMD5CryptPasswordImpl(String algorithm, char[] password, IteratedPasswordAlgorithmSpec spec, Charset hashCharset)
(package private)
SunUnixMD5CryptPasswordImpl(String algorithm, char[] password, IteratedSaltedPasswordAlgorithmSpec spec, Charset hashCharset)
(package private)
SunUnixMD5CryptPasswordImpl(String algorithm, char[] password, SaltedPasswordAlgorithmSpec spec, Charset hashCharset)
(package private)
SunUnixMD5CryptPasswordImpl(String algorithm, IteratedSaltedHashPasswordSpec spec)
(package private)
SunUnixMD5CryptPasswordImpl(String algorithm, SaltedHashPasswordSpec spec)
(package private)
SunUnixMD5CryptPasswordImpl(SunUnixMD5CryptPassword password)
(package private)
SunUnixMD5CryptPasswordImpl(ClearPasswordSpec spec)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SunUnixMD5CryptPasswordImpl
clone()
Creates and returns a copy of thisPassword
.(package private) <T extends KeySpec>
booleanconvertibleTo(Class<T> keySpecType)
boolean
equals(Object obj)
String
getAlgorithm()
private static int
getDigestBit(int[] unsignedResult, int bitPosition)
byte[]
getHash()
Get the hash component of this password.int
getIterationCount()
Get the iteration count of this password.(package private) <S extends KeySpec>
SgetKeySpec(Class<S> keySpecType)
private static MessageDigest
getMD5MessageDigest()
byte[]
getSalt()
Get the salt component of this password.int
hashCode()
private void
readObject(ObjectInputStream ignored)
(package private) static byte[]
sunMD5Crypt(String algorithm, byte[] password, byte[] salt, int iterationCount)
Hashes the given password using the Sun variant of the MD5 Crypt algorithm.(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.SunUnixMD5CryptPassword
getParameterSpec, impliesParameters
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
MD5
static final String MD5
- See Also:
- Constant Field Values
-
MAGIC_BYTES
static final byte[] MAGIC_BYTES
-
MAGIC_BYTES_WITH_ROUNDS
static final byte[] MAGIC_BYTES_WITH_ROUNDS
-
SEPARATOR_BYTES
static final byte[] SEPARATOR_BYTES
-
BASIC_ROUND_COUNT
static final int BASIC_ROUND_COUNT
- See Also:
- Constant Field Values
-
algorithm
private final String algorithm
-
hash
private final byte[] hash
-
salt
private final byte[] salt
-
iterationCount
private final int iterationCount
-
HAMLET_EXCERPT
private static final String HAMLET_EXCERPT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SunUnixMD5CryptPasswordImpl
SunUnixMD5CryptPasswordImpl(String algorithm, byte[] clonedHash, byte[] clonedSalt, int iterationCount)
-
SunUnixMD5CryptPasswordImpl
SunUnixMD5CryptPasswordImpl(SunUnixMD5CryptPassword password)
-
SunUnixMD5CryptPasswordImpl
SunUnixMD5CryptPasswordImpl(String algorithm, IteratedSaltedHashPasswordSpec spec)
-
SunUnixMD5CryptPasswordImpl
SunUnixMD5CryptPasswordImpl(String algorithm, SaltedHashPasswordSpec spec)
-
SunUnixMD5CryptPasswordImpl
SunUnixMD5CryptPasswordImpl(ClearPasswordSpec spec) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
SunUnixMD5CryptPasswordImpl
SunUnixMD5CryptPasswordImpl(String algorithm, char[] password, Charset hashCharset) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
SunUnixMD5CryptPasswordImpl
SunUnixMD5CryptPasswordImpl(String algorithm, char[] password, IteratedSaltedPasswordAlgorithmSpec spec, Charset hashCharset) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
SunUnixMD5CryptPasswordImpl
SunUnixMD5CryptPasswordImpl(String algorithm, char[] password, SaltedPasswordAlgorithmSpec spec, Charset hashCharset) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
SunUnixMD5CryptPasswordImpl
SunUnixMD5CryptPasswordImpl(String algorithm, char[] password, IteratedPasswordAlgorithmSpec spec, Charset hashCharset) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
SunUnixMD5CryptPasswordImpl
private SunUnixMD5CryptPasswordImpl(String algorithm, char[] password, byte[] clonedSalt, int iterationCount, Charset hashCharset) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
-
Method Detail
-
getAlgorithm
public String getAlgorithm()
- Specified by:
getAlgorithm
in interfaceKey
-
getHash
public byte[] getHash()
Description copied from interface:SunUnixMD5CryptPassword
Get the hash component of this password.- Specified by:
getHash
in interfaceSunUnixMD5CryptPassword
- Returns:
- the hash
-
getSalt
public byte[] getSalt()
Description copied from interface:SunUnixMD5CryptPassword
Get the salt component of this password.- Specified by:
getSalt
in interfaceSunUnixMD5CryptPassword
- Returns:
- the salt
-
getIterationCount
public int getIterationCount()
Description copied from interface:SunUnixMD5CryptPassword
Get the iteration count of this password.- Specified by:
getIterationCount
in interfaceSunUnixMD5CryptPassword
- Returns:
- the iteration count
-
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
-
sunMD5Crypt
static byte[] sunMD5Crypt(String algorithm, byte[] password, byte[] salt, int iterationCount) throws NoSuchAlgorithmException
Hashes the given password using the Sun variant of the MD5 Crypt algorithm.- Parameters:
algorithm
- the algorithm to be used. Possible values are available as constants on {link}SunUnixMD5CryptPassword{link}password
- the password to be hashedsalt
- the saltiterationCount
- the number of additional iterations to use- Returns:
- a
byte[]
containing the hashed password - Throws:
NoSuchAlgorithmException
- if aMessageDigest
object that implements MD5 cannot be retrieved
-
getDigestBit
private static int getDigestBit(int[] unsignedResult, int bitPosition)
-
getMD5MessageDigest
private static MessageDigest getMD5MessageDigest() 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 SunUnixMD5CryptPasswordImpl 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 interfaceSunUnixMD5CryptPassword
- Specified by:
clone
in classAbstractPasswordImpl
- Returns:
- a copy of this
Password
.
-
-