Package com.ultikits.ultitools.entities
Class TokenEntity
java.lang.Object
com.ultikits.ultitools.entities.TokenEntity
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDecode the JWT payload from access_token and populate the fields.Get the decoded payload information (for debugging).Get the token's expiration time.Get the token's issued-at time.Get the user ID as a string (for compatibility).booleanhasAuthority(String authority) Check whether the user has the given authority.booleanCheck whether the token has expired.
-
Field Details
-
access_token
-
refresh_token
-
token_type
-
expires_in
private int expires_in -
scope
-
jti
-
user_id
-
user_name
-
email
-
authorities
-
exp
-
iat
-
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
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
Get the token's expiration time.- Returns:
- the expiration time as a Date, or null if not set
-
getIssuedAt
Get the token's issued-at time.- Returns:
- the issued-at time as a Date, or null if not set
-
hasAuthority
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
Get the user ID as a string (for compatibility).- Returns:
- the user ID as a string, or null if it is null
-