com.holonplatform.auth

## Interface Credentials.Encoder

- All Known Implementing Classes:
    DefaultCredentials.CredentialsEncoder
  Enclosing interface:
    Credentials

      public static interface Credentials.Encoder

  Builder to encode credentials using hash for secure storing.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `HASH_MD2` MD2 hash algorithm name
    `static String` | `HASH_MD5` MD5 hash algorithm name
    `static String` | `HASH_SHA_1` SHA-1 hash algorithm name
    `static String` | `HASH_SHA_256` SHA-256 hash algorithm name
    `static String` | `HASH_SHA_384` SHA-384 hash algorithm name
    `static String` | `HASH_SHA_512` SHA-512 hash algorithm name

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `build()` Hash given secret
    `String` | `buildAndEncodeBase64()` Hash given secret and encode using Base64
    `Credentials.Encoder` | `charset(String charset)` Secret encoding charset name.
    `Credentials.Encoder` | `hashAlgorithm(String algorithm)` Hash algorithm to use.
    `Credentials.Encoder` | `hashIterations(int iterations)` Set hash iterations to perform.
    `Credentials.Encoder` | `hashMD5()` Apply MD5 hash algorithm
    `Credentials.Encoder` | `hashSHA1()` Apply SHA-1 hash algorithm
    `Credentials.Encoder` | `hashSHA256()` Apply SHA-256 hash algorithm
    `Credentials.Encoder` | `hashSHA384()` Apply SHA-384 hash algorithm
    `Credentials.Encoder` | `hashSHA512()` Apply SHA-512 hash algorithm
    `Credentials.Encoder` | `salt(byte[] salt)` Optional salt to use for hashing
    `Credentials.Encoder` | `salt(String salt)` Optional salt to use for hashing
    `Credentials.Encoder` | `secret(String secret)` Secret text to encode

- - ### Field Detail

    - #### HASH_MD2

          static final String HASH_MD2

      MD2 hash algorithm name
      See Also:
        Constant Field Values

    - #### HASH_MD5

          static final String HASH_MD5

      MD5 hash algorithm name
      See Also:
        Constant Field Values

    - #### HASH_SHA_1

          static final String HASH_SHA_1

      SHA-1 hash algorithm name
      See Also:
        Constant Field Values

    - #### HASH_SHA_256

          static final String HASH_SHA_256

      SHA-256 hash algorithm name
      See Also:
        Constant Field Values

    - #### HASH_SHA_384

          static final String HASH_SHA_384

      SHA-384 hash algorithm name
      See Also:
        Constant Field Values

    - #### HASH_SHA_512

          static final String HASH_SHA_512

      SHA-512 hash algorithm name
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### secret

          Credentials.Encoder secret(String secret)

      Secret text to encode
      Parameters:
        `secret` - Secret text (for example a password)
      Returns:
        this

    - #### salt

          Credentials.Encoder salt(byte[] salt)

      Optional salt to use for hashing
      Parameters:
        `salt` - Salt data
      Returns:
        this
      See Also:
        `Hash.generateSalt()`

    - #### salt

          Credentials.Encoder salt(String salt)

      Optional salt to use for hashing
      Parameters:
        `salt` - Salt string
      Returns:
        this
      See Also:
        `Hash.generateSalt()`

    - #### hashAlgorithm

          Credentials.Encoder hashAlgorithm(String algorithm)

      Hash algorithm to use. Default is SHA-256
      Parameters:
        `algorithm` - Hash algorithm name
      Returns:
        this

    - #### hashMD5

          Credentials.Encoder hashMD5()

      Apply MD5 hash algorithm
      Returns:
        this

    - #### hashSHA1

          Credentials.Encoder hashSHA1()

      Apply SHA-1 hash algorithm
      Returns:
        this

    - #### hashSHA256

          Credentials.Encoder hashSHA256()

      Apply SHA-256 hash algorithm
      Returns:
        this

    - #### hashSHA384

          Credentials.Encoder hashSHA384()

      Apply SHA-384 hash algorithm
      Returns:
        this

    - #### hashSHA512

          Credentials.Encoder hashSHA512()

      Apply SHA-512 hash algorithm
      Returns:
        this

    - #### hashIterations

          Credentials.Encoder hashIterations(int iterations)

      Set hash iterations to perform. Default is 1.
      Parameters:
        `iterations` - Hash iterations
      Returns:
        this

    - #### charset

          Credentials.Encoder charset(String charset)

      Secret encoding charset name. By default UTF-8 is assumed.
      Parameters:
        `charset` - Charset name
      Returns:
        this

    - #### build

          byte[] build()

      Hash given secret
      Returns:
        Hashed secret as bytes array

    - #### buildAndEncodeBase64

          String buildAndEncodeBase64()

      Hash given secret and encode using Base64
      Returns:
        Base64 encoded hashed secret

Copyright © 2019 The Holon Platform. All rights reserved.