private static JsonWebKeySet getJsonWebKeyByKeyId(final JsonWebKeySet jwks,
                                                      final Optional<String> kid,
                                                      final Optional<OidcJsonWebKeyUsage> usage) {
        if (kid.isPresent()) {
            var resultJwks = filterJsonWebKeySetKeysBy(jwks, kid, usage);
            if (usage.isPresent() && resultJwks.isEmpty()) {
                LOGGER.debug("No JSON web keys found for [{}] and usage [{}]. Skipping usage...", kid.get(), usage.get());
                resultJwks = filterJsonWebKeySetKeysBy(jwks, kid, Optional.empty());
            }
            LOGGER.debug("JSON web keys found for [{}] are [{}]", kid.get(), resultJwks);
            return new JsonWebKeySet(resultJwks);
        }
        var resultJwks = filterJsonWebKeySetKeysBy(jwks, Optional.empty(), usage);
        if (usage.isPresent() && resultJwks.isEmpty()) {
            LOGGER.debug("No JSON web keys found for usage [{}]. Skipping usage...", usage.get());
            resultJwks = filterJsonWebKeySetKeysBy(jwks, Optional.empty(), Optional.empty());
        }
        LOGGER.debug("JSON web keys found are [{}]", resultJwks);
        return new JsonWebKeySet(resultJwks);
    }
Gets json web key from jwks.

@param jwks         the jwks
@param requestedKey the kid
@param usage        the usage
@return the json web key from jwks
support/cas-server-support-oidc-core-api/src/main/java/org/apereo/cas/oidc/jwks/OidcJsonWebKeyStoreUtils.java