Record Class PlayerCertificate
java.lang.Object
java.lang.Record
lol.trq.alts.account.PlayerCertificate
- Record Components:
privateKeyPem- the PEM-encoded RSA private keypublicKeyPem- the PEM-encoded RSA public keypublicKeySignatureV2- the service's Base64 signature over the public key, in the current schemepublicKeySignature- the signature in the older scheme, which the services have deprecated; may benullexpiresAt- when the pair stops being valid, ornullwhen the service did not sayrefreshedAfter- when the service suggests fetching a new pair, ahead of the expiry; may benull
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.booleanReturns whether the pair is no longer valid at the given instant.Returns the value of theexpiresAtrecord component.final inthashCode()Returns a hash code value for this object.Decodes the private key.Returns the value of theprivateKeyPemrecord component.Decodes the public key.Returns the value of thepublicKeyPemrecord component.Returns the value of thepublicKeySignaturerecord component.Returns the value of thepublicKeySignatureV2record component.Returns the value of therefreshedAfterrecord component.booleanshouldRefresh(Instant now) Returns whether a new pair should be fetched: the service's suggested refresh time has passed, or the pair has expired.toString()Returns a description with the private key redacted.
-
Constructor Details
-
PlayerCertificate
public PlayerCertificate(String privateKeyPem, String publicKeyPem, String publicKeySignatureV2, String publicKeySignature, Instant expiresAt, Instant refreshedAfter) Creates an instance of aPlayerCertificaterecord class.- Parameters:
privateKeyPem- the value for theprivateKeyPemrecord componentpublicKeyPem- the value for thepublicKeyPemrecord componentpublicKeySignatureV2- the value for thepublicKeySignatureV2record componentpublicKeySignature- the value for thepublicKeySignaturerecord componentexpiresAt- the value for theexpiresAtrecord componentrefreshedAfter- the value for therefreshedAfterrecord component
-
-
Method Details
-
privateKey
Decodes the private key.- Returns:
- the RSA private key
- Throws:
AltsException- of kindINVALID_INPUTif the PEM is absent or its body is not Base64, or of kindCRYPTOif what it decodes to is not a PKCS#8 RSA key; the message never quotes the key- Since:
- 0.12.0
-
publicKey
Decodes the public key.- Returns:
- the RSA public key
- Throws:
AltsException- of kindINVALID_INPUTif the PEM is absent or its body is not Base64, or of kindCRYPTOif what it decodes to is not an X.509 RSA key- Since:
- 0.12.0
-
expired
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
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
-
hashCode
-
equals
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 withObjects::equals(Object,Object). -
privateKeyPem
Returns the value of theprivateKeyPemrecord component.- Returns:
- the value of the
privateKeyPemrecord component
-
publicKeyPem
Returns the value of thepublicKeyPemrecord component.- Returns:
- the value of the
publicKeyPemrecord component
-
publicKeySignatureV2
Returns the value of thepublicKeySignatureV2record component.- Returns:
- the value of the
publicKeySignatureV2record component
-
publicKeySignature
Returns the value of thepublicKeySignaturerecord component.- Returns:
- the value of the
publicKeySignaturerecord component
-
expiresAt
-
refreshedAfter
Returns the value of therefreshedAfterrecord component.- Returns:
- the value of the
refreshedAfterrecord component
-