Class TokenEntity

java.lang.Object
com.ultikits.ultitools.entities.TokenEntity

public class TokenEntity extends Object
  • Field Details

    • access_token

      private String access_token
    • refresh_token

      private String refresh_token
    • token_type

      private String token_type
    • expires_in

      private int expires_in
    • scope

      private String scope
    • jti

      private String jti
    • user_id

      private Long user_id
    • user_name

      private String user_name
    • email

      private String email
    • authorities

      private String[] authorities
    • exp

      private Long exp
    • iat

      private Long iat
    • client_id

      private String client_id
  • Constructor Details

    • TokenEntity

      public TokenEntity()
  • Method Details

    • decodeJwtPayload

      public void decodeJwtPayload()
      Decode the JWT payload from access_token and populate the fields.
    • getDecodedInfo

      public String getDecodedInfo()
      Get the decoded payload information (for debugging).
      Returns:
      a string containing the decoded information
    • isExpired

      public boolean isExpired()
      Check whether the token has expired.
      Returns:
      true if expired, false if still valid
    • getExpirationDate

      public Date getExpirationDate()
      Get the token's expiration time.
      Returns:
      the expiration time as a Date, or null if not set
    • getIssuedAt

      public Date getIssuedAt()
      Get the token's issued-at time.
      Returns:
      the issued-at time as a Date, or null if not set
    • hasAuthority

      public boolean hasAuthority(String authority)
      Check whether the user has the given authority.
      Parameters:
      authority - the authority to check
      Returns:
      true if the user has that authority, false otherwise
    • getUserIdAsString

      public String getUserIdAsString()
      Get the user ID as a string (for compatibility).
      Returns:
      the user ID as a string, or null if it is null