use of io.jans.orm.couchbase.model.CouchbaseConnectionConfiguration in project jans by JanssenProject.
the class CouchbaseConfService method getOrCreateIDPAuthConfs.
private List<IDPAuthConf> getOrCreateIDPAuthConfs(List<IDPAuthConf> existing, List<CouchbaseConnectionConfiguration> confs) {
if (existing == null) {
existing = Lists.newArrayList();
}
for (CouchbaseConnectionConfiguration conf : confs) {
Optional<IDPAuthConf> existingConf = existing.stream().filter(o -> o.getName() != null && o.getName().equals(conf.getConfigId())).findFirst();
final IDPAuthConf idpConf;
if (existingConf.isEmpty()) {
idpConf = new IDPAuthConf();
existing.add(idpConf);
} else {
idpConf = existingConf.get();
}
if (shouldEncryptPassword(conf)) {
try {
conf.setUserPassword(encryptionService.encrypt(conf.getUserPassword()));
} catch (StringEncrypter.EncryptionException e) {
throw new RuntimeException("Unable to decrypt password.", e);
}
}
idpConf.setType(AUTH);
idpConf.setVersion(idpConf.getVersion() + 1);
idpConf.setName(conf.getConfigId());
idpConf.setEnabled(true);
idpConf.setConfig(JacksonUtils.newMapper().valueToTree(conf));
}
return existing;
}
use of io.jans.orm.couchbase.model.CouchbaseConnectionConfiguration in project jans by JanssenProject.
the class CouchbaseConfigurationResource method patch.
@PATCH
@Path(ApiConstants.NAME_PARAM_PATH)
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
@ProtectedApi(scopes = { ApiAccessConstants.DATABASE_COUCHBASE_WRITE_ACCESS })
public Response patch(@PathParam(ApiConstants.NAME) String name, @NotNull String requestString) throws Exception {
log.debug("COUCHBASE to be patched - name = " + name + " , requestString = " + requestString);
CouchbaseConnectionConfiguration conf = findByName(name);
log.info("Patch configuration by name " + name);
conf = Jackson.applyPatch(requestString, conf);
couchbaseConfService.save(conf);
return Response.ok(conf).build();
}
Aggregations