use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class SqlConfigurationResource method test.
@POST
@Path(ApiConstants.TEST)
@ProtectedApi(scopes = { ApiAccessConstants.DATABASE_SQL_READ_ACCESS })
public Response test(@Valid @NotNull SqlConnectionConfiguration conf) {
log.debug("SQL to be tested - conf = " + conf);
Properties properties = new Properties();
properties.put("sql.db.schema.name", conf.getSchemaName());
properties.put("sql.connection.uri", Joiner.on(",").join(conf.getConnectionUri()));
properties.put("sql.connection.driver-property.serverTimezone", conf.getServerTimezone());
properties.put("sql.connection.pool.max-total", conf.getConnectionPoolMaxTotal());
properties.put("sql.connection.pool.max-idle", conf.getConnectionPoolMaxIdle());
properties.put("sql.auth.userName", conf.getUserName());
properties.put("sql.auth.userPassword", conf.getUserPassword());
// Password hash method
properties.put("sql.password.encryption.method", conf.getPasswordEncryptionMethod());
// Max time needed to create connection pool in milliseconds
properties.put("sql.connection.pool.create-max-wait-time-millis", conf.getCreateMaxWaitTimeMillis());
// Max wait 20 seconds
properties.put("sql.connection.pool.max-wait-time-millis", conf.getMaxWaitTimeMillis());
// Allow to evict connection in pool after 30 minutes
properties.put("sql.connection.pool.min-evictable-idle-time-millis", conf.getMinEvictableIdleTimeMillis());
properties.put("sql.binaryAttributes", Joiner.on(",").join(conf.getBinaryAttributes()));
properties.put("sql.certificateAttributes", Joiner.on(",").join(conf.getCertificateAttributes()));
SqlConnectionProvider connectionProvider = new SqlConnectionProvider(properties);
return Response.ok(connectionProvider.isConnected()).build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class StatResource method getStatistics.
@GET
@ProtectedApi(scopes = { ApiAccessConstants.STATS_USER_READ_ACCESS, ApiAccessConstants.JANS_STAT })
@Produces(MediaType.APPLICATION_JSON)
public Response getStatistics(@HeaderParam("Authorization") String authorization, @QueryParam(value = "month") String month, @QueryParam(value = "format") String format) {
if (StringUtils.isBlank(format)) {
format = "";
}
String url = getIssuer() + this.statUrl;
JsonNode jsonNode = this.authService.getStat(url, authorization, month, format);
logger.trace("StatResource::getUserStatistics() - jsonNode:{} ", jsonNode);
return Response.ok(jsonNode.get("response")).build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class UmaResourcesResource method deleteUmaResource.
@DELETE
@Path(ApiConstants.ID_PATH)
@ProtectedApi(scopes = { ApiAccessConstants.UMA_RESOURCES_DELETE_ACCESS })
public Response deleteUmaResource(@PathParam(value = ApiConstants.ID) @NotNull String id) {
log.debug("UMA_RESOURCE to delete - id = " + id);
UmaResource umaResource = findOrThrow(id);
umaResourceService.remove(umaResource);
return Response.status(Response.Status.NO_CONTENT).build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class UmaResourcesResource method updateUmaResource.
@PUT
@ProtectedApi(scopes = { ApiAccessConstants.UMA_RESOURCES_WRITE_ACCESS })
public Response updateUmaResource(@Valid UmaResource resource) {
log.debug("UMA_RESOURCE to be upated - umaResource = " + resource);
String id = resource.getId();
checkNotNull(id, AttributeNames.ID);
UmaResource existingResource = findOrThrow(id);
resource.setId(existingResource.getId());
resource.setDn(umaResourceService.getDnForResource(id));
umaResourceService.updateResource(resource);
return Response.ok(resource).build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class AttributesResource method deleteAttribute.
@DELETE
@Path(ApiConstants.INUM_PATH)
@ProtectedApi(scopes = { ApiAccessConstants.ATTRIBUTES_DELETE_ACCESS })
public Response deleteAttribute(@PathParam(ApiConstants.INUM) @NotNull String inum) {
log.debug(" GluuAttribute details to delete - inum = " + inum);
GluuAttribute attribute = attributeService.getAttributeByInum(inum);
checkResourceNotNull(attribute, GLUU_ATTRIBUTE);
attributeService.removeAttribute(attribute);
return Response.noContent().build();
}
Aggregations