Class ServerIdentity

java.lang.Object
org.cloudburstmc.netty.util.nethernet.ServerIdentity

public class ServerIdentity extends Object
Produces the server-side identity assertion for each SDP answer
See Also:
  • Constructor Details

    • ServerIdentity

      public ServerIdentity(PrivateKey privateKey, PublicKey publicKey, Instant expiry, String domain) throws org.jose4j.lang.JoseException
      Throws:
      org.jose4j.lang.JoseException
  • Method Details

    • generate

      public static ServerIdentity generate(String domain) throws org.jose4j.lang.JoseException
      Generate a brand-new server identity that is not stored
      Parameters:
      domain - The domain name for the server identity
      Returns:
      A new ServerIdentity instance
      Throws:
      org.jose4j.lang.JoseException - If there is an error creating the JWT
    • fromPem

      public static ServerIdentity fromPem(File pem, String domain) throws GeneralSecurityException, IOException, org.jose4j.lang.JoseException
      Loads the keypair from an unencrypted PEM private key, either SEC1 EC PRIVATE KEY or PKCS#8 PRIVATE 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 file
      domain - The domain name for the server identity, as a PEM carries no subject
      Returns:
      The loaded ServerIdentity
      Throws:
      GeneralSecurityException - If the key is malformed or not on P-384
      IOException - If there is an I/O error
      org.jose4j.lang.JoseException - If there is an error creating the JWT
    • fromPemOrCreate

      public static ServerIdentity 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 create
      domain - The identity domain, as a PEM carries no subject
      Returns:
      The loaded ServerIdentity
      Throws:
      GeneralSecurityException - If the key is malformed or not on P-384
      IOException - If there is an I/O error
      org.jose4j.lang.JoseException - If there is an error creating the JWT
    • identityValue

      public String identityValue(String answerSdp) throws org.jose4j.lang.JoseException
      Generate the identity value as base64 for this answer SDP
      Parameters:
      answerSdp - The SDP to generate the identity value for
      Returns:
      The base64 identity value
      Throws:
      org.jose4j.lang.JoseException - If there is an error signing the identity value
    • augmentAnswer

      public String augmentAnswer(String answerSdp) throws org.jose4j.lang.JoseException
      Insert the identity into the answer SDP The specific placement is a strange requirement for the spec but we will follow it
      Parameters:
      answerSdp - The SDP to insert the identity into
      Returns:
      The SDP with the identity inserted
      Throws:
      org.jose4j.lang.JoseException - If there is an error signing the identity value