Class AbstractToken

  • All Implemented Interfaces:
    java.io.Serializable, org.gluu.persist.model.base.Deletable
    Direct Known Subclasses:
    AccessToken, AuthorizationCode, IdToken, RefreshToken, UmaPCT, UmaRPT

    public abstract class AbstractToken
    extends java.lang.Object
    implements java.io.Serializable, org.gluu.persist.model.base.Deletable

    Base class for the access token, refresh token and authorization code.

    When created, a token is valid for a given lifetime, and after this period of time, it will be marked as expired automatically by a background process.

    When required, the token can be marked as revoked.

    Version:
    March 14, 2019
    Author:
    Javier Rojas Blum
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        AbstractToken​(int lifeTime)
      Creates and initializes the values of an abstract token.
      protected AbstractToken​(java.lang.String code, java.util.Date creationDate, java.util.Date expirationDate)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void checkExpired()
      Checks whether the token has expired and if true, marks itself as expired.
      void checkExpired​(java.util.Date now)
      Checks whether the token has expired and if true, marks itself as expired.
      java.lang.String getAuthMode()
      Returns the authentication mode.
      java.lang.String getCode()
      Returns the token code.
      java.util.Date getCreationDate()
      Returns the creation date of the token.
      java.util.Date getExpirationDate()
      Returns the expiration date of the token.
      int getExpiresIn()
      Returns the lifetime in seconds of the token.
      static java.lang.String getHash​(java.lang.String input, SignatureAlgorithm signatureAlgorithm)  
      java.lang.String getSessionDn()  
      int getTtl()  
      java.lang.String getX5ts256()  
      java.lang.Boolean isDeletable()  
      boolean isExpired()
      Return true if the token has expired.
      boolean isRevoked()
      Returns true if the token has been revoked.
      boolean isValid()
      Checks whether a token is valid, it is valid if it is not revoked and not expired.
      void resetTtlFromExpirationDate()  
      void setAuthMode​(java.lang.String authMode)
      Sets the authentication mode.
      void setCode​(java.lang.String code)
      Sets the token code.
      void setCreationDate​(java.util.Date creationDate)
      Sets the creation date of the token.
      void setDeletable​(boolean deletable)  
      void setExpirationDate​(java.util.Date expirationDate)
      Sets the expiration date of the token.
      void setExpired​(boolean expired)
      Sets the value of the expired flag to indicate whether the token has expired.
      void setRevoked​(boolean revoked)
      Sets the value of the revoked flag to indicate whether the token has been revoked.
      void setSessionDn​(java.lang.String sessionDn)  
      void setX5ts256​(java.lang.String x5ts256)  
      • Methods inherited from class java.lang.Object

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

      • AbstractToken

        public AbstractToken​(int lifeTime)
        Creates and initializes the values of an abstract token.
        Parameters:
        lifeTime - The life time of the token.
      • AbstractToken

        protected AbstractToken​(java.lang.String code,
                                java.util.Date creationDate,
                                java.util.Date expirationDate)
    • Method Detail

      • getTtl

        public int getTtl()
      • resetTtlFromExpirationDate

        public void resetTtlFromExpirationDate()
      • checkExpired

        public void checkExpired()
        Checks whether the token has expired and if true, marks itself as expired.
      • checkExpired

        public void checkExpired​(java.util.Date now)
        Checks whether the token has expired and if true, marks itself as expired.
      • isValid

        public boolean isValid()
        Checks whether a token is valid, it is valid if it is not revoked and not expired.
        Returns:
        Returns true if the token is valid.
      • getCode

        public java.lang.String getCode()
        Returns the token code.
        Returns:
        The Code of the token.
      • setCode

        public void setCode​(java.lang.String code)
        Sets the token code.
        Parameters:
        code - The code of the token.
      • getCreationDate

        public java.util.Date getCreationDate()
        Returns the creation date of the token.
        Returns:
        The creation date.
      • setCreationDate

        public void setCreationDate​(java.util.Date creationDate)
        Sets the creation date of the token.
        Parameters:
        creationDate - The creation date.
      • getExpirationDate

        public java.util.Date getExpirationDate()
        Returns the expiration date of the token.
        Returns:
        The expiration date.
      • setExpirationDate

        public void setExpirationDate​(java.util.Date expirationDate)
        Sets the expiration date of the token.
        Parameters:
        expirationDate - The expiration date.
      • isRevoked

        public boolean isRevoked()
        Returns true if the token has been revoked.
        Returns:
        true if the token has been revoked.
      • setRevoked

        public void setRevoked​(boolean revoked)
        Sets the value of the revoked flag to indicate whether the token has been revoked.
        Parameters:
        revoked - Revoke or not.
      • isExpired

        public boolean isExpired()
        Return true if the token has expired.
        Returns:
        true if the token has expired.
      • setExpired

        public void setExpired​(boolean expired)
        Sets the value of the expired flag to indicate whether the token has expired.
        Parameters:
        expired - Expire or not.
      • getAuthMode

        public java.lang.String getAuthMode()
        Returns the authentication mode.
        Returns:
        The authentication mode.
      • setAuthMode

        public void setAuthMode​(java.lang.String authMode)
        Sets the authentication mode.
        Parameters:
        authMode - The authentication mode.
      • getX5ts256

        public java.lang.String getX5ts256()
      • setX5ts256

        public void setX5ts256​(java.lang.String x5ts256)
      • getSessionDn

        public java.lang.String getSessionDn()
      • setSessionDn

        public void setSessionDn​(java.lang.String sessionDn)
      • isDeletable

        public java.lang.Boolean isDeletable()
        Specified by:
        isDeletable in interface org.gluu.persist.model.base.Deletable
      • setDeletable

        public void setDeletable​(boolean deletable)
      • getExpiresIn

        public int getExpiresIn()
        Returns the lifetime in seconds of the token.
        Returns:
        The lifetime in seconds of the token.
      • getHash

        public static java.lang.String getHash​(java.lang.String input,
                                               SignatureAlgorithm signatureAlgorithm)