Package com.tnsai.mcp.auth
Record Class PkceFlow.TokenResponse
java.lang.Object
java.lang.Record
com.tnsai.mcp.auth.PkceFlow.TokenResponse
- Record Components:
accessToken- the access tokenrefreshToken- the refresh token, may be nulltokenType- the token type (typically "Bearer")expiresIn- token lifetime in secondsscope- the granted scope, may be nullobtainedAt- the instant when this token was obtained
- Enclosing class:
PkceFlow
public static record PkceFlow.TokenResponse(String accessToken, String refreshToken, String tokenType, long expiresIn, String scope, Instant obtainedAt)
extends Record
Token response from the authorization server.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theaccessTokenrecord component.final booleanIndicates whether some other object is "equal to" this one.longReturns the value of theexpiresInrecord component.final inthashCode()Returns a hash code value for this object.booleanChecks if this token has expired.booleanisExpiringSoon(Duration threshold) Checks if this token is expiring soon, within the given threshold.Returns the value of theobtainedAtrecord component.Returns the value of therefreshTokenrecord component.scope()Returns the value of thescoperecord component.Returns the value of thetokenTyperecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
TokenResponse
public TokenResponse(String accessToken, String refreshToken, String tokenType, long expiresIn, String scope, Instant obtainedAt) Creates an instance of aTokenResponserecord class.- Parameters:
accessToken- the value for theaccessTokenrecord componentrefreshToken- the value for therefreshTokenrecord componenttokenType- the value for thetokenTyperecord componentexpiresIn- the value for theexpiresInrecord componentscope- the value for thescoperecord componentobtainedAt- the value for theobtainedAtrecord component
-
-
Method Details
-
isExpired
public boolean isExpired()Checks if this token has expired.- Returns:
- true if the token has expired
-
isExpiringSoon
Checks if this token is expiring soon, within the given threshold.- Parameters:
threshold- the time before expiry to consider "expiring soon"- Returns:
- true if the token will expire within the threshold
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
accessToken
Returns the value of theaccessTokenrecord component.- Returns:
- the value of the
accessTokenrecord component
-
refreshToken
Returns the value of therefreshTokenrecord component.- Returns:
- the value of the
refreshTokenrecord component
-
tokenType
Returns the value of thetokenTyperecord component.- Returns:
- the value of the
tokenTyperecord component
-
expiresIn
public long expiresIn()Returns the value of theexpiresInrecord component.- Returns:
- the value of the
expiresInrecord component
-
scope
Returns the value of thescoperecord component.- Returns:
- the value of the
scoperecord component
-
obtainedAt
Returns the value of theobtainedAtrecord component.- Returns:
- the value of the
obtainedAtrecord component
-