com.holonplatform.auth.keys

## Interface KeySource

- All Known Subinterfaces:
    KeySource.KetSourceWithCharset

      public interface KeySource

  Security key source.

  A key source can be created from different source types and formats using the provided static methods, such as `string(String)`, `stream(InputStream)` or `file(File)`.

  Since:
    5.1.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `KeySource.KetSourceWithCharset` A `KeySource` which can support a charset.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static KeySource` | `bytes(byte[] source)` Create a key source from an array of bytes.
    `static KeySource` | `file(File source)` Create a key source from a `File`.
    `static KeySource` | `file(String fileName)` Create a key source from a file with given file name.
    `byte[]` | `getBytes()` Get the key as a byte array.
    `static KeySource` | `resource(String name)` Create a key source using a classpath resource using the default ClassLoader.
    `static KeySource` | `resource(String name, ClassLoader classLoader)` Create a key source using a classpath resource.
    `static KeySource` | `stream(InputStream source)` Create a key source from a `InputStream`.
    `static KeySource` | `string(String source)` Create a key source from a `String`.
    `static KeySource` | `string(String source, Charset charset)` Create a key source from a `String` using given charset.
    `static KeySource` | `string(String source, String charsetName)` Create a key source from a `String` using given charset name.

- - ### Method Detail

    - #### getBytes

          byte[] getBytes()
                   throws IOException

      Get the key as a byte array.
      Returns:
        Key bytes
      Throws:
        `IOException` - If an error occurred

    - #### bytes

          static KeySource bytes(byte[] source)

      Create a key source from an array of bytes.
      Parameters:
        `source` - Key source (not null)
      Returns:
        A new `KeySource`

    - #### string

          static KeySource string(String source)

      Create a key source from a `String`. The `UTF-8` charset is used by default.
      Parameters:
        `source` - Key source (not null)
      Returns:
        A new `KeySource`

    - #### string

          static KeySource string(String source,
                                  Charset charset)

      Create a key source from a `String` using given charset.
      Parameters:
        `source` - Key source (not null)
        `charset` - The charset with which the source was encoded (not null)
      Returns:
        A new `KeySource`

    - #### string

          static KeySource string(String source,
                                  String charsetName)

      Create a key source from a `String` using given charset name.
      Parameters:
        `source` - Key source (not null)
        `charsetName` - The charset name with which the source was encoded (not null)
      Returns:
        A new `KeySource`
      Throws:
        `UnsupportedCharsetException` - If given charset name is not supported by the JVM

    - #### stream

          static KeySource stream(InputStream source)

      Create a key source from a `InputStream`.
      Parameters:
        `source` - Key source (not null)
      Returns:
        A new `KeySource`

    - #### resource

          static KeySource resource(String name,
                                    ClassLoader classLoader)

      Create a key source using a classpath resource. The resource lookup strategy is the same as `ClassLoader.getResource(String)`.
      Parameters:
        `name` - Key resource name (not null)
        `classLoader` - The ClassLoader to use (not null)
      Returns:
        A new `KeySource`

    - #### resource

          static KeySource resource(String name)

      Create a key source using a classpath resource using the default ClassLoader. The resource lookup strategy is the same as `ClassLoader.getResource(String)`.
      Parameters:
        `name` - Key resource name (not null)
      Returns:
        A new `KeySource`

    - #### file

          static KeySource file(File source)

      Create a key source from a `File`.
      Parameters:
        `source` - Key source (not null)
      Returns:
        A new `KeySource`

    - #### file

          static KeySource file(String fileName)

      Create a key source from a file with given file name.
      Parameters:
        `fileName` - Key source file name (not null)
      Returns:
        A new `KeySource`

Copyright © 2019 The Holon Platform. All rights reserved.