Class ServerIdentity
java.lang.Object
org.cloudburstmc.netty.util.nethernet.ServerIdentity
Produces the server-side identity assertion for each SDP answer
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionServerIdentity(PrivateKey privateKey, PublicKey publicKey, Instant expiry, String domain) -
Method Summary
Modifier and TypeMethodDescriptionaugmentAnswer(String answerSdp) Insert the identity into the answer SDP The specific placement is a strange requirement for the spec but we will follow itstatic ServerIdentityLoads the keypair from an unencrypted PEM private key, either SEC1EC PRIVATE KEYor PKCS#8PRIVATE KEY.static ServerIdentityfromPemOrCreate(File pem, String domain) Loads the identity from a PEM private key, creating a new P-384 key there on first use.static ServerIdentityfromPkcs12(File keystore, String password) Loads the keypair from the first key entry of a PKCS12 keystore.static ServerIdentityfromPkcs12(File keystore, String password, @Nullable String domain) Loads the keypair from the first key entry of a PKCS12 keystore, naming the identitydomainrather than the certificate's common name.static ServerIdentityGenerate a brand-new server identity that is not storedidentityValue(String answerSdp) Generate the identity value as base64 for this answer SDPkeyPair()The keypair this identity signs with, for callers that also have to sign as a client.
-
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
-
fromPkcs12
public static ServerIdentity fromPkcs12(File keystore, String password) throws GeneralSecurityException, IOException, org.jose4j.lang.JoseException Loads the keypair from the first key entry of a PKCS12 keystore.- Parameters:
keystore- The PKCS12 keystore file, commonly named .p12 or .pfxpassword- The keystore password- Returns:
- The loaded ServerIdentity
- Throws:
GeneralSecurityException- If there is a security errorIOException- If there is an I/O errororg.jose4j.lang.JoseException- If there is an error creating the JWT
-
fromPkcs12
public static ServerIdentity fromPkcs12(File keystore, String password, @Nullable String domain) throws GeneralSecurityException, IOException, org.jose4j.lang.JoseException Loads the keypair from the first key entry of a PKCS12 keystore, naming the identitydomainrather than the certificate's common name.The domain is only display text; clients pin the public key, so it can be changed without replacing the key and re-prompting anyone.
- Parameters:
keystore- The PKCS12 keystore filepassword- The keystore passworddomain- The identity domain, or null to take the certificate's common name- Returns:
- The loaded ServerIdentity
- Throws:
GeneralSecurityException- If there is a security errorIOException- If there is an I/O errororg.jose4j.lang.JoseException- If there is an error creating the JWT
-
generate
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 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 ServerIdentity
- 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 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 createdomain- The identity domain, as a PEM carries no subject- Returns:
- The loaded ServerIdentity
- 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
-
keyPair
The keypair this identity signs with, for callers that also have to sign as a client.- Returns:
- The keypair
-
identityValue
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
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
-