use of io.cdap.cdap.proto.security.GrantRequest in project cdap by caskdata.
the class AuthorizationClient method grant.
@Override
public void grant(Authorizable authorizable, Principal principal, Set<? extends Permission> permissions) throws AccessException {
GrantRequest grantRequest = new GrantRequest(authorizable, principal, permissions);
URL url = resolveURL(AUTHORIZATION_BASE + "/privileges/grant");
HttpRequest request = HttpRequest.post(url).withBody(GSON.toJson(grantRequest)).build();
executePrivilegeRequest(request);
}
use of io.cdap.cdap.proto.security.GrantRequest in project cdap by caskdata.
the class AuthorizationHandler method grant.
@Path("/privileges/grant")
@POST
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void grant(FullHttpRequest httpRequest, HttpResponder httpResponder) throws BadRequestException, FeatureDisabledException, UnknownHostException, AccessException {
ensureSecurityEnabled();
GrantRequest request = parseBody(httpRequest, GrantRequest.class);
if (request == null) {
throw new BadRequestException("Missing request body");
}
permissionManager.grant(request.getAuthorizable(), request.getPrincipal(), getRequestPermissions(request));
httpResponder.sendStatus(HttpResponseStatus.OK);
createLogEntry(httpRequest, HttpResponseStatus.OK);
}
Aggregations