Record Class PlayerCertificate

java.lang.Object
java.lang.Record
lol.trq.alts.account.PlayerCertificate
Record Components:
privateKeyPem - the PEM-encoded RSA private key
publicKeyPem - the PEM-encoded RSA public key
publicKeySignatureV2 - the service's Base64 signature over the public key, in the current scheme
publicKeySignature - the signature in the older scheme, which the services have deprecated; may be null
expiresAt - when the pair stops being valid, or null when the service did not say
refreshedAfter - when the service suggests fetching a new pair, ahead of the expiry; may be null

public record PlayerCertificate(String privateKeyPem, String publicKeyPem, String publicKeySignatureV2, String publicKeySignature, Instant expiresAt, Instant refreshedAfter) extends Record
An account's chat-signing key pair, from POST /player/certificates: an RSA key pair, the service's signature over the public key, and how long the pair is good for.

The private key signs chat as the account, so it is a credential: it is redacted from toString(), and the library neither stores nor logs it. A host that wants to reuse a pair across launches persists it itself, under whatever protection it gives the account's tokens, and asks for a new one once shouldRefresh(Instant) says so.

Since:
0.12.0
  • Constructor Details

    • PlayerCertificate

      public PlayerCertificate(String privateKeyPem, String publicKeyPem, String publicKeySignatureV2, String publicKeySignature, Instant expiresAt, Instant refreshedAfter)
      Creates an instance of a PlayerCertificate record class.
      Parameters:
      privateKeyPem - the value for the privateKeyPem record component
      publicKeyPem - the value for the publicKeyPem record component
      publicKeySignatureV2 - the value for the publicKeySignatureV2 record component
      publicKeySignature - the value for the publicKeySignature record component
      expiresAt - the value for the expiresAt record component
      refreshedAfter - the value for the refreshedAfter record component
  • Method Details

    • privateKey

      public PrivateKey privateKey()
      Decodes the private key.
      Returns:
      the RSA private key
      Throws:
      AltsException - of kind INVALID_INPUT if the PEM is absent or its body is not Base64, or of kind CRYPTO if what it decodes to is not a PKCS#8 RSA key; the message never quotes the key
      Since:
      0.12.0
    • publicKey

      public PublicKey publicKey()
      Decodes the public key.
      Returns:
      the RSA public key
      Throws:
      AltsException - of kind INVALID_INPUT if the PEM is absent or its body is not Base64, or of kind CRYPTO if what it decodes to is not an X.509 RSA key
      Since:
      0.12.0
    • expired

      public boolean expired(Instant now)
      Returns whether the pair is no longer valid at the given instant. A pair with no stated expiry is treated as expired, since nothing vouches for it.
      Parameters:
      now - the instant to measure against
      Returns:
      true if the pair has expired or carries no expiry
      Since:
      0.12.0
    • shouldRefresh

      public boolean shouldRefresh(Instant now)
      Returns whether a new pair should be fetched: the service's suggested refresh time has passed, or the pair has expired.
      Parameters:
      now - the instant to measure against
      Returns:
      true if it is time to fetch a new pair
      Since:
      0.12.0
    • toString

      public String toString()
      Returns a description with the private key redacted.
      Specified by:
      toString in class Record
      Returns:
      a string safe to log
      Since:
      0.12.0
    • 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.
    • privateKeyPem

      @SerializedName("privateKey") public String privateKeyPem()
      Returns the value of the privateKeyPem record component.
      Returns:
      the value of the privateKeyPem record component
    • publicKeyPem

      @SerializedName("publicKey") public String publicKeyPem()
      Returns the value of the publicKeyPem record component.
      Returns:
      the value of the publicKeyPem record component
    • publicKeySignatureV2

      @SerializedName("publicKeySignatureV2") public String publicKeySignatureV2()
      Returns the value of the publicKeySignatureV2 record component.
      Returns:
      the value of the publicKeySignatureV2 record component
    • publicKeySignature

      @SerializedName("publicKeySignature") public String publicKeySignature()
      Returns the value of the publicKeySignature record component.
      Returns:
      the value of the publicKeySignature record component
    • expiresAt

      @SerializedName("expiresAt") public Instant expiresAt()
      Returns the value of the expiresAt record component.
      Returns:
      the value of the expiresAt record component
    • refreshedAfter

      @SerializedName("refreshedAfter") public Instant refreshedAfter()
      Returns the value of the refreshedAfter record component.
      Returns:
      the value of the refreshedAfter record component