Package org.apache.catalina.realm
Class DigestCredentialHandlerBase
java.lang.Object
org.apache.catalina.realm.DigestCredentialHandlerBase
- All Implemented Interfaces:
CredentialHandler
- Direct Known Subclasses:
MessageDigestCredentialHandler,SecretKeyCredentialHandler
Base implementation for the Tomcat provided
CredentialHandlers.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Stringprotected abstract intprotected intintprotected abstract LoggetLog()booleanWhen checking input credentials against stored credentials will a warning message be logged if invalid stored credentials are discovered?intprotected booleanmatchesSaltIterationsEncoded(String inputCredentials, String storedCredentials) Checks whether the provided credential matches the stored credential when the stored credential is in the form salt$iteration-count$credentialGenerates the equivalent stored credentials for the given input credentials.protected abstract StringGenerates the equivalent stored credentials for the given input credentials, salt and iterations.protected StringGenerates the equivalent stored credentials for the given input credentials, salt, iterations and key length.abstract voidsetAlgorithm(String algorithm) Set the algorithm used to convert input credentials to stored credentials.voidsetIterations(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.voidsetLogInvalidStoredCredentials(boolean logInvalidStoredCredentials) Set whether a warning message will be logged if invalid stored credentials are discovered while checking input credentials against stored credentials?voidsetSaltLength(int saltLength) Set the salt length that will be used when creating a new stored credential for a given input credential.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.catalina.CredentialHandler
matches
-
Field Details
-
sm
-
DEFAULT_SALT_LENGTH
public static final int DEFAULT_SALT_LENGTH- See Also:
-
-
Constructor Details
-
DigestCredentialHandlerBase
public DigestCredentialHandlerBase()
-
-
Method Details
-
getIterations
public int getIterations()- Returns:
- the number of iterations of the associated algorithm that will be used when creating a new stored credential for a given input credential.
-
setIterations
public 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.- Parameters:
iterations- the iterations count
-
getSaltLength
public int getSaltLength()- Returns:
- the salt length that will be used when creating a new stored credential for a given input credential.
-
setSaltLength
public void setSaltLength(int saltLength) Set the salt length that will be used when creating a new stored credential for a given input credential.- Parameters:
saltLength- the salt length
-
getLogInvalidStoredCredentials
public boolean getLogInvalidStoredCredentials()When checking input credentials against stored credentials will a warning message be logged if invalid stored credentials are discovered?- Returns:
trueif logging will occur
-
setLogInvalidStoredCredentials
public 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?- Parameters:
logInvalidStoredCredentials-trueto log, the default value isfalse
-
mutate
Description copied from interface:CredentialHandlerGenerates the equivalent stored credentials for the given input credentials.- Specified by:
mutatein interfaceCredentialHandler- Parameters:
userCredential- User provided credentials- Returns:
- The equivalent stored credentials for the given input credentials
-
matchesSaltIterationsEncoded
Checks whether the provided credential matches the stored credential when the stored credential is in the form salt$iteration-count$credential- Parameters:
inputCredentials- The input credentialstoredCredentials- The stored credential- Returns:
trueif they match, otherwisefalse
-
getDefaultSaltLength
protected int getDefaultSaltLength()- Returns:
- the default salt length used by the
CredentialHandler.
-
mutate
Generates the equivalent stored credentials for the given input credentials, salt and iterations. If the algorithm requires a key length, the default will be used.- Parameters:
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 credentials- Returns:
- The equivalent stored credentials for the given input
credentials or
nullif the generation fails
-
mutate
Generates the equivalent stored credentials for the given input credentials, salt, iterations and key length. The default implementation calls ignores the key length and callsmutate(String, byte[], int). Sub-classes that use the key length should override this method.- Parameters:
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 applicable- Returns:
- The equivalent stored credentials for the given input
credentials or
nullif the generation fails
-
setAlgorithm
Set the algorithm used to convert input credentials to stored credentials.- Parameters:
algorithm- the algorithm- Throws:
NoSuchAlgorithmException- if the specified algorithm is not supported
-
getAlgorithm
- Returns:
- the algorithm used to convert input credentials to stored credentials.
-
getDefaultIterations
protected abstract int getDefaultIterations()- Returns:
- the default number of iterations used by the
CredentialHandler.
-
getLog
- Returns:
- the logger for the CredentialHandler instance.
-