use of io.jans.as.model.config.Conf in project jans by JanssenProject.
the class JwksResource method deleteKey.
@DELETE
@ProtectedApi(scopes = { ApiAccessConstants.JWKS_WRITE_ACCESS })
@Path(ApiConstants.KID_PATH)
public Response deleteKey(@PathParam(ApiConstants.KID) @NotNull String kid) {
log.debug("Key to be to be deleted - kid = " + kid);
final Conf conf = configurationService.findConf();
WebKeysConfiguration webkeys = configurationService.findConf().getWebKeys();
JSONWebKey jwk = getJSONWebKey(webkeys, kid);
if (jwk == null) {
throw new NotFoundException(getNotFoundError("JWK with kid - '" + kid + "' does not exist!"));
}
conf.getWebKeys().getKeys().removeIf(x -> x.getKid() != null && x.getKid().equals(kid));
configurationService.merge(conf);
return Response.noContent().build();
}
use of io.jans.as.model.config.Conf in project jans by JanssenProject.
the class JwksResource method put.
@PUT
@ProtectedApi(scopes = { ApiAccessConstants.JWKS_WRITE_ACCESS })
public Response put(WebKeysConfiguration webkeys) {
log.debug("JWKS details to be updated - webkeys = " + webkeys);
final Conf conf = configurationService.findConf();
conf.setWebKeys(webkeys);
configurationService.merge(conf);
final String json = configurationService.findConf().getWebKeys().toString();
return Response.ok(json).build();
}
use of io.jans.as.model.config.Conf in project jans by JanssenProject.
the class ConfigurationFactory method isRevisionIncreased.
private boolean isRevisionIncreased() {
final Conf persistenceConf = loadConfigurationFromPersistence("jansRevision");
if (persistenceConf == null) {
return false;
}
log.trace("LDAP revision: {}, server revision: {}", persistenceConf.getRevision(), loadedRevision);
return persistenceConf.getRevision() > this.loadedRevision;
}
use of io.jans.as.model.config.Conf in project jans by JanssenProject.
the class ConfigurationFactory method createFromLdap.
private boolean createFromLdap(boolean recoverFromFiles) {
log.info("Loading configuration from '{}' DB...", baseConfiguration.getString("persistence.type"));
try {
final io.jans.as.model.config.Conf c = loadConfigurationFromPersistence();
if (c != null) {
init(c);
// Destroy old configuration
if (this.loaded) {
destroy(AppConfiguration.class);
destroy(io.jans.as.model.config.StaticConfiguration.class);
destroy(io.jans.as.model.config.WebKeysConfiguration.class);
destroy(ErrorResponseFactory.class);
}
this.loaded = true;
configurationUpdateEvent.select(ConfigurationUpdate.Literal.INSTANCE).fire(conf);
destroyCryptoProviderInstance();
AbstractCryptoProvider newAbstractCryptoProvider = abstractCryptoProviderInstance.get();
cryptoProviderEvent.select(CryptoProviderEvent.Literal.INSTANCE).fire(newAbstractCryptoProvider);
return true;
}
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
}
if (recoverFromFiles) {
log.info("Unable to find configuration in LDAP, try to load configuration from file system... ");
if (createFromFile()) {
this.loadedFromLdap = false;
return true;
}
}
return false;
}
use of io.jans.as.model.config.Conf in project jans by JanssenProject.
the class KeyGeneratorTimer method updateKeysImpl.
private void updateKeysImpl() throws Exception {
log.info("Updating JWKS keys ...");
String dn = configurationFactory.getBaseConfiguration().getString(Constants.SERVER_KEY_OF_CONFIGURATION_ENTRY);
Conf conf = ldapEntryManager.find(Conf.class, dn);
JSONObject jwks = conf.getWebKeys().toJSONObject();
JSONObject updatedJwks = updateKeys(jwks);
conf.setWebKeys(ServerUtil.createJsonMapper().readValue(updatedJwks.toString(), WebKeysConfiguration.class));
long nextRevision = conf.getRevision() + 1;
conf.setRevision(nextRevision);
ldapEntryManager.merge(conf);
log.info("Updated JWKS successfully");
log.trace("JWKS keys: " + conf.getWebKeys().getKeys().stream().map(JSONWebKey::getKid).collect(Collectors.toList()));
log.trace("KeyStore keys: " + cryptoProvider.getKeys());
}
Aggregations