@Override
    public JsonWebKeySet store(final JsonWebKeySet jsonWebKeySet) {
        val issuer = oidcProperties.getCore().getIssuer();
        val collectionName = oidcProperties.getJwks().getMongo().getCollection();
        val result = mongoTemplate.findById(issuer, OidcJsonWebKeystoreEntity.class, collectionName);
        val json = jsonWebKeySet.toJson(JsonWebKey.OutputControlLevel.INCLUDE_PRIVATE);
        Optional.ofNullable(result)
            .ifPresentOrElse(entity -> {
                val update = Update.update("data", json);
                val query = new Query(Criteria.where("issuer").is(entity.getIssuer()));
                mongoTemplate.updateFirst(query, update, collectionName);
            }, () -> {
                val entity = new OidcJsonWebKeystoreEntity(issuer, json);
                mongoTemplate.insert(entity, collectionName);
            });
        return jsonWebKeySet;
    }
This is {@link OidcMongoDbJsonWebKeystoreGeneratorService}.

@author Misagh Moayyed
@since 6.5.0
support/cas-server-support-oidc-mongo/src/main/java/org/apereo/cas/oidc/jwks/generator/mongo/OidcMongoDbJsonWebKeystoreGeneratorService.java