Class AccessToken
java.lang.Object
com.developer.nefarious.zjoule.plugin.models.AccessToken
Represents an OAuth2 access token along with its metadata and expiration details.
The AccessToken
class is used to store information about an OAuth2 access token,
including the token string, its type, expiration time, scope, and additional metadata.
It also tracks the time the token was received, allowing for validation of its validity
based on the expiration time.
-
Constructor Summary
ConstructorDescriptionDefault constructor that initializes thereceivedAt
field to the current time. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the access token string.long
Retrieves the expiration time in seconds.getJti()
Retrieves the unique token identifier.Retrieves the time the token was received.getScope()
Retrieves the scope of the token.Retrieves the token type (e.g., Bearer).isValid()
Checks if the access token is still valid based on its expiration time and the time it was received.void
setAccessToken
(String accessToken) Sets the access token string.void
setExpiresIn
(long expiresIn) Sets the expiration time in seconds.void
Sets the unique token identifier.void
setReceivedAt
(Date receivedAt) Sets the time the token was received.void
Sets the scope of the token.void
setTokenType
(String tokenType) Sets the token type (e.g., Bearer).
-
Constructor Details
-
AccessToken
public AccessToken()Default constructor that initializes thereceivedAt
field to the current time.The
receivedAt
field is used to calculate the token's validity duration based on itsexpiresIn
value.
-
-
Method Details
-
getAccessToken
Retrieves the access token string.- Returns:
- the access token string.
-
getExpiresIn
public long getExpiresIn()Retrieves the expiration time in seconds.- Returns:
- the expiration time in seconds.
-
getJti
Retrieves the unique token identifier.- Returns:
- the token's unique identifier.
-
getReceivedAt
Retrieves the time the token was received.- Returns:
- the
Date
when the token was received.
-
getScope
Retrieves the scope of the token.- Returns:
- the token's scope.
-
getTokenType
Retrieves the token type (e.g., Bearer).- Returns:
- the token type.
-
isValid
Checks if the access token is still valid based on its expiration time and the time it was received.- Returns:
true
if the token is still valid;false
otherwise.
-
setAccessToken
Sets the access token string.- Parameters:
accessToken
- the access token string to set.
-
setExpiresIn
public void setExpiresIn(long expiresIn) Sets the expiration time in seconds.- Parameters:
expiresIn
- the expiration time in seconds to set.
-
setJti
Sets the unique token identifier.- Parameters:
jti
- the token's unique identifier to set.
-
setReceivedAt
Sets the time the token was received.- Parameters:
receivedAt
- theDate
when the token was received.
-
setScope
Sets the scope of the token.- Parameters:
scope
- the token's scope to set.
-
setTokenType
Sets the token type (e.g., Bearer).- Parameters:
tokenType
- the token type to set.
-