Class SimpleTokenData

  • All Implemented Interfaces:
    Serializable, TokenData

    public final class SimpleTokenData
    extends Object
    implements Serializable, TokenData
    Simple Token information class that contains a username and a lifetime. The class is not able to detect time manipulations. It is assumed that the current time of the system is correct. This class is immutable. Created by Martin Stockhammer on 03.02.17.
    See Also:
    Serialized Form
    • Constructor Detail

      • SimpleTokenData

        public SimpleTokenData​(String user,
                               long lifetime,
                               long nonce)
        Creates a new token info instance for the given user. The lifetime in milliseconds defines the invalidation date by adding the lifetime to the current time of instantiation.
        Parameters:
        user - The user name
        lifetime - The number of milliseconds after that the token is invalid
        nonce - Should be a random number and different for each instance.
      • SimpleTokenData

        public SimpleTokenData​(String user,
                               Duration lifetime,
                               long nonce)
        Creates a new token info instance for the given user. The lifetime in milliseconds defines the invalidation date by adding the lifetime to the current time of instantiation.
        Parameters:
        user - The user name
        lifetime - The number of milliseconds after that the token is invalid
        nonce - Should be a random number and different for each instance.
    • Method Detail

      • created

        public final Instant created()
        Description copied from interface: TokenData
        The date the token was created.
        Specified by:
        created in interface TokenData
        Returns:
        The creation date.
      • getNonce

        public final long getNonce()
        Description copied from interface: TokenData
        The nonce that is stored in the token.
        Specified by:
        getNonce in interface TokenData
        Returns:
        The nonce.
      • isValid

        public boolean isValid()
        Description copied from interface: TokenData
        Returns true, if the token is valid.
        Specified by:
        isValid in interface TokenData
        Returns:
        True, if valid, otherwise false.