Class IdentityUtils

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

public class IdentityUtils extends Object
  • 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

      public static String encodePublicKey(PublicKey key)
      Parameters:
      key - An EC public key
      Returns:
      The key as a token's cpk claim carries it, base64 of its X.509 encoding
    • decodePublicKey

      public static PublicKey decodePublicKey(String encoded) throws GeneralSecurityException
      Parameters:
      encoded - A key as encodePublicKey(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 offer
      org.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 as trust decides. The fingerprint binding is checked either way.
      Parameters:
      sdpOffer - The SDP offer to validate
      trust - 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 offer
      org.jose4j.jwt.consumer.InvalidJwtException - If the SDP offer contains an invalid JWT
    • getCanonicalFingerprintJson

      public static String getCanonicalFingerprintJson(String sdpOffer)
      Get the canonical fingerprint JSON from the SDP offer
      Parameters:
      sdpOffer - The SDP offer to extract fingerprints from
      Returns:
      The canonical fingerprint JSON