Record Class OAuthGrant

java.lang.Object
java.lang.Record
dev.relism.flash.ext.security.oauthserver.OAuthGrant
Record Components:
subject - who authorized it, as OAuthSubject.id()
claims - carried into every access token issued from it
redirectUri - the one the authorization request named, which the code exchange must repeat; null otherwise
challenge - the PKCE S256 challenge; codes only
usedAt - when it was exchanged, null while it is unused

public record OAuthGrant(String hash, OAuthGrant.Kind kind, String family, String clientId, String subject, Map<String,Object> claims, String scope, String resource, String redirectUri, String challenge, Instant expiresAt, Instant usedAt) extends Record
An authorization code or a refresh token, stored under the hash of its value. Every grant descending from one authorization shares a family, so a replayed code or a reused refresh token revokes the whole of it (OAuth 2.1 §4.1.2, §4.3.1).
  • Constructor Details

    • OAuthGrant

      public OAuthGrant(String hash, OAuthGrant.Kind kind, String family, String clientId, String subject, Map<String,Object> claims, String scope, String resource, String redirectUri, String challenge, Instant expiresAt, Instant usedAt)
      Creates an instance of a OAuthGrant record class.
      Parameters:
      hash - the value for the hash record component
      kind - the value for the kind record component
      family - the value for the family record component
      clientId - the value for the clientId record component
      subject - the value for the subject record component
      claims - the value for the claims record component
      scope - the value for the scope record component
      resource - the value for the resource record component
      redirectUri - the value for the redirectUri record component
      challenge - the value for the challenge record component
      expiresAt - the value for the expiresAt record component
      usedAt - the value for the usedAt record component
  • Method Details

    • used

      public OAuthGrant used(Instant at)
    • 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.
    • hash

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

      public OAuthGrant.Kind kind()
      Returns the value of the kind record component.
      Returns:
      the value of the kind record component
    • family

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

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

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

      public Map<String,Object> claims()
      Returns the value of the claims record component.
      Returns:
      the value of the claims record component
    • scope

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

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

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

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

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

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