Class OidcKeyProvider

java.lang.Object
org.mockserver.oidc.OidcKeyProvider

public class OidcKeyProvider extends Object
Resolves the AsymmetricKeyPair that an OIDC provider signs tokens with and publishes via its JWKS endpoint.

Resolution order:

  1. If jwkJson is supplied — parse the JWK (which carries both key material and, when present, its kid and algorithm).
  2. If privateKeyPem is supplied — parse the private key; derive the public key from certificatePem when present, otherwise from the RSA private key's CRT parameters.
  3. Otherwise — generate a fresh key pair for signingAlgorithm.

Whatever the source, the resulting key pair's algorithm matches the configured signingAlgorithm so the same key both signs tokens and is published in the JWKS — keeping the sign/publish invariant intact. A supplied keyId (or the JWK's own kid) gives a stable kid across restarts so JWKS-caching clients keep working; otherwise a random kid is generated.