Class SecretKeyCredentialHandler
java.lang.Object
org.apache.catalina.realm.DigestCredentialHandlerBase
org.apache.catalina.realm.SecretKeyCredentialHandler
- All Implemented Interfaces:
CredentialHandler
A credential handler that uses a
SecretKeyFactory (PBE) to hash credentials.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default algorithm used for key derivation.static final intThe default number of iterations for key derivation.static final intThe default derived key length in bits.Fields inherited from class DigestCredentialHandlerBase
DEFAULT_SALT_LENGTH, sm -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the algorithm used to convert input credentials to stored credentials.protected intGet the default number of iterations used by theCredentialHandler.intReturns the key length.protected LoggetLog()Get the logger for the CredentialHandler instance.booleanChecks to see if the input credentials match the stored credentialsprotected 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.voidsetAlgorithm(String algorithm) Set the algorithm used to convert input credentials to stored credentials.voidsetKeyLength(int keyLength) Sets the key length.
-
Field Details
-
DEFAULT_ALGORITHM
The default algorithm used for key derivation.- See Also:
-
DEFAULT_KEY_LENGTH
public static final int DEFAULT_KEY_LENGTHThe default derived key length in bits.- See Also:
-
DEFAULT_ITERATIONS
public static final int DEFAULT_ITERATIONSThe default number of iterations for key derivation.- See Also:
-
-
Constructor Details
-
SecretKeyCredentialHandler
Create a handler with the default algorithm.- Throws:
NoSuchAlgorithmException- if the default algorithm is not available
-
-
Method Details
-
getAlgorithm
Description copied from class:DigestCredentialHandlerBaseGet the algorithm used to convert input credentials to stored credentials.- Specified by:
getAlgorithmin classDigestCredentialHandlerBase- Returns:
- the algorithm used to convert input credentials to stored credentials.
-
setAlgorithm
Description copied from class:DigestCredentialHandlerBaseSet the algorithm used to convert input credentials to stored credentials.- Specified by:
setAlgorithmin classDigestCredentialHandlerBase- Parameters:
algorithm- the algorithm- Throws:
NoSuchAlgorithmException- if the specified algorithm is not supported
-
getKeyLength
public int getKeyLength()Returns the key length.- Returns:
- the key length
-
setKeyLength
public void setKeyLength(int keyLength) Sets the key length.- Parameters:
keyLength- the key length
-
matches
Description copied from interface:CredentialHandlerChecks to see if the input credentials match the stored credentials- Parameters:
inputCredentials- User provided credentialsstoredCredentials- Credentials stored in theRealm- Returns:
trueif the inputCredentials match the storedCredentials, otherwisefalse
-
mutate
Description copied from class:DigestCredentialHandlerBaseGenerates the equivalent stored credentials for the given input credentials, salt and iterations. If the algorithm requires a key length, the default will be used.- Specified by:
mutatein classDigestCredentialHandlerBase- 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
Description copied from class:DigestCredentialHandlerBaseGenerates the equivalent stored credentials for the given input credentials, salt, iterations and key length. The default implementation calls ignores the key length and callsDigestCredentialHandlerBase.mutate(String, byte[], int). Subclasses that use the key length should override this method.- Overrides:
mutatein classDigestCredentialHandlerBase- 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
-
getDefaultIterations
protected int getDefaultIterations()Description copied from class:DigestCredentialHandlerBaseGet the default number of iterations used by theCredentialHandler.- Specified by:
getDefaultIterationsin classDigestCredentialHandlerBase- Returns:
- the default number of iterations used by the
CredentialHandler.
-
getLog
Description copied from class:DigestCredentialHandlerBaseGet the logger for the CredentialHandler instance.- Specified by:
getLogin classDigestCredentialHandlerBase- Returns:
- the logger for the CredentialHandler instance.
-