Record Class MintedToken
- Record Components:
token- the access token, held in a zeroizable, redacting wrapperlifetime- how long the issuer said the token is good for; strictly positive
A lifetime, not a deadline
This carries expires_in as the server sent it, and deliberately does NOT convert it to
an absolute instant. Converting requires a clock, and the clock that decides when this token
stops being usable belongs to CachingTokenSource - which is injectable, so that expiry can
be tested by moving time rather than by waiting for it. Computing the instant here, against
whatever Instant.now() returns, would put the conversion on a second clock that the
freshness decision cannot see. That is not a hypothetical: the first version of this record did
exactly that, and the source it fed then treated every token as valid forever, because the two
clocks disagreed by months.
The expiry comes from the platform, never from a claim the SDK read
expires_in is stated outright by the issuer, in the same response that carried the
token. Nothing here parses a JWT to find out, and in particular nothing parses the EXTERNAL token
a federated workload presented: that token is opaque to the SDK by design, and inferring a
lifetime from it would mean believing a claim from an issuer the SDK does not verify.
-
Constructor Summary
ConstructorsConstructorDescriptionMintedToken(BearerToken token, Duration lifetime) Creates an instance of aMintedTokenrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.lifetime()Returns the value of thelifetimerecord component.token()Returns the value of thetokenrecord component.toString()Redacted: the wrapper's owntoStringshows at most a six-character prefix.value()Renders the token for the wire.
-
Constructor Details
-
Method Details
-
value
Renders the token for the wire.Materialising a
Stringis an unavoidable loss at the HTTP boundary - a header value is a String and the JVM cannot erase one - so it is done at the last possible moment and never stored.- Returns:
- the token value
- Throws:
IllegalStateException- if the token has already been cleared
-
toString
Redacted: the wrapper's owntoStringshows at most a six-character prefix. -
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. All components in this record class are compared withObjects::equals(Object,Object). -
token
Returns the value of thetokenrecord component.- Returns:
- the value of the
tokenrecord component
-
lifetime
Returns the value of thelifetimerecord component.- Returns:
- the value of the
lifetimerecord component
-