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 Stringalgorithm(package private) static intBASIC_ROUND_COUNTprivate static StringHAMLET_EXCERPTprivate byte[]hashprivate intiterationCount(package private) static byte[]MAGIC_BYTES(package private) static byte[]MAGIC_BYTES_WITH_ROUNDS(package private) static StringMD5private byte[]salt(package private) static byte[]SEPARATOR_BYTESprivate static longserialVersionUID-
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)privateSunUnixMD5CryptPasswordImpl(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 SunUnixMD5CryptPasswordImplclone()Creates and returns a copy of thisPassword.(package private) <T extends KeySpec>
booleanconvertibleTo(Class<T> keySpecType)booleanequals(Object obj)StringgetAlgorithm()private static intgetDigestBit(int[] unsignedResult, int bitPosition)byte[]getHash()Get the hash component of this password.intgetIterationCount()Get the iteration count of this password.(package private) <S extends KeySpec>
SgetKeySpec(Class<S> keySpecType)private static MessageDigestgetMD5MessageDigest()byte[]getSalt()Get the salt component of this password.inthashCode()private voidreadObject(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) booleanverify(char[] guess)(package private) booleanverify(char[] guess, Charset hashCharset)(package private) ObjectwriteReplace()-
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:
getAlgorithmin interfaceKey
-
getHash
public byte[] getHash()
Description copied from interface:SunUnixMD5CryptPasswordGet the hash component of this password.- Specified by:
getHashin interfaceSunUnixMD5CryptPassword- Returns:
- the hash
-
getSalt
public byte[] getSalt()
Description copied from interface:SunUnixMD5CryptPasswordGet the salt component of this password.- Specified by:
getSaltin interfaceSunUnixMD5CryptPassword- Returns:
- the salt
-
getIterationCount
public int getIterationCount()
Description copied from interface:SunUnixMD5CryptPasswordGet the iteration count of this password.- Specified by:
getIterationCountin interfaceSunUnixMD5CryptPassword- Returns:
- the iteration count
-
getKeySpec
<S extends KeySpec> S getKeySpec(Class<S> keySpecType) throws InvalidKeySpecException
- Specified by:
getKeySpecin classAbstractPasswordImpl- Throws:
InvalidKeySpecException
-
verify
boolean verify(char[] guess) throws InvalidKeyException- Specified by:
verifyin classAbstractPasswordImpl- Throws:
InvalidKeyException
-
verify
boolean verify(char[] guess, Charset hashCharset) throws InvalidKeyException- Overrides:
verifyin classAbstractPasswordImpl- Throws:
InvalidKeyException
-
convertibleTo
<T extends KeySpec> boolean convertibleTo(Class<T> keySpecType)
- Specified by:
convertibleToin 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 aMessageDigestobject 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:
hashCodein classAbstractPasswordImpl
-
equals
public boolean equals(Object obj)
- Specified by:
equalsin classAbstractPasswordImpl
-
readObject
private void readObject(ObjectInputStream ignored) throws NotSerializableException
- Throws:
NotSerializableException
-
writeReplace
Object writeReplace()
-
clone
public SunUnixMD5CryptPasswordImpl clone()
Description copied from interface:PasswordCreates and returns a copy of thisPassword.- Specified by:
clonein interfaceOneWayPassword- Specified by:
clonein interfacePassword- Specified by:
clonein interfaceSunUnixMD5CryptPassword- Specified by:
clonein classAbstractPasswordImpl- Returns:
- a copy of this
Password.
-
-