Class Token

java.lang.Object
com.codingchili.core.security.Token
All Implemented Interfaces:
Serializable

public class Token extends Object implements Serializable
Used to authenticate requests between services and with clients.
See Also:
Serialized Form
  • Constructor Details

    • Token

      public Token()
      Creates a new empty unverified token.
    • Token

      public Token(String domain)
      Creates a new hmac token with the specified token factory.
      Parameters:
      domain - a unique identifier - username or service id.
  • Method Details

    • getKey

      public String getKey()
      Returns:
      the cipher value of the token.
    • setKey

      public Token setKey(String key)
      Parameters:
      key - the cipher value, this should be cryptographically generated and balidated.
      Returns:
      fluent.
    • getExpiry

      public long getExpiry()
      Returns:
      the time of expiry in epoch seconds.
    • setExpiry

      public Token setExpiry(long expiry)
      Parameters:
      expiry - the time of expiry on epoch seconds.
      Returns:
      fluent
    • expires

      public Token expires(long value, TimeUnit unit)
      Sets the expiry date of the token.
      Parameters:
      value - the number of time units the token is valid for from now.
      unit - the time unit of the given value.
      Returns:
      fluent.
    • getDomain

      public String getDomain()
      Returns:
      the domain in which this token is valid for authentication.
    • setDomain

      public Token setDomain(String domain)
      Parameters:
      domain - the domain where this token should be valid for authentication.
      Returns:
      fluent.
    • getProperty

      public <T> T getProperty(String key)
    • addProperty

      public Token addProperty(String key, Object value)
      Adds a property to the token. This must be cryptographically incorporated in the getKey().
      Parameters:
      key - the key of the property to set.
      value - the value of the property to set.
      Returns:
      fluent.
    • getProperties

      public Map<String,​Object> getProperties()
      Returns:
      all properties that are set on the token.
    • setProperties

      public Token setProperties(Map<String,​Object> properties)
      Parameters:
      properties - a map of properties to set.
      Returns:
      fluent.