com.holonplatform.auth.internal

## Class DefaultCredentials

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

- All Implemented Interfaces:
    Credentials, Serializable

      public class DefaultCredentials
      extends Object
      implements Credentials

  Default `Credentials` implementation
  Since:
    5.0.0
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DefaultCredentials.CredentialsBuilder` Default `Builder` implementation.
    `static class` | `DefaultCredentials.CredentialsEncoder` Default `Encoder` implementation.

    - ### Nested classes/interfaces inherited from interface com.holonplatform.auth.Credentials

      `Credentials.Builder, Credentials.Encoder`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultCredentials()` Constructor
    `DefaultCredentials(byte[] secret)` Constructor
    `DefaultCredentials(byte[] secret, String hashAlgorithm)` Constructor
    `DefaultCredentials(byte[] secret, String hashAlgorithm, byte[] salt, int hashIterations)` Constructor
    `DefaultCredentials(String secret)` Constructor
    `DefaultCredentials(String secret, String hashAlgorithm)` Constructor
    `DefaultCredentials(String secret, String hashAlgorithm, byte[] salt, int hashIterations)` Constructor
    `DefaultCredentials(String secret, String hashAlgorithm, String salt, int hashIterations)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Date` | `getExpireDate()` Credential expire date
    `String` | `getHashAlgorithm()` Get hash algorithm used to encode secret.
    `int` | `getHashIterations()` Get hash iterations performed for secret encoding
    `byte[]` | `getSalt()` Get salt data used to hash secret
    `byte[]` | `getSecret()` Get secret data (e.g. password)
    `boolean` | `isBase64Encoded()` Whether secret is encoded using Base64.
    `boolean` | `isHexEncoded()` Whether secret is encoded using hexademical representation
    `void` | `setBase64Encoded(boolean base64Encoded)` Set whether secret is encoded using Base64
    `void` | `setExpireDate(Date expireDate)` Set credential expire date
    `void` | `setHashAlgorithm(String hashAlgorithm)` Set hash algorithm name
    `void` | `setHashIterations(int hashIterations)` Set hash iterations performed to encode secret
    `void` | `setHexEncoded(boolean hexEncoded)` Set whether secret is hex encoded
    `void` | `setSalt(byte[] salt)` Set salt data used to hash secret
    `void` | `setSalt(String salt)` Set salt as UTF-8 String
    `void` | `setSecret(byte[] secret)` Set secret
    `void` | `setSecret(String secret)` Set secret as UTF-8 String

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

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

    - ### Methods inherited from interface com.holonplatform.auth.Credentials

      `builder, encoder`

- - ### Constructor Detail

    - #### DefaultCredentials

          public DefaultCredentials()

      Constructor

    - #### DefaultCredentials

          public DefaultCredentials(String secret)

      Constructor
      Parameters:
        `secret` - Secret (e.g. password)

    - #### DefaultCredentials

          public DefaultCredentials(String secret,
                                    String hashAlgorithm)

      Constructor
      Parameters:
        `secret` - Secret (e.g. password)
        `hashAlgorithm` - Hash algorithm used to encode secret

    - #### DefaultCredentials

          public DefaultCredentials(String secret,
                                    String hashAlgorithm,
                                    byte[] salt,
                                    int hashIterations)

      Constructor
      Parameters:
        `secret` - Secret (e.g. password)
        `hashAlgorithm` - Hash algorithm used to encode secret
        `salt` - Salt used in secret hashing
        `hashIterations` - Hash iterations performed to encode secret

    - #### DefaultCredentials

          public DefaultCredentials(String secret,
                                    String hashAlgorithm,
                                    String salt,
                                    int hashIterations)

      Constructor
      Parameters:
        `secret` - Secret (e.g. password)
        `hashAlgorithm` - Hash algorithm used to encode secret
        `salt` - Salt used in secret hashing
        `hashIterations` - Hash iterations performed to encode secret

    - #### DefaultCredentials

          public DefaultCredentials(byte[] secret)

      Constructor
      Parameters:
        `secret` - Secret (e.g. password)

    - #### DefaultCredentials

          public DefaultCredentials(byte[] secret,
                                    String hashAlgorithm)

      Constructor
      Parameters:
        `secret` - Secret (e.g. password)
        `hashAlgorithm` - Hash algorithm used to encode secret

    - #### DefaultCredentials

          public DefaultCredentials(byte[] secret,
                                    String hashAlgorithm,
                                    byte[] salt,
                                    int hashIterations)

      Constructor
      Parameters:
        `secret` - Secret (e.g. password)
        `hashAlgorithm` - Hash algorithm used to encode secret
        `salt` - Salt used in secret hashing
        `hashIterations` - Hash iterations performed to encode secret

  - ### Method Detail

    - #### getSecret

          public byte[] getSecret()

      Description copied from interface: `Credentials`
      Get secret data (e.g. password)
      Specified by:
        `getSecret` in interface `Credentials`
      Returns:
        Secret

    - #### getHashAlgorithm

          public String getHashAlgorithm()

      Description copied from interface: `Credentials`
      Get hash algorithm used to encode secret. If `null`, means secret is not hashed and `Credentials.getSalt()` or `Credentials.getHashIterations()` must be ignored.
      Specified by:
        `getHashAlgorithm` in interface `Credentials`
      Returns:
        Hash algorithm name

    - #### getSalt

          public byte[] getSalt()

      Description copied from interface: `Credentials`
      Get salt data used to hash secret
      Specified by:
        `getSalt` in interface `Credentials`
      Returns:
        Salt data

    - #### getHashIterations

          public int getHashIterations()

      Description copied from interface: `Credentials`
      Get hash iterations performed for secret encoding
      Specified by:
        `getHashIterations` in interface `Credentials`
      Returns:
        Hash iterations

    - #### isBase64Encoded

          public boolean isBase64Encoded()

      Description copied from interface: `Credentials`
      Whether secret is encoded using Base64. If `true` and hash algorithm is specified, any salt data will be considered Base64 encoded too.
      Specified by:
        `isBase64Encoded` in interface `Credentials`
      Returns:
        `true` if secret is encoded using Base64

    - #### isHexEncoded

          public boolean isHexEncoded()

      Description copied from interface: `Credentials`
      Whether secret is encoded using hexademical representation
      Specified by:
        `isHexEncoded` in interface `Credentials`
      Returns:
        `true` if secret is hex encoded

    - #### getExpireDate

          public Date getExpireDate()

      Description copied from interface: `Credentials`
      Credential expire date
      Specified by:
        `getExpireDate` in interface `Credentials`
      Returns:
        Credential expire date, or `null` if credential never expires

    - #### setSecret

          public void setSecret(byte[] secret)

      Set secret
      Parameters:
        `secret` - the secret to set

    - #### setSecret

          public void setSecret(String secret)

      Set secret as UTF-8 String
      Parameters:
        `secret` - the secret to set

    - #### setHashAlgorithm

          public void setHashAlgorithm(String hashAlgorithm)

      Set hash algorithm name
      Parameters:
        `hashAlgorithm` - the hashAlgorithm to set

    - #### setSalt

          public void setSalt(byte[] salt)

      Set salt data used to hash secret
      Parameters:
        `salt` - the salt to set

    - #### setSalt

          public void setSalt(String salt)

      Set salt as UTF-8 String
      Parameters:
        `salt` - the salt to set

    - #### setHashIterations

          public void setHashIterations(int hashIterations)

      Set hash iterations performed to encode secret
      Parameters:
        `hashIterations` - the hashIterations to set

    - #### setBase64Encoded

          public void setBase64Encoded(boolean base64Encoded)

      Set whether secret is encoded using Base64
      Parameters:
        `base64Encoded` - `true` if secret is encoded using Base64

    - #### setHexEncoded

          public void setHexEncoded(boolean hexEncoded)

      Set whether secret is hex encoded
      Parameters:
        `hexEncoded` - `true` if secret is hex encoded

    - #### setExpireDate

          public void setExpireDate(Date expireDate)

      Set credential expire date
      Parameters:
        `expireDate` - Expire date

Copyright © 2019 The Holon Platform. All rights reserved.