use of io.pravega.shared.controller.tracing.RPCTracingTags.LIST_SCOPES in project pravega by pravega.
the class ControllerServiceImpl method listScopes.
@Override
public void listScopes(Controller.ScopesRequest request, StreamObserver<Controller.ScopesResponse> responseObserver) {
RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), LIST_SCOPES);
log.info(requestTag.getRequestId(), "listScope called.");
final AuthContext ctx;
if (this.grpcAuthHelper.isAuthEnabled()) {
ctx = AuthContext.current();
} else {
ctx = null;
}
Supplier<String> stringSupplier = () -> {
String result = this.grpcAuthHelper.checkAuthorization(authorizationResource.ofScopes(), AuthHandler.Permissions.READ, ctx);
log.debug("Result of authorization for [{}] and READ permission is: [{}]", authorizationResource.ofScopes(), result);
return result;
};
Function<String, CompletableFuture<Controller.ScopesResponse>> scopesFn = delegationToken -> listWithFilter(request.getContinuationToken().getToken(), pageLimit, (x, y) -> controllerService.listScopes(x, y, requestTag.getRequestId()), x -> grpcAuthHelper.isAuthorized(authorizationResource.ofScope(x), AuthHandler.Permissions.READ, ctx), x -> x, requestTag.getRequestId()).thenApply(response -> Controller.ScopesResponse.newBuilder().addAllScopes(response.getKey()).setContinuationToken(Controller.ContinuationToken.newBuilder().setToken(response.getValue()).build()).build());
authenticateExecuteAndProcessResults(stringSupplier, scopesFn, responseObserver, requestTag);
}
Aggregations