public abstract class DigestCredentialHandlerBase extends java.lang.Object implements CredentialHandler
CredentialHandlers.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_SALT_LENGTH |
protected static StringManager |
sm |
| Constructor and Description |
|---|
DigestCredentialHandlerBase() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
equals(byte[] b1,
byte[] b2)
Implements byte-array equality which always compares all bytes in the
array, without stopping early if any bytes do not match.
|
static boolean |
equals(java.lang.String s1,
java.lang.String s2,
boolean ignoreCase)
Implements String equality which always compares all characters in the
string, without stopping early if any characters do not match.
|
abstract java.lang.String |
getAlgorithm() |
protected abstract int |
getDefaultIterations() |
protected int |
getDefaultSaltLength() |
int |
getIterations() |
protected abstract Log |
getLog() |
boolean |
getLogInvalidStoredCredentials()
When checking input credentials against stored credentials will a warning
message be logged if invalid stored credentials are discovered?
|
int |
getSaltLength() |
protected boolean |
matchesSaltIterationsEncoded(java.lang.String inputCredentials,
java.lang.String storedCredentials)
Checks whether the provided credential matches the stored credential when
the stored credential is in the form salt$iteration-count$credential
|
java.lang.String |
mutate(java.lang.String userCredential)
Generates the equivalent stored credentials for the given input
credentials.
|
protected abstract java.lang.String |
mutate(java.lang.String inputCredentials,
byte[] salt,
int iterations)
Generates the equivalent stored credentials for the given input
credentials, salt and iterations.
|
protected java.lang.String |
mutate(java.lang.String inputCredentials,
byte[] salt,
int iterations,
int keyLength)
Generates the equivalent stored credentials for the given input
credentials, salt, iterations and key length.
|
abstract void |
setAlgorithm(java.lang.String algorithm)
Set the algorithm used to convert input credentials to stored
credentials.
|
void |
setIterations(int iterations)
Set the number of iterations of the associated algorithm that will be
used when creating a new stored credential for a given input credential.
|
void |
setLogInvalidStoredCredentials(boolean logInvalidStoredCredentials)
Set whether a warning message will be logged if invalid stored
credentials are discovered while checking input credentials against
stored credentials?
|
void |
setSaltLength(int saltLength)
Set the salt length that will be used when creating a new stored
credential for a given input credential.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitmatchesprotected static final StringManager sm
public static final int DEFAULT_SALT_LENGTH
public int getIterations()
public void setIterations(int iterations)
iterations - the iterations countpublic int getSaltLength()
public void setSaltLength(int saltLength)
saltLength - the salt lengthpublic boolean getLogInvalidStoredCredentials()
true if logging will occurpublic void setLogInvalidStoredCredentials(boolean logInvalidStoredCredentials)
logInvalidStoredCredentials - true to log, the
default value is falsepublic java.lang.String mutate(java.lang.String userCredential)
CredentialHandlermutate in interface CredentialHandleruserCredential - User provided credentialsprotected boolean matchesSaltIterationsEncoded(java.lang.String inputCredentials,
java.lang.String storedCredentials)
inputCredentials - The input credentialstoredCredentials - The stored credentialtrue if they match, otherwise falseprotected int getDefaultSaltLength()
CredentialHandler.protected abstract java.lang.String mutate(java.lang.String inputCredentials,
byte[] salt,
int iterations)
inputCredentials - User provided credentialssalt - Salt, if anyiterations - Number of iterations of the algorithm associated
with this CredentialHandler applied to the
inputCredentials to generate the equivalent
stored credentialsnull if the generation failsprotected java.lang.String mutate(java.lang.String inputCredentials,
byte[] salt,
int iterations,
int keyLength)
mutate(String, byte[], int). Sub-classes that use the key length
should override this method.inputCredentials - User provided credentialssalt - Salt, if anyiterations - Number of iterations of the algorithm associated
with this CredentialHandler applied to the
inputCredentials to generate the equivalent
stored credentialskeyLength - Length of the produced digest in bits for
implementations where it's applicablenull if the generation failspublic abstract void setAlgorithm(java.lang.String algorithm)
throws java.security.NoSuchAlgorithmException
algorithm - the algorithmjava.security.NoSuchAlgorithmException - if the specified algorithm
is not supportedpublic abstract java.lang.String getAlgorithm()
protected abstract int getDefaultIterations()
CredentialHandler.protected abstract Log getLog()
public static boolean equals(java.lang.String s1,
java.lang.String s2,
boolean ignoreCase)
Note:
This implementation was adapted from MessageDigest.isEqual(byte[], byte[])
which we assume is as optimizer-defeating as possible.
s1 - The first string to compare.s2 - The second string to compare.ignoreCase - true if the strings should be compared
without regard to case. Note that "true" here is only guaranteed
to work with plain ASCII characters.true if the strings are equal to each other,
false otherwise.public static boolean equals(byte[] b1,
byte[] b2)
Note:
Implementation note: this method delegates to MessageDigest.isEqual(byte[], byte[])
under the assumption that it provides a constant-time comparison of the
bytes in the arrays. Java 7+ has such an implementation, but neither the
Javadoc nor any specification requires it. Therefore, Tomcat should
continue to use this method internally in case the JDK
implementation changes so this method can be re-implemented properly.
b1 - The first array to compare.b2 - The second array to compare.true if the arrays are equal to each other,
false otherwise.Copyright © 2000-2024 Apache Software Foundation. All Rights Reserved.