Class UnixMD5CryptPasswordImpl
- java.lang.Object
-
- org.wildfly.security.password.impl.AbstractPasswordImpl
-
- org.wildfly.security.password.impl.UnixMD5CryptPasswordImpl
-
- All Implemented Interfaces:
Serializable,Cloneable,Key,UnixMD5CryptPassword,OneWayPassword,Password
final class UnixMD5CryptPasswordImpl extends AbstractPasswordImpl implements UnixMD5CryptPassword
Implementation of the Unix MD5 Crypt password.- Author:
- Farah Juma, David M. Lloyd
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]hash(package private) static byte[]MAGIC_BYTES(package private) static StringMD5private byte[]saltprivate static longserialVersionUID-
Fields inherited from interface org.wildfly.security.password.interfaces.UnixMD5CryptPassword
ALGORITHM_CRYPT_MD5, ITERATION_COUNT, SALT_SIZE
-
-
Constructor Summary
Constructors Constructor Description UnixMD5CryptPasswordImpl(byte[] clonedHash, byte[] clonedSalt)UnixMD5CryptPasswordImpl(char[] password, byte[] salt, Charset hashCharset)UnixMD5CryptPasswordImpl(char[] password, Charset hashCharset)UnixMD5CryptPasswordImpl(char[] password, SaltedPasswordAlgorithmSpec spec, Charset hashCharset)UnixMD5CryptPasswordImpl(UnixMD5CryptPassword password)UnixMD5CryptPasswordImpl(ClearPasswordSpec spec)UnixMD5CryptPasswordImpl(SaltedHashPasswordSpec spec)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description UnixMD5CryptPasswordImplclone()Creates and returns a copy of thisPassword.(package private) <T extends KeySpec>
booleanconvertibleTo(Class<T> keySpecType)(package private) static byte[]encode(byte[] password, byte[] salt)Hashes the given password using the MD5 Crypt algorithm.booleanequals(Object obj)StringgetAlgorithm()byte[]getHash()Get the hash component of this password.(package private) <S extends KeySpec>
SgetKeySpec(Class<S> keySpecType)(package private) static MessageDigestgetMD5MessageDigest()byte[]getSalt()Get the salt component of this password.inthashCode()private voidreadObject(ObjectInputStream ignored)private static byte[]truncatedClone(byte[] salt)(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.UnixMD5CryptPassword
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
-
hash
private final byte[] hash
-
salt
private final byte[] salt
-
-
Constructor Detail
-
UnixMD5CryptPasswordImpl
UnixMD5CryptPasswordImpl(byte[] clonedHash, byte[] clonedSalt)
-
UnixMD5CryptPasswordImpl
UnixMD5CryptPasswordImpl(UnixMD5CryptPassword password)
-
UnixMD5CryptPasswordImpl
UnixMD5CryptPasswordImpl(SaltedHashPasswordSpec spec)
-
UnixMD5CryptPasswordImpl
UnixMD5CryptPasswordImpl(ClearPasswordSpec spec) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
UnixMD5CryptPasswordImpl
UnixMD5CryptPasswordImpl(char[] password, Charset hashCharset) throws NoSuchAlgorithmException- Throws:
NoSuchAlgorithmException
-
UnixMD5CryptPasswordImpl
UnixMD5CryptPasswordImpl(char[] password, SaltedPasswordAlgorithmSpec spec, Charset hashCharset) throws NoSuchAlgorithmException- Throws:
NoSuchAlgorithmException
-
UnixMD5CryptPasswordImpl
UnixMD5CryptPasswordImpl(char[] password, byte[] salt, Charset hashCharset) throws NoSuchAlgorithmException- Throws:
NoSuchAlgorithmException
-
-
Method Detail
-
truncatedClone
private static byte[] truncatedClone(byte[] salt)
-
getAlgorithm
public String getAlgorithm()
- Specified by:
getAlgorithmin interfaceKey
-
getHash
public byte[] getHash()
Description copied from interface:UnixMD5CryptPasswordGet the hash component of this password.- Specified by:
getHashin interfaceUnixMD5CryptPassword- Returns:
- the hash component
-
getSalt
public byte[] getSalt()
Description copied from interface:UnixMD5CryptPasswordGet the salt component of this password.- Specified by:
getSaltin interfaceUnixMD5CryptPassword- Returns:
- the salt component
-
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
-
encode
static byte[] encode(byte[] password, byte[] salt) throws NoSuchAlgorithmExceptionHashes the given password using the MD5 Crypt algorithm.- Parameters:
password- the password to be hashedsalt- the salt, will be truncated to an array of 8 bytes if an array larger than 8 bytes is given- Returns:
- a
byte[]containing the hashed password - Throws:
NoSuchAlgorithmException- if aMessageDigestobject that implements MD5 cannot be retrieved
-
getMD5MessageDigest
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 UnixMD5CryptPasswordImpl clone()
Description copied from interface:PasswordCreates and returns a copy of thisPassword.- Specified by:
clonein interfaceOneWayPassword- Specified by:
clonein interfacePassword- Specified by:
clonein interfaceUnixMD5CryptPassword- Specified by:
clonein classAbstractPasswordImpl- Returns:
- a copy of this
Password.
-
-