com.holonplatform.auth.internal

## Class DefaultCredentials.CredentialsEncoder

- java.lang.Object
- - com.holonplatform.auth.internal.DefaultCredentials.CredentialsEncoder

- All Implemented Interfaces:
    Credentials.Encoder
  Enclosing class:
    DefaultCredentials

      public static class DefaultCredentials.CredentialsEncoder
      extends Object
      implements Credentials.Encoder

  Default `Encoder` implementation.

- - ### Field Summary

    - ### Fields inherited from interface com.holonplatform.auth.Credentials.Encoder

      `HASH_MD2, HASH_MD5, HASH_SHA_1, HASH_SHA_256, HASH_SHA_384, HASH_SHA_512`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CredentialsEncoder()`

  - ### Method Summary

    All Methods Instance Methods Concrete 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

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

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

- - ### Constructor Detail

    - #### CredentialsEncoder

          public CredentialsEncoder()

  - ### Method Detail

    - #### secret

          public Credentials.Encoder secret(String secret)

      Description copied from interface: `Credentials.Encoder`
      Secret text to encode
      Specified by:
        `secret` in interface `Credentials.Encoder`
      Parameters:
        `secret` - Secret text (for example a password)
      Returns:
        this

    - #### salt

          public Credentials.Encoder salt(byte[] salt)

      Description copied from interface: `Credentials.Encoder`
      Optional salt to use for hashing
      Specified by:
        `salt` in interface `Credentials.Encoder`
      Parameters:
        `salt` - Salt data
      Returns:
        this
      See Also:
        `Hash.generateSalt()`

    - #### salt

          public Credentials.Encoder salt(String salt)

      Description copied from interface: `Credentials.Encoder`
      Optional salt to use for hashing
      Specified by:
        `salt` in interface `Credentials.Encoder`
      Parameters:
        `salt` - Salt string
      Returns:
        this
      See Also:
        `Hash.generateSalt()`

    - #### hashAlgorithm

          public Credentials.Encoder hashAlgorithm(String algorithm)

      Description copied from interface: `Credentials.Encoder`
      Hash algorithm to use. Default is SHA-256
      Specified by:
        `hashAlgorithm` in interface `Credentials.Encoder`
      Parameters:
        `algorithm` - Hash algorithm name
      Returns:
        this

    - #### hashMD5

          public Credentials.Encoder hashMD5()

      Description copied from interface: `Credentials.Encoder`
      Apply MD5 hash algorithm
      Specified by:
        `hashMD5` in interface `Credentials.Encoder`
      Returns:
        this

    - #### hashSHA1

          public Credentials.Encoder hashSHA1()

      Description copied from interface: `Credentials.Encoder`
      Apply SHA-1 hash algorithm
      Specified by:
        `hashSHA1` in interface `Credentials.Encoder`
      Returns:
        this

    - #### hashSHA256

          public Credentials.Encoder hashSHA256()

      Description copied from interface: `Credentials.Encoder`
      Apply SHA-256 hash algorithm
      Specified by:
        `hashSHA256` in interface `Credentials.Encoder`
      Returns:
        this

    - #### hashSHA384

          public Credentials.Encoder hashSHA384()

      Description copied from interface: `Credentials.Encoder`
      Apply SHA-384 hash algorithm
      Specified by:
        `hashSHA384` in interface `Credentials.Encoder`
      Returns:
        this

    - #### hashSHA512

          public Credentials.Encoder hashSHA512()

      Description copied from interface: `Credentials.Encoder`
      Apply SHA-512 hash algorithm
      Specified by:
        `hashSHA512` in interface `Credentials.Encoder`
      Returns:
        this

    - #### hashIterations

          public Credentials.Encoder hashIterations(int iterations)

      Description copied from interface: `Credentials.Encoder`
      Set hash iterations to perform. Default is 1.
      Specified by:
        `hashIterations` in interface `Credentials.Encoder`
      Parameters:
        `iterations` - Hash iterations
      Returns:
        this

    - #### charset

          public Credentials.Encoder charset(String charset)

      Description copied from interface: `Credentials.Encoder`
      Secret encoding charset name. By default UTF-8 is assumed.
      Specified by:
        `charset` in interface `Credentials.Encoder`
      Parameters:
        `charset` - Charset name
      Returns:
        this

    - #### build

          public byte[] build()

      Description copied from interface: `Credentials.Encoder`
      Hash given secret
      Specified by:
        `build` in interface `Credentials.Encoder`
      Returns:
        Hashed secret as bytes array

    - #### buildAndEncodeBase64

          public String buildAndEncodeBase64()

      Description copied from interface: `Credentials.Encoder`
      Hash given secret and encode using Base64
      Specified by:
        `buildAndEncodeBase64` in interface `Credentials.Encoder`
      Returns:
        Base64 encoded hashed secret

Copyright © 2019 The Holon Platform. All rights reserved.