public static PublicJsonWebKey generateJsonWebKey(final String jwksType, final int jwksKeySize,
                                                      final OidcJsonWebKeyUsage usage) {
        switch (jwksType.trim().toLowerCase(Locale.ENGLISH)) {
            case "ec" -> {
                if (jwksKeySize == JWK_EC_P384_SIZE) {
                    val jwk = generateJsonWebKeyEC(EllipticCurves.P384);
                    jwk.setKeyId(UUID.randomUUID().toString());
                    jwk.setAlgorithm(AlgorithmIdentifiers.ECDSA_USING_P384_CURVE_AND_SHA384);
                    usage.assignTo(jwk);
                    return jwk;
                }
                if (jwksKeySize == JWK_EC_P512_SIZE) {
                    val jwk = generateJsonWebKeyEC(EllipticCurves.P521);
                    jwk.setKeyId(UUID.randomUUID().toString());
                    jwk.setAlgorithm(AlgorithmIdentifiers.ECDSA_USING_P521_CURVE_AND_SHA512);
                    usage.assignTo(jwk);
                    return jwk;
                }
                val jwk = generateJsonWebKeyEC(EllipticCurves.P256);
                jwk.setKeyId(UUID.randomUUID().toString());
                jwk.setAlgorithm(AlgorithmIdentifiers.ECDSA_USING_P521_CURVE_AND_SHA512);
                usage.assignTo(jwk);
                return jwk;
            }
            default -> {
                val newJwk = FunctionUtils.doUnchecked(() -> RsaJwkGenerator.generateJwk(jwksKeySize));
                newJwk.setKeyId(UUID.randomUUID().toString());
                usage.assignTo(newJwk);
                return newJwk;
            }
        }
    }
Generate json web key.

@param jwksType    the jwks type
@param jwksKeySize the jwks key size
@param usage       the usage
@return the public json web key
support/cas-server-support-oidc-core-api/src/main/java/org/apereo/cas/oidc/jwks/OidcJsonWebKeyStoreUtils.java