Record Class OAuthToken
java.lang.Object
java.lang.Record
org.apache.juneau.rest.auth.oauth.flow.OAuthToken
- Record Components:
accessToken- The opaque or JWT access-token string. Nevernull.tokenType- The token type per RFC 6749 §5.1 (typically"Bearer"). Nevernull.expiresAt- The instant at which the access token expires. May beInstant.MAXwhen the IdP returned noexpires_in.refreshToken- The refresh token, if the IdP issued one.scope- The granted scopes, if the IdP returned ascopefield.idToken- The OIDC ID token (a JWT), if the flow scope includedopenid. Not validated — seeidToken().
public record OAuthToken(String accessToken, String tokenType, Instant expiresAt, Optional<String> refreshToken, Optional<Set<String>> scope, Optional<String> idToken)
extends Record
Immutable record returned by every OAuth 2.0 flow helper on a successful token acquisition.
Never log accessToken / refreshToken / idToken. toString() redacts the
secret-bearing fields so token material never reaches logs via this record's auto-generated form.
- Since:
- 10.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theaccessTokenrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theexpiresAtrecord component.final inthashCode()Returns a hash code value for this object.idToken()The OIDC ID token (a JWT), if the flow scope includedopenid.booleanReturns whether the token is past its expiration instant relative to the supplied clock.Returns the value of therefreshTokenrecord component.scope()Returns the value of thescoperecord component.Returns the value of thetokenTyperecord component.toString()Redacts the secret-bearing fields so token material never reaches logs via this record'stoString().
-
Constructor Details
-
Method Details
-
isExpired
Returns whether the token is past its expiration instant relative to the supplied clock.- Parameters:
now- The reference instant (typicallyClock.instant()).skew- Skew tolerance (subtracted fromexpiresAt). Must be non-negative.- Returns:
true ifnow >= expiresAt - skew.
-
idToken
The OIDC ID token (a JWT), if the flow scope includedopenid.SECURITY CAVEAT: this ID token is returned verbatim and is NOT validated by the flow helpers — its signature and its
iss/aud/exp/nonceclaims are not checked. Callers MUST NOT trust its claims for authentication or authorization decisions without performing fullIDTokenValidator-based verification first.- Returns:
- The raw ID token, or an empty
Optionalif the IdP issued none.
-
toString
Redacts the secret-bearing fields so token material never reaches logs via this record'stoString(). -
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. All components in this record class are compared withObjects::equals(Object,Object). -
accessToken
Returns the value of theaccessTokenrecord component.- Returns:
- the value of the
accessTokenrecord component
-
tokenType
Returns the value of thetokenTyperecord component.- Returns:
- the value of the
tokenTyperecord component
-
expiresAt
Returns the value of theexpiresAtrecord component.- Returns:
- the value of the
expiresAtrecord component
-
refreshToken
Returns the value of therefreshTokenrecord component.- Returns:
- the value of the
refreshTokenrecord component
-
scope
Returns the value of thescoperecord component.- Returns:
- the value of the
scoperecord component
-