Record Class NewApiKey

java.lang.Object
java.lang.Record
org.jwcarman.who.apikey.NewApiKey
Record Components:
id - the key's credential id, to list, rotate or revoke it by
name - the key's name
key - the raw key, sent in the API-key header; never in toString()
scopes - the permissions the key may use, at most
expiresAt - when the key stops signing in

public record NewApiKey(UUID id, String name, String key, Set<String> scopes, Instant expiresAt) extends Record
A key just made, by ApiKeyService.create(Identity, String, Duration, Set) or ApiKeyService.rotate(UUID, Duration): the only time the raw key exists outside the caller. Show it once; who keeps only its hash.
  • Constructor Details

  • Method Details

    • toString

      public String toString()
      Describes the key without the raw key, so it is safe to log.
      Specified by:
      toString in class Record
      Returns:
      the id, name, scopes and expiry
    • 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.
    • id

      public UUID id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • name

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

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

      public Set<String> scopes()
      Returns the value of the scopes record component.
      Returns:
      the value of the scopes record component
    • expiresAt

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