Class JwtValidateKey

java.lang.Object
net.officefloor.web.jwt.validate.JwtValidateKey
All Implemented Interfaces:
Serializable

public class JwtValidateKey extends Object implements Serializable
JWT validate key.
Author:
Daniel Sagenschneider
See Also:
  • Constructor Details

    • JwtValidateKey

      public JwtValidateKey(long startTime, long expireTime, Key key) throws IllegalArgumentException
      Instantiate.
      Parameters:
      startTime - Seconds since Epoch for when this JwtValidateKey becomes active.
      expireTime - Seconds since Epoch for expiry of this JwtValidateKey.
      key - Key to validate the JWT.
      Throws:
      IllegalArgumentException - If invalid arguments.
    • JwtValidateKey

      public JwtValidateKey(Clock<Long> timeInSeconds, long periodToExpire, TimeUnit unit, Key key) throws IllegalArgumentException
      Instantiate to become active immediately and expire within the specified time.
      Parameters:
      timeInSeconds - Clock to obtain the seconds since Epoch.
      periodToExpire - Period to expire the Key.
      unit - TimeUnit for period.
      key - Key to validate the JWT.
      Throws:
      IllegalArgumentException - If invalid arguments.
    • JwtValidateKey

      public JwtValidateKey(Key key) throws IllegalArgumentException

      Instantiates to (effectively) never expire.

      This should only be used for testing. Within production environments, Key instances should be rotated at a semi-regular basis to reduce impact of compromised keys.

      Parameters:
      key - Key.
      Throws:
      IllegalArgumentException - If missing Key.
  • Method Details

    • getStartTime

      public long getStartTime()
      Obtains the milliseconds since Epoch for when this JwtValidateKey becomes active.
      Returns:
      Milliseconds since Epoch for when this JwtValidateKey becomes active.
    • getExpireTime

      public long getExpireTime()
      Obtains the milliseconds since Epoch for expiry of this JwtValidateKey.
      Returns:
      Milliseconds since Epoch for expiry of this JwtValidateKey.
    • getKey

      public Key getKey()
      Obtains the Key.
      Returns:
      Key to validate the JWT.