@Override
    public JsonWebKeySet rotate() {
        return whenKeystoreResourceExists()
            .map(Unchecked.function(resource -> {
                LOGGER.trace("Rotating keys found in [{}]", resource);
                val jsonWebKeySet = OidcJsonWebKeystoreGeneratorService.toJsonWebKeyStore(resource);

                jsonWebKeySet.getJsonWebKeys().forEach(key -> {
                    LOGGER.debug("Processing key [{}] to determine rotation eligibility", key.getKeyId());

                    val state = JsonWebKeyLifecycleStates.getJsonWebKeyState(key);
                    if (state == JsonWebKeyLifecycleStates.CURRENT) {
                        JsonWebKeyLifecycleStates.setJsonWebKeyState(key, JsonWebKeyLifecycleStates.PREVIOUS);
                        LOGGER.trace("Rotating state for current key [{}] to previous", key.getKeyId());
                    }
                    if (state == JsonWebKeyLifecycleStates.FUTURE) {
                        JsonWebKeyLifecycleStates.setJsonWebKeyState(key, JsonWebKeyLifecycleStates.CURRENT);
                        LOGGER.trace("Rotating state for future key [{}] to current", key.getKeyId());
                    }
                });
                generateFutureKeys(jsonWebKeySet);
                generateCurrentKeys(jsonWebKeySet);

                return generatorService.store(jsonWebKeySet);
            }))
            .orElse(null);
    }
This is {@link OidcDefaultJsonWebKeystoreRotationService}.

@author Misagh Moayyed
@since 6.5.0
support/cas-server-support-oidc-core-api/src/main/java/org/apereo/cas/oidc/jwks/rotation/OidcDefaultJsonWebKeystoreRotationService.java