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 ServerIdentityGenerate a brand-new server identity that is not storedidentityValue(String answerSdp) Generate the identity value as base64 for this answer SDP
-
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
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
-
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
-