Record Class TokenValidationRequest

java.lang.Object
java.lang.Record
io.fluxzero.idp.client.TokenValidationRequest
Record Components:
token - compact serialized JWT
issuer - exact issuer expected in the iss claim
audiences - accepted audiences for this validation context
expectedTokenUse - expected Fluxzero token_use value, or blank to skip the check
now - clock value used for temporal validation
leeway - tolerated clock skew for temporal validation

public record TokenValidationRequest(String token, String issuer, List<String> audiences, String expectedTokenUse, Instant now, Duration leeway) extends Record
Parameters for validating an ID or access token against a configured OIDC tenant.
  • Constructor Details

    • TokenValidationRequest

      public TokenValidationRequest(String token, String issuer, List<String> audiences, String expectedTokenUse, Instant now, Duration leeway)
      Creates an instance of a TokenValidationRequest record class.
      Parameters:
      token - the value for the token record component
      issuer - the value for the issuer record component
      audiences - the value for the audiences record component
      expectedTokenUse - the value for the expectedTokenUse record component
      now - the value for the now record component
      leeway - the value for the leeway record component
  • Method Details

    • idToken

      public static TokenValidationRequest idToken(String token, OidcTenantConfig config)
      Creates a validation request for an ID token returned to the BFF callback.

      ID tokens are intended for the application client, so the accepted audience is the configured client id.

      Parameters:
      token - compact serialized ID token
      config - tenant configuration
      Returns:
      validation request for an ID token
    • accessToken

      public static TokenValidationRequest accessToken(String token, OidcTenantConfig config)
      Creates a validation request for a bearer access token sent to backend APIs.

      Access tokens are intended for a resource/API audience, not for the application client id.

      Parameters:
      token - compact serialized access token
      config - tenant configuration
      Returns:
      validation request for an access token
    • withNow

      public TokenValidationRequest withNow(Instant newNow)
      Returns a copy with a deterministic clock value.
      Parameters:
      newNow - clock value to validate against
      Returns:
      copy with the supplied clock value
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
    • token

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

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

      public List<String> audiences()
      Returns the value of the audiences record component.
      Returns:
      the value of the audiences record component
    • expectedTokenUse

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

      public Instant now()
      Returns the value of the now record component.
      Returns:
      the value of the now record component
    • leeway

      public Duration leeway()
      Returns the value of the leeway record component.
      Returns:
      the value of the leeway record component