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
`static java.lang.String` `DEFAULT_ALGORITHM`
`static int` `DEFAULT_ITERATIONS`
`static int` `DEFAULT_KEY_LENGTH`

### Fields inherited from class org.apache.catalina.realm.DigestCredentialHandlerBase

`DEFAULT_SALT_LENGTH, sm`

### Constructor Summary

Constructors
`SecretKeyCredentialHandler()`

### Method Summary

All Methods Instance Methods Concrete Methods
`java.lang.String` `getAlgorithm()`
`protected int` `getDefaultIterations()`
`int` `getKeyLength()`
`protected Log` `getLog()`
`boolean` `matches​(java.lang.String inputCredentials, java.lang.String storedCredentials)` Checks to see if the input credentials match the stored credentials
`protected 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.
`void` `setAlgorithm​(java.lang.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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### DEFAULT_ALGORITHM

    public static final java.lang.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 java.security.NoSuchAlgorithmException

Throws:
  `java.security.NoSuchAlgorithmException`

### Method Detail

#### getAlgorithm

    public java.lang.String getAlgorithm()

Specified by:
  `getAlgorithm` in class `DigestCredentialHandlerBase`
Returns:
  the algorithm used to convert input credentials to stored credentials.

#### setAlgorithm

    public void setAlgorithm​(java.lang.String algorithm)
                      throws java.security.NoSuchAlgorithmException

Description copied from class: `DigestCredentialHandlerBase`
Set the algorithm used to convert input credentials to stored credentials.

Specified by:
  `setAlgorithm` in class `DigestCredentialHandlerBase`
Parameters:
  `algorithm` - the algorithm
Throws:
  `java.security.NoSuchAlgorithmException` - if the specified algorithm is not supported

#### getKeyLength

    public int getKeyLength()

#### setKeyLength

    public void setKeyLength​(int keyLength)

#### matches

    public boolean matches​(java.lang.String inputCredentials,
                           java.lang.String storedCredentials)

Description copied from interface: `CredentialHandler`
Checks to see if the input credentials match the stored credentials

Parameters:
  `inputCredentials` - User provided credentials
  `storedCredentials` - Credentials stored in the `Realm`
Returns:
  `true` if the inputCredentials match the storedCredentials, otherwise `false`

#### mutate

    protected java.lang.String mutate​(java.lang.String inputCredentials,
                                      byte[] salt,
                                      int iterations)

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 class `DigestCredentialHandlerBase`
Parameters:
  `inputCredentials` - User provided credentials
  `salt` - Salt, if any
  `iterations` - 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

    protected java.lang.String mutate​(java.lang.String inputCredentials,
                                      byte[] salt,
                                      int iterations,
                                      int keyLength)

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 calls `DigestCredentialHandlerBase.mutate(String, byte[], int)`. Sub-classes that use the key length should override this method.

Overrides:
  `mutate` in class `DigestCredentialHandlerBase`
Parameters:
  `inputCredentials` - User provided credentials
  `salt` - Salt, if any
  `iterations` - Number of iterations of the algorithm associated with this CredentialHandler applied to the inputCredentials to generate the equivalent stored credentials
  `keyLength` - 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 class `DigestCredentialHandlerBase`
Returns:
  the default number of iterations used by the `CredentialHandler`.

#### getLog

    protected Log getLog()

Specified by:
  `getLog` in class `DigestCredentialHandlerBase`
Returns:
  the logger for the CredentialHandler instance.