Class AbstractToken

  • All Implemented Interfaces:
    io.jans.orm.model.base.Deletable, Serializable
    Direct Known Subclasses:
    AccessToken, AuthorizationCode, IdToken, RefreshToken, UmaPCT, UmaRPT

    public abstract class AbstractToken
    extends Object
    implements Serializable, io.jans.orm.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:
    September 30, 2021
    Author:
    Javier Rojas Blum
    See Also:
    Serialized Form
    • Constructor Detail

      • AbstractToken

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

        protected AbstractToken​(String code,
                                Date creationDate,
                                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​(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 String getCode()
        Returns the token code.
        Returns:
        The Code of the token.
      • setCode

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

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

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

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

        public void setExpirationDate​(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.
      • getX5ts256

        public String getX5ts256()
      • setX5ts256

        public void setX5ts256​(String x5ts256)
      • getDpop

        public String getDpop()
      • setDpop

        public void setDpop​(String dpop)
      • getSessionDn

        public String getSessionDn()
      • setSessionDn

        public void setSessionDn​(String sessionDn)
      • isDeletable

        public Boolean isDeletable()
        Specified by:
        isDeletable in interface io.jans.orm.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 String getHash​(String input,
                                     io.jans.as.model.crypto.signature.SignatureAlgorithm signatureAlgorithm)