use of io.trino.server.security.ResourceSecurity in project trino by trinodb.
the class ThreadResource method getThreadInfo.
@ResourceSecurity(MANAGEMENT_READ)
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Info> getThreadInfo() {
ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
List<Info> threads = Arrays.stream(mbean.getThreadInfo(mbean.getAllThreadIds(), Integer.MAX_VALUE)).filter(Objects::nonNull).map(ThreadResource::toInfo).collect(Collectors.toUnmodifiableList());
return Ordering.from(byName()).sortedCopy(threads);
}
use of io.trino.server.security.ResourceSecurity in project trino by trinodb.
the class QueryResource method getAllQueryInfo.
@ResourceSecurity(AUTHENTICATED_USER)
@GET
public List<BasicQueryInfo> getAllQueryInfo(@QueryParam("state") String stateFilter, @Context HttpServletRequest servletRequest, @Context HttpHeaders httpHeaders) {
QueryState expectedState = stateFilter == null ? null : QueryState.valueOf(stateFilter.toUpperCase(Locale.ENGLISH));
List<BasicQueryInfo> queries = dispatchManager.getQueries();
queries = filterQueries(sessionContextFactory.extractAuthorizedIdentity(servletRequest, httpHeaders, alternateHeaderName), queries, accessControl);
ImmutableList.Builder<BasicQueryInfo> builder = ImmutableList.builder();
for (BasicQueryInfo queryInfo : queries) {
if (stateFilter == null || queryInfo.getState() == expectedState) {
builder.add(queryInfo);
}
}
return builder.build();
}
use of io.trino.server.security.ResourceSecurity in project trino by trinodb.
the class QueryResource method getQueryInfo.
@ResourceSecurity(AUTHENTICATED_USER)
@GET
@Path("{queryId}")
public Response getQueryInfo(@PathParam("queryId") QueryId queryId, @Context HttpServletRequest servletRequest, @Context HttpHeaders httpHeaders) {
requireNonNull(queryId, "queryId is null");
Optional<QueryInfo> queryInfo = dispatchManager.getFullQueryInfo(queryId);
if (queryInfo.isEmpty()) {
return Response.status(Status.GONE).build();
}
try {
checkCanViewQueryOwnedBy(sessionContextFactory.extractAuthorizedIdentity(servletRequest, httpHeaders, alternateHeaderName), queryInfo.get().getSession().toIdentity(), accessControl);
return Response.ok(queryInfo.get()).build();
} catch (AccessDeniedException e) {
throw new ForbiddenException();
}
}
use of io.trino.server.security.ResourceSecurity in project trino by trinodb.
the class QueryStateInfoResource method getQueryStateInfo.
@ResourceSecurity(AUTHENTICATED_USER)
@GET
@Path("{queryId}")
@Produces(MediaType.APPLICATION_JSON)
public QueryStateInfo getQueryStateInfo(@PathParam("queryId") String queryId, @Context HttpServletRequest servletRequest, @Context HttpHeaders httpHeaders) throws WebApplicationException {
try {
BasicQueryInfo queryInfo = dispatchManager.getQueryInfo(new QueryId(queryId));
checkCanViewQueryOwnedBy(sessionContextFactory.extractAuthorizedIdentity(servletRequest, httpHeaders, alternateHeaderName), queryInfo.getSession().toIdentity(), accessControl);
return getQueryStateInfo(queryInfo);
} catch (AccessDeniedException e) {
throw new ForbiddenException();
} catch (NoSuchElementException e) {
throw new WebApplicationException(NOT_FOUND);
}
}
use of io.trino.server.security.ResourceSecurity in project trino by trinodb.
the class QueryResource method cancelQuery.
@ResourceSecurity(AUTHENTICATED_USER)
@DELETE
@Path("{queryId}")
public void cancelQuery(@PathParam("queryId") QueryId queryId, @Context HttpServletRequest servletRequest, @Context HttpHeaders httpHeaders) {
requireNonNull(queryId, "queryId is null");
try {
BasicQueryInfo queryInfo = dispatchManager.getQueryInfo(queryId);
checkCanKillQueryOwnedBy(sessionContextFactory.extractAuthorizedIdentity(servletRequest, httpHeaders, alternateHeaderName), queryInfo.getSession().toIdentity(), accessControl);
dispatchManager.cancelQuery(queryId);
} catch (AccessDeniedException e) {
throw new ForbiddenException();
} catch (NoSuchElementException ignored) {
}
}
Aggregations