Class DigestPasswordImpl
- java.lang.Object
-
- org.wildfly.security.password.impl.AbstractPasswordImpl
-
- org.wildfly.security.password.impl.DigestPasswordImpl
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Key
,DigestPassword
,OneWayPassword
,Password
class DigestPasswordImpl extends AbstractPasswordImpl implements DigestPassword
Pre-digested (DigestMD5) credential type implementation.- Author:
- Peter Skopek., Darran Lofthouse
-
-
Field Summary
Fields Modifier and Type Field Description private String
algorithm
private byte[]
digest
private String
realm
private static long
serialVersionUID
private String
username
-
Fields inherited from interface org.wildfly.security.password.interfaces.DigestPassword
ALGORITHM_DIGEST_MD5, ALGORITHM_DIGEST_SHA, ALGORITHM_DIGEST_SHA_256, ALGORITHM_DIGEST_SHA_384, ALGORITHM_DIGEST_SHA_512, ALGORITHM_DIGEST_SHA_512_256
-
-
Constructor Summary
Constructors Constructor Description DigestPasswordImpl(String algorithm, char[] password, DigestPasswordAlgorithmSpec spec, Charset hashCharset)
DigestPasswordImpl(String algorithm, String username, String realm, byte[] digest)
DigestPasswordImpl(String algorithm, DigestPasswordSpec spec)
DigestPasswordImpl(String algorithm, EncryptablePasswordSpec spec)
DigestPasswordImpl(DigestPassword password)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DigestPasswordImpl
clone()
Creates and returns a copy of thisPassword
.(package private) <T extends KeySpec>
booleanconvertibleTo(Class<T> keySpecType)
boolean
equals(Object obj)
String
getAlgorithm()
byte[]
getDigest()
Get the digest represented by thisPassword
.(package private) <S extends KeySpec>
SgetKeySpec(Class<S> keySpecType)
private static MessageDigest
getMessageDigest(String algorithm)
String
getRealm()
Get the realm thisPassword
is associated with.String
getUsername()
Get the username thisPassword
is associated with.int
hashCode()
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 org.wildfly.security.password.interfaces.DigestPassword
getParameterSpec, impliesParameters
-
Methods inherited from interface java.security.Key
getEncoded, getFormat
-
Methods inherited from interface org.wildfly.security.password.Password
castAndApply, castAndApply, castAs, castAs
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
algorithm
private final String algorithm
-
username
private final String username
-
realm
private final String realm
-
digest
private final byte[] digest
-
-
Constructor Detail
-
DigestPasswordImpl
DigestPasswordImpl(String algorithm, String username, String realm, byte[] digest)
-
DigestPasswordImpl
DigestPasswordImpl(String algorithm, DigestPasswordSpec spec)
-
DigestPasswordImpl
DigestPasswordImpl(DigestPassword password)
-
DigestPasswordImpl
DigestPasswordImpl(String algorithm, EncryptablePasswordSpec spec) throws InvalidKeySpecException
- Throws:
InvalidKeySpecException
-
DigestPasswordImpl
DigestPasswordImpl(String algorithm, char[] password, DigestPasswordAlgorithmSpec spec, Charset hashCharset) throws InvalidKeySpecException
- Throws:
InvalidKeySpecException
-
-
Method Detail
-
getAlgorithm
public String getAlgorithm()
- Specified by:
getAlgorithm
in interfaceKey
-
getUsername
public String getUsername()
Description copied from interface:DigestPassword
Get the username thisPassword
is associated with.Generally a
Password
should not need to know this information but this is an integral part of how the representation of thisPassword
is created.- Specified by:
getUsername
in interfaceDigestPassword
- Returns:
- the username this
Password
is associated with
-
getRealm
public String getRealm()
Description copied from interface:DigestPassword
Get the realm thisPassword
is associated with.Note: This is independent of the name of the realm used to obtain the
Password
representation, this is the value used to generate the digest.- Specified by:
getRealm
in interfaceDigestPassword
- Returns:
- the realm this
Password
is associated with
-
getDigest
public byte[] getDigest()
Description copied from interface:DigestPassword
Get the digest represented by thisPassword
.- Specified by:
getDigest
in interfaceDigestPassword
- Returns:
- the digest represented by this
Password
-
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
-
getMessageDigest
private static MessageDigest getMessageDigest(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 DigestPasswordImpl clone()
Description copied from interface:Password
Creates and returns a copy of thisPassword
.- Specified by:
clone
in interfaceDigestPassword
- Specified by:
clone
in interfaceOneWayPassword
- Specified by:
clone
in interfacePassword
- Specified by:
clone
in classAbstractPasswordImpl
- Returns:
- a copy of this
Password
.
-
-