Class OperatorIdentity
java.lang.Object
org.cloudburstmc.netty.util.nethernet.OperatorIdentity
The key an operator signs NetherNet identity assertions with, and the name players see it under.
A server presents it in every answer. A client presents it in its offer, derived for the player
it connects on behalf of with forPlayer(java.lang.String, java.lang.String), which is what a proxy does toward a downstream
server.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOperatorIdentity(PrivateKey privateKey, PublicKey publicKey, Instant expiry, String domain) -
Method Summary
Modifier and TypeMethodDescriptionThis identity acting for a player, for the offer a client sends on their behalf.static OperatorIdentityLoads the keypair from an unencrypted PEM private key, either SEC1EC PRIVATE KEYor PKCS#8PRIVATE KEY.static OperatorIdentityfromPemOrCreate(File pem, String domain) Loads the identity from a PEM private key, creating a new P-384 key there on first use.static OperatorIdentityAn identity whose token an auth service issued for the key, as a retail client's multiplayer token is: what a client presents to a server that validates against Minecraft's auth service rather than trusting the peer's own signature.static OperatorIdentityGenerate a brand-new server identity that is not storedThe key players pin this operator by, for fingerprints and fleet checks.withAssertion(String sdp) Inserts this identity's assertion into a description, offer or answer.
-
Constructor Details
-
OperatorIdentity
public OperatorIdentity(PrivateKey privateKey, PublicKey publicKey, Instant expiry, String domain) throws org.jose4j.lang.JoseException - Throws:
org.jose4j.lang.JoseException
-
-
Method Details
-
fromToken
An identity whose token an auth service issued for the key, as a retail client's multiplayer token is: what a client presents to a server that validates against Minecraft's auth service rather than trusting the peer's own signature. The key has to be the one the token'scpkclaim names, or the fingerprint signature will not verify.- Parameters:
keyPair- The key the token was issued fortoken- The compact JWT the auth service issued, carryingcpk,xidandxnamedomain- The identity provider named in the assertion- Returns:
- An identity presenting that token
-
generate
Generate a brand-new server identity that is not stored- Parameters:
domain- The domain name for the server identity- Returns:
- A new OperatorIdentity instance
- Throws:
org.jose4j.lang.JoseException- If there is an error creating the JWT
-
fromPem
public static OperatorIdentity fromPem(File pem, String domain) throws GeneralSecurityException, IOException, org.jose4j.lang.JoseException Loads the keypair from an unencrypted PEM private key, either SEC1EC PRIVATE KEYor PKCS#8PRIVATE KEY. The key must carry its public point, which OpenSSL includes by default and the standard library cannot recover from the scalar. A PEM has no expiry, so the token is issued without one.- Parameters:
pem- The PEM filedomain- The domain name for the server identity, as a PEM carries no subject- Returns:
- The loaded OperatorIdentity
- Throws:
GeneralSecurityException- If the key is malformed or not on P-384IOException- If there is an I/O errororg.jose4j.lang.JoseException- If there is an error creating the JWT
-
fromPemOrCreate
public static OperatorIdentity fromPemOrCreate(File pem, String domain) throws GeneralSecurityException, IOException, org.jose4j.lang.JoseException Loads the identity from a PEM private key, creating a new P-384 key there on first use.The file is created readable only by its owner and is never replaced once it exists, because clients pin the public key and a new one prompts every returning player again.
- Parameters:
pem- The PEM file to load or createdomain- The identity domain, as a PEM carries no subject- Returns:
- The loaded OperatorIdentity
- Throws:
GeneralSecurityException- If the key is malformed or not on P-384IOException- If there is an I/O errororg.jose4j.lang.JoseException- If there is an error creating the JWT
-
publicKey
The key players pin this operator by, for fingerprints and fleet checks.- Returns:
- The public key
-
forPlayer
This identity acting for a player, for the offer a client sends on their behalf. The token names the player and expires, so derive one per connection rather than keeping it.- Parameters:
xuid- The player's XUID, which the server reads asxidname- The player's name, read asxname- Returns:
- An identity with the same key and domain whose token carries the player
- Throws:
org.jose4j.lang.JoseException- If there is an error signing the token
-
withAssertion
Inserts this identity's assertion into a description, offer or answer. The description has to be finished, because a peer checks the signature against exactly the fingerprints it receives, and the attribute goes ahead of the first media line as the spec requires.- Parameters:
sdp- The description without an identity line- Returns:
- The description with the identity inserted
- Throws:
org.jose4j.lang.JoseException- If there is an error signing
-