use of io.cdap.cdap.common.internal.remote.MethodArgument in project cdap by caskdata.
the class RemotePrivilegesHandler method listPrivileges.
@POST
@Path("/listPrivileges")
public void listPrivileges(FullHttpRequest request, HttpResponder responder) throws Exception {
Iterator<MethodArgument> arguments = parseArguments(request);
Principal principal = deserializeNext(arguments);
LOG.trace("Listing grantedPermissions for principal {}", principal);
Set<GrantedPermission> grantedPermissions = permissionManager.listGrants(principal);
LOG.debug("Returning grantedPermissions for principal {} as {}", principal, grantedPermissions);
responder.sendJson(HttpResponseStatus.OK, GSON.toJson(grantedPermissions));
}
use of io.cdap.cdap.common.internal.remote.MethodArgument in project cdap by caskdata.
the class AbstractRemoteSystemOpsHandler method deserializeNext.
@Nullable
<T> T deserializeNext(Iterator<MethodArgument> arguments, @Nullable Type typeOfT) throws ClassNotFoundException, BadRequestException {
if (!arguments.hasNext()) {
throw new BadRequestException("Expected additional elements.");
}
MethodArgument argument = arguments.next();
if (argument == null) {
return null;
}
JsonElement value = argument.getValue();
if (value == null) {
return null;
}
if (typeOfT != null) {
return GSON.fromJson(value, typeOfT);
}
return GSON.<T>fromJson(value, Class.forName(argument.getType()));
}
use of io.cdap.cdap.common.internal.remote.MethodArgument in project cdap by caskdata.
the class RemotePrivilegesHandler method revokeAll.
@POST
@Path("/revokeAll")
public void revokeAll(FullHttpRequest request, HttpResponder responder) throws Exception {
Iterator<MethodArgument> arguments = parseArguments(request);
EntityId entityId = deserializeNext(arguments);
LOG.trace("Revoking all actions on {}", entityId);
permissionManager.revoke(Authorizable.fromEntityId(entityId));
LOG.info("Revoked all actions on {} successfully", entityId);
responder.sendStatus(HttpResponseStatus.OK);
}
use of io.cdap.cdap.common.internal.remote.MethodArgument in project cdap by caskdata.
the class RemotePrivilegesHandler method grant.
@POST
@Path("/grant")
public void grant(FullHttpRequest request, HttpResponder responder) throws Exception {
Iterator<MethodArgument> arguments = parseArguments(request);
EntityId entityId = deserializeNext(arguments);
Principal principal = deserializeNext(arguments);
Set<? extends Permission> permissions = deserializeNext(arguments, SET_OF_PERMISSIONS);
LOG.trace("Granting {} on {} to {}", permissions, entityId, principal);
permissionManager.grant(Authorizable.fromEntityId(entityId), principal, permissions);
LOG.info("Granted {} on {} to {} successfully", permissions, entityId, principal);
responder.sendStatus(HttpResponseStatus.OK);
}
use of io.cdap.cdap.common.internal.remote.MethodArgument in project cdap by caskdata.
the class RemotePrivilegesHandler method revoke.
@POST
@Path("/revoke")
public void revoke(FullHttpRequest request, HttpResponder responder) throws Exception {
Iterator<MethodArgument> arguments = parseArguments(request);
EntityId entityId = deserializeNext(arguments);
Principal principal = deserializeNext(arguments);
Set<? extends Permission> permissions = deserializeNext(arguments, SET_OF_PERMISSIONS);
LOG.trace("Revoking {} on {} from {}", permissions, entityId, principal);
permissionManager.revoke(Authorizable.fromEntityId(entityId), principal, permissions);
LOG.info("Revoked {} on {} from {} successfully", permissions, entityId, principal);
responder.sendStatus(HttpResponseStatus.OK);
}
Aggregations