Interface TokenTrust

All Known Implementing Classes:
TokenTrust.Pinned
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface TokenTrust
Decides whether the token in an offer's identity assertion is trusted.

This is only the first half of validating an offer. Whichever policy is chosen, the assertion's detached JWS over the SDP fingerprints is still verified against the token's cpk, which is what ties the identity to the DTLS certificate the peer presents.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    Accepts a token signed by, and naming, one of a fixed set of keys.
    static final class 
    Holder so the shared consumer is built once.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final TokenTrust
    Reads the claims without checking who signed the token, for peers that cannot present a Minecraft-issued one, such as another proxy in the same fleet.
    static final TokenTrust
    Verifies the token against Minecraft's authorization service, which is what a retail client presents.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.jose4j.jwt.JwtClaims
    claims(Identity identity)
     
    static TokenTrust
    Trusts only a token signed by one of keys that also names that key as its cpk.
    default void
    Does whatever makes the first claims(org.cloudburstmc.netty.util.nethernet.Identity) call fast, such as fetching keys.
  • Field Details

    • MINECRAFT_AUTH

      static final TokenTrust MINECRAFT_AUTH
      Verifies the token against Minecraft's authorization service, which is what a retail client presents. This is the default.
    • ANY

      static final TokenTrust ANY
      Reads the claims without checking who signed the token, for peers that cannot present a Minecraft-issued one, such as another proxy in the same fleet.

      The cpk binding still applies, so the peer must hold the key its token names, and the token must carry an expiry and be within it. Neither bounds what the token says: the peer signs its own, so xid, xname and the expiry itself are whatever it chose. Nothing here establishes who the peer is, so pair it with an identity check of your own.

  • Method Details

    • pinnedTo

      static TokenTrust pinnedTo(PublicKey... keys)
      Trusts only a token signed by one of keys that also names that key as its cpk. This is how a client confirms a server it knows: pin the public key of the identity the server answers with. A server's own token carries no expiry and none is required here, the key is the anchor; an expiry that is present still has to be current.
      Parameters:
      keys - The public keys to accept, more than one across a rotation
      Returns:
      The trust
    • claims

      org.jose4j.jwt.JwtClaims claims(Identity identity) throws Exception
      Parameters:
      identity - The identity taken from the offer
      Returns:
      The token's claims, which must include cpk
      Throws:
      Exception - If the token is not trusted
    • prepare

      default void prepare()
      Does whatever makes the first claims(org.cloudburstmc.netty.util.nethernet.Identity) call fast, such as fetching keys. Called once when signaling binds, off the event loop, and expected to swallow its own failures.