Package org.apache.catalina.realm
Class SecretKeyCredentialHandler
- java.lang.Object
-
- org.apache.catalina.realm.DigestCredentialHandlerBase
-
- org.apache.catalina.realm.SecretKeyCredentialHandler
-
- All Implemented Interfaces:
CredentialHandler
public class SecretKeyCredentialHandler extends DigestCredentialHandlerBase
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_ALGORITHMstatic intDEFAULT_ITERATIONSstatic intDEFAULT_KEY_LENGTH-
Fields inherited from class org.apache.catalina.realm.DigestCredentialHandlerBase
DEFAULT_SALT_LENGTH, sm
-
-
Constructor Summary
Constructors Constructor Description SecretKeyCredentialHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetAlgorithm()protected intgetDefaultIterations()intgetKeyLength()protected LoggetLog()booleanmatches(String inputCredentials, String storedCredentials)Checks to see if the input credentials match the stored credentialsprotected Stringmutate(String inputCredentials, byte[] salt, int iterations)Generates the equivalent stored credentials for the given input credentials, salt and iterations.protected Stringmutate(String inputCredentials, byte[] salt, int iterations, int keyLength)Generates 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)-
Methods inherited from class org.apache.catalina.realm.DigestCredentialHandlerBase
getDefaultSaltLength, getIterations, getLogInvalidStoredCredentials, getSaltLength, matchesSaltIterationsEncoded, mutate, setIterations, setLogInvalidStoredCredentials, setSaltLength
-
-
-
-
Field Detail
-
DEFAULT_ALGORITHM
public static final String DEFAULT_ALGORITHM
- See Also:
- Constant Field Values
-
DEFAULT_KEY_LENGTH
public static final int DEFAULT_KEY_LENGTH
- See Also:
- Constant Field Values
-
DEFAULT_ITERATIONS
public static final int DEFAULT_ITERATIONS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SecretKeyCredentialHandler
public SecretKeyCredentialHandler() throws NoSuchAlgorithmException- Throws:
NoSuchAlgorithmException
-
-
Method Detail
-
getAlgorithm
public String getAlgorithm()
- Specified by:
getAlgorithmin classDigestCredentialHandlerBase- Returns:
- the algorithm used to convert input credentials to stored credentials.
-
setAlgorithm
public void setAlgorithm(String algorithm) throws NoSuchAlgorithmException
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()
-
setKeyLength
public void setKeyLength(int keyLength)
-
matches
public boolean matches(String inputCredentials, String storedCredentials)
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
protected String mutate(String inputCredentials, byte[] salt, int iterations)
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
protected String mutate(String inputCredentials, byte[] salt, int iterations, int keyLength)
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). Sub-classes 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()
- Specified by:
getDefaultIterationsin classDigestCredentialHandlerBase- Returns:
- the default number of iterations used by the
CredentialHandler.
-
getLog
protected Log getLog()
- Specified by:
getLogin classDigestCredentialHandlerBase- Returns:
- the logger for the CredentialHandler instance.
-
-