Class JwtValidateKey

  • All Implemented Interfaces:
    java.io.Serializable

    public class JwtValidateKey
    extends java.lang.Object
    implements java.io.Serializable
    JWT validate key.
    Author:
    Daniel Sagenschneider
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      JwtValidateKey​(long startTime, long expireTime, java.security.Key key)
      Instantiate.
      JwtValidateKey​(java.security.Key key)
      Instantiates to (effectively) never expire.
      JwtValidateKey​(Clock<java.lang.Long> timeInSeconds, long periodToExpire, java.util.concurrent.TimeUnit unit, java.security.Key key)
      Instantiate to become active immediately and expire within the specified time.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getExpireTime()
      Obtains the milliseconds since Epoch for expiry of this JwtValidateKey.
      java.security.Key getKey()
      Obtains the Key.
      long getStartTime()
      Obtains the milliseconds since Epoch for when this JwtValidateKey becomes active.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JwtValidateKey

        public JwtValidateKey​(long startTime,
                              long expireTime,
                              java.security.Key key)
                       throws java.lang.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:
        java.lang.IllegalArgumentException - If invalid arguments.
      • JwtValidateKey

        public JwtValidateKey​(Clock<java.lang.Long> timeInSeconds,
                              long periodToExpire,
                              java.util.concurrent.TimeUnit unit,
                              java.security.Key key)
                       throws java.lang.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:
        java.lang.IllegalArgumentException - If invalid arguments.
      • JwtValidateKey

        public JwtValidateKey​(java.security.Key key)
                       throws java.lang.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:
        java.lang.IllegalArgumentException - If missing Key.
    • Method Detail

      • 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 java.security.Key getKey()
        Obtains the Key.
        Returns:
        Key to validate the JWT.