use of org.apereo.cas.oidc.jwks.generator.OidcJsonWebKeystoreEntity in project cas by apereo.
the class OidcJpaJsonWebKeystoreGeneratorService method store.
@Override
public JsonWebKeySet store(final JsonWebKeySet jsonWebKeySet) throws Exception {
val issuer = oidcProperties.getCore().getIssuer();
return transactionTemplate.execute(status -> {
val result = jsonWebKeySet.toJson(JsonWebKey.OutputControlLevel.INCLUDE_PRIVATE);
Optional.ofNullable(entityManager.find(OidcJsonWebKeystoreEntity.class, issuer)).ifPresentOrElse(entity -> {
entity.setData(result);
entityManager.merge(entity);
}, () -> {
val entity = new OidcJsonWebKeystoreEntity(issuer, result);
entityManager.persist(entity);
});
return jsonWebKeySet;
});
}
use of org.apereo.cas.oidc.jwks.generator.OidcJsonWebKeystoreEntity in project cas by apereo.
the class OidcMongoDbJsonWebKeystoreGeneratorService method store.
@Override
public JsonWebKeySet store(final JsonWebKeySet jsonWebKeySet) throws Exception {
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;
}
Aggregations