com.holonplatform.auth.keys

## Interface KeyReader

-     public interface KeyReader

  Security keys reader.

  Provide methods to read public and private security keys from different sources, using the `KeySource` interface to support several key sources, and with different key formats and encodings.

  Since:
    5.1.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `PARAMETER_KEYSTORE_KEY_ALIAS` Parameter which can be used when reading a key from a Key Store to provide the key alias name in the Key Store
    `static String` | `PARAMETER_KEYSTORE_KEY_PASSWORD` Parameter which can be used when reading a key from a Key Store to provide the key recovering password for a key alias
    `static String` | `PARAMETER_KEYSTORE_PASSWORD` Parameter which can be used when reading a key from a Key Store to provide the Key Store password

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static KeyReader` | `getDefault()` Get the default `KeyReader`.
    `PrivateKey` | `privateKey(KeySource source, String algorithm, KeyFormat format, KeyEncoding encoding, Map<String,String> parameters)` Read a `PrivateKey` from given key `source`.
    `PublicKey` | `publicKey(KeySource source, String algorithm, KeyFormat format, KeyEncoding encoding, Map<String,String> parameters)` Read a `PublicKey` from given key `source`.

- - ### Field Detail

    - #### PARAMETER_KEYSTORE_PASSWORD

          static final String PARAMETER_KEYSTORE_PASSWORD

      Parameter which can be used when reading a key from a Key Store to provide the Key Store password
      See Also:
        Constant Field Values

    - #### PARAMETER_KEYSTORE_KEY_ALIAS

          static final String PARAMETER_KEYSTORE_KEY_ALIAS

      Parameter which can be used when reading a key from a Key Store to provide the key alias name in the Key Store
      See Also:
        Constant Field Values

    - #### PARAMETER_KEYSTORE_KEY_PASSWORD

          static final String PARAMETER_KEYSTORE_KEY_PASSWORD

      Parameter which can be used when reading a key from a Key Store to provide the key recovering password for a key alias
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### publicKey

          PublicKey publicKey(KeySource source,
                              String algorithm,
                              KeyFormat format,
                              KeyEncoding encoding,
                              Map<String,String> parameters)
                       throws SecurityException

      Read a `PublicKey` from given key `source`.

      When a key store type format is used (such as `KeyFormat.PKCS12`), the standard `PARAMETER_KEYSTORE_PASSWORD`, `PARAMETER_KEYSTORE_KEY_ALIAS` and `PARAMETER_KEYSTORE_KEY_PASSWORD` parameters must be provided to specify the key store password, the key alias name and the optional key recovering password.

      Parameters:
        `source` - Key source (not null)
        `algorithm` - Key algorithm. Must be a supported key factory algorithm, see `KeyFactory.getInstance(String)` (not null)
        `format` - Key format (not null)
        `encoding` - Key source encoding (not null)
        `parameters` - Optional parameters
      Returns:
        The `PublicKey` representation of the decoded key
      Throws:
        `SecurityException` - If the key source is not valid or a decoding error occurred

    - #### privateKey

          PrivateKey privateKey(KeySource source,
                                String algorithm,
                                KeyFormat format,
                                KeyEncoding encoding,
                                Map<String,String> parameters)
                         throws SecurityException

      Read a `PrivateKey` from given key `source`.

      When a key store type format is used (such as `KeyFormat.PKCS12`), the standard `PARAMETER_KEYSTORE_PASSWORD`, `PARAMETER_KEYSTORE_KEY_ALIAS` and `PARAMETER_KEYSTORE_KEY_PASSWORD` parameters must be provided to specify the key store password, the key alias name and the optional key recovering password.

      Parameters:
        `source` - Key source (not null)
        `algorithm` - Key algorithm. Must be a supported key factory algorithm, see `KeyFactory.getInstance(String)` (not null)
        `format` - Key format (not null)
        `encoding` - Key source encoding (not null)
        `parameters` - Optional parameters
      Returns:
        The `PrivateKey` representation of the decoded key
      Throws:
        `SecurityException` - If the key source is not valid or a decoding error occurred

    - #### getDefault

          static KeyReader getDefault()

      Get the default `KeyReader`.
      Returns:
        The default `KeyReader`

Copyright © 2019 The Holon Platform. All rights reserved.