Class IdentityUtils
java.lang.Object
org.cloudburstmc.netty.util.nethernet.IdentityUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PublicKeydecodePublicKey(String encoded) static StringencodePublicKey(PublicKey key) static StringgetCanonicalFingerprintJson(String sdpOffer) Get the canonical fingerprint JSON from the SDP offerstatic voidFetches the auth service's keys ahead of the first join, so that join does not pay for the round trip.static org.jose4j.jwt.consumer.JwtContextvalidateIdentity(Identity identity) static org.jose4j.jwt.JwtClaimsvalidateSdp(String sdpOffer) Validate the SDP offer against the embedded identity and known jwt signer This is designed into the spec to prevent MITMstatic org.jose4j.jwt.JwtClaimsvalidateSdp(String sdpOffer, TokenTrust trust) Validate the SDP offer against the embedded identity, trusting its token astrustdecides.
-
Constructor Details
-
IdentityUtils
public IdentityUtils()
-
-
Method Details
-
prefetchKeys
public static void prefetchKeys()Fetches the auth service's keys ahead of the first join, so that join does not pay for the round trip. A failure is only logged: the first join fetches them again. -
encodePublicKey
- Parameters:
key- An EC public key- Returns:
- The key as a token's
cpkclaim carries it, base64 of its X.509 encoding
-
decodePublicKey
- Parameters:
encoded- A key asencodePublicKey(java.security.PublicKey)writes it- Returns:
- The key
- Throws:
GeneralSecurityException- If the bytes are not an EC public key
-
validateIdentity
public static org.jose4j.jwt.consumer.JwtContext validateIdentity(Identity identity) throws org.jose4j.jwt.consumer.InvalidJwtException - Throws:
org.jose4j.jwt.consumer.InvalidJwtException
-
validateSdp
public static org.jose4j.jwt.JwtClaims validateSdp(String sdpOffer) throws org.jose4j.lang.JoseException, org.jose4j.jwt.consumer.InvalidJwtException Validate the SDP offer against the embedded identity and known jwt signer This is designed into the spec to prevent MITM- Parameters:
sdpOffer- The SDP offer to validate- Returns:
- The JWT claims if the SDP offer is valid
- Throws:
org.jose4j.lang.JoseException- If there is an error processing the SDP offerorg.jose4j.jwt.consumer.InvalidJwtException- If the SDP offer contains an invalid JWT
-
validateSdp
public static org.jose4j.jwt.JwtClaims validateSdp(String sdpOffer, TokenTrust trust) throws org.jose4j.lang.JoseException, org.jose4j.jwt.consumer.InvalidJwtException Validate the SDP offer against the embedded identity, trusting its token astrustdecides. The fingerprint binding is checked either way.- Parameters:
sdpOffer- The SDP offer to validatetrust- Who to trust to have signed the token- Returns:
- The JWT claims if the SDP offer is valid
- Throws:
org.jose4j.lang.JoseException- If there is an error processing the SDP offerorg.jose4j.jwt.consumer.InvalidJwtException- If the SDP offer contains an invalid JWT
-
getCanonicalFingerprintJson
Get the canonical fingerprint JSON from the SDP offer- Parameters:
sdpOffer- The SDP offer to extract fingerprints from- Returns:
- The canonical fingerprint JSON
-