Class SecretKeyCredentialHandler
java.lang.Object
org.apache.catalina.realm.DigestCredentialHandlerBase
org.apache.catalina.realm.SecretKeyCredentialHandler
- All Implemented Interfaces:
CredentialHandler
-
Field Summary
Fields inherited from class org.apache.catalina.realm.DigestCredentialHandlerBase
DEFAULT_SALT_LENGTH, sm
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected int
int
protected Log
getLog()
boolean
Checks to see if the input credentials match the stored credentialsprotected String
Generates the equivalent stored credentials for the given input credentials, salt and iterations.protected String
Generates the equivalent stored credentials for the given input credentials, salt, iterations and key length.void
setAlgorithm
(String algorithm) Set the algorithm used to convert input credentials to stored credentials.void
setKeyLength
(int keyLength) Methods inherited from class org.apache.catalina.realm.DigestCredentialHandlerBase
equals, equals, getDefaultSaltLength, getIterations, getLogInvalidStoredCredentials, getSaltLength, matchesSaltIterationsEncoded, mutate, setIterations, setLogInvalidStoredCredentials, setSaltLength
-
Field Details
-
DEFAULT_ALGORITHM
- See Also:
-
DEFAULT_KEY_LENGTH
public static final int DEFAULT_KEY_LENGTH- See Also:
-
DEFAULT_ITERATIONS
public static final int DEFAULT_ITERATIONS- See Also:
-
-
Constructor Details
-
SecretKeyCredentialHandler
- Throws:
NoSuchAlgorithmException
-
-
Method Details
-
getAlgorithm
- Specified by:
getAlgorithm
in classDigestCredentialHandlerBase
- Returns:
- the algorithm used to convert input credentials to stored credentials.
-
setAlgorithm
Description copied from class:DigestCredentialHandlerBase
Set the algorithm used to convert input credentials to stored credentials.- Specified by:
setAlgorithm
in classDigestCredentialHandlerBase
- Parameters:
algorithm
- the algorithm- Throws:
NoSuchAlgorithmException
- if the specified algorithm is not supported
-
getKeyLength
public int getKeyLength() -
setKeyLength
public void setKeyLength(int keyLength) -
matches
Description copied from interface:CredentialHandler
Checks to see if the input credentials match the stored credentials- Parameters:
inputCredentials
- User provided credentialsstoredCredentials
- Credentials stored in theRealm
- Returns:
true
if the inputCredentials match the storedCredentials, otherwisefalse
-
mutate
Description copied from class:DigestCredentialHandlerBase
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.- Specified by:
mutate
in 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
null
if the generation fails
-
mutate
Description copied from class:DigestCredentialHandlerBase
Generates 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)
. Sub-classes that use the key length should override this method.- Overrides:
mutate
in 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
null
if the generation fails
-
getDefaultIterations
protected int getDefaultIterations()- Specified by:
getDefaultIterations
in classDigestCredentialHandlerBase
- Returns:
- the default number of iterations used by the
CredentialHandler
.
-
getLog
- Specified by:
getLog
in classDigestCredentialHandlerBase
- Returns:
- the logger for the CredentialHandler instance.
-