use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class ScopesResource method createOpenidScope.
@POST
@ProtectedApi(scopes = { ApiAccessConstants.SCOPES_WRITE_ACCESS })
public Response createOpenidScope(@Valid Scope scope) {
log.debug("SCOPE to be added - scope = " + scope);
log.debug("SCOPE to be added - scope.getId() = " + scope.getId());
checkNotNull(scope.getId(), AttributeNames.ID);
if (scope.getDisplayName() == null) {
scope.setDisplayName(scope.getId());
}
String inum = UUID.randomUUID().toString();
scope.setInum(inum);
scope.setDn(scopeService.getDnForScope(inum));
if (scope.getScopeType() == null) {
scope.setScopeType(ScopeType.OAUTH);
}
if (ScopeType.UMA.getValue().equalsIgnoreCase(scope.getScopeType().getValue())) {
scope.setScopeType(ScopeType.OAUTH);
}
scopeService.addScope(scope);
Scope result = scopeService.getScopeByInum(inum);
log.debug("SCOPE added is - " + result.getId());
return Response.status(Response.Status.CREATED).entity(result).build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class ScopesResource method updateScope.
@PUT
@ProtectedApi(scopes = { ApiAccessConstants.SCOPES_WRITE_ACCESS })
public Response updateScope(@Valid Scope scope) {
log.debug("SCOPE to be updated - scope = " + scope.getId());
String inum = scope.getInum();
checkNotNull(inum, SCOPE);
Scope existingScope = scopeService.getScopeByInum(inum);
checkResourceNotNull(existingScope, SCOPE);
if (scope.getScopeType() == null) {
scope.setScopeType(ScopeType.OAUTH);
}
if (ScopeType.UMA.getValue().equalsIgnoreCase(scope.getScopeType().getValue())) {
scope.setScopeType(ScopeType.OAUTH);
}
scope.setInum(existingScope.getInum());
scope.setBaseDn(scopeService.getDnForScope(inum));
scopeService.updateScope(scope);
Scope result = scopeService.getScopeByInum(inum);
log.debug("SCOPE updated is - " + result.getId());
return Response.ok(result).build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class ScopesResource method getScopeById.
@GET
@ProtectedApi(scopes = { ApiAccessConstants.SCOPES_READ_ACCESS })
@Path(ApiConstants.INUM_PATH)
public Response getScopeById(@NotNull @PathParam(ApiConstants.INUM) String inum) {
log.debug("SCOPES to be fetched - inum = " + inum);
Scope scope = scopeService.getScopeByInum(inum);
checkResourceNotNull(scope, SCOPE);
return Response.ok(scope).build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class CouchbaseConfigurationResource method test.
@POST
@Path(ApiConstants.TEST)
@ProtectedApi(scopes = { ApiAccessConstants.DATABASE_COUCHBASE_READ_ACCESS })
public Response test(@Valid @NotNull CouchbaseConnectionConfiguration conf) {
log.debug("COUCHBASE to be tested - conf = " + conf);
Properties properties = new Properties();
properties.put("couchbase.servers", Joiner.on(",").join(conf.getServers()));
properties.put("couchbase.auth.userName", conf.getUserName());
properties.put("couchbase.auth.userPassword", conf.getUserPassword());
properties.put("couchbase.auth.buckets", Joiner.on(",").join(conf.getBuckets()));
properties.put("couchbase.bucket.default", conf.getDefaultBucket());
properties.put("couchbase.password.encryption.method", conf.getPasswordEncryptionMethod());
CouchbaseConnectionProvider connectionProvider = new CouchbaseConnectionProvider(properties, DefaultCouchbaseEnvironment.create());
return Response.ok(connectionProvider.isConnected()).build();
}
use of io.jans.configapi.core.rest.ProtectedApi 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