Record Class BearerToken

java.lang.Object
java.lang.Record
com.eqixiac.equinix.core.auth.BearerToken
Record Components:
value - the bearer token; must not be null or blank
expiresAt - when the token expires, or null when unknown

public record BearerToken(String value, Instant expiresAt) extends Record
A bearer access token supplied by a BearerTokenProvider: the token value sent as Authorization: Bearer <value> and, optionally, the instant it expires.

When expiresAt is known, the SDK asks the provider for a new token shortly (30 seconds) before that instant. When it is null, the token is used until the service answers HTTP 401, at which point the provider is asked once for a replacement.

Author:
ianjones
  • Constructor Details

  • Method Details

    • of

      public static BearerToken of(String value)
      A token with no known expiry.
      Parameters:
      value - the bearer token
      Returns:
      the token
    • toString

      public String toString()
      Never prints the token value, so a token cannot leak into logs through toString().
      Specified by:
      toString in class Record
      Returns:
      a redacted description
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • value

      public String value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component
    • expiresAt

      public Instant expiresAt()
      Returns the value of the expiresAt record component.
      Returns:
      the value of the expiresAt record component