Java Code Examples for org.apache.hadoop.hbase.ipc.RpcServer#isInRpcCallContext()

The following examples show how to use org.apache.hadoop.hbase.ipc.RpcServer#isInRpcCallContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RangerAuthorizationCoprocessor.java    From ranger with Apache License 2.0 5 votes vote down vote up
private void requireScannerOwner(ObserverContext<?> ctx, InternalScanner s) throws AccessDeniedException {
    if (!RpcServer.isInRpcCallContext()) {
      return;
    }

    User user = getActiveUser(ctx);
 String requestUserName = user.getShortName();
    String owner = scannerOwners.get(s);
    if (owner != null && !owner.equals(requestUserName)) {
      throw new AccessDeniedException("User '"+ requestUserName +"' is not the scanner owner!");
    }	
}
 
Example 2
Source File: VisibilityController.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Verify, when servicing an RPC, that the caller is the scanner owner. If so, we assume that
 * access control is correctly enforced based on the checks performed in preScannerOpen()
 */
private void requireScannerOwner(InternalScanner s) throws AccessDeniedException {
  if (!RpcServer.isInRpcCallContext())
    return;
  String requestUName = RpcServer.getRequestUserName().orElse(null);
  String owner = scannerOwners.get(s);
  if (authorizationEnabled && owner != null && !owner.equals(requestUName)) {
    throw new AccessDeniedException("User '" + requestUName + "' is not the scanner owner!");
  }
}
 
Example 3
Source File: AccessController.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Verify, when servicing an RPC, that the caller is the scanner owner.
 * If so, we assume that access control is correctly enforced based on
 * the checks performed in preScannerOpen()
 */
private void requireScannerOwner(InternalScanner s) throws AccessDeniedException {
  if (!RpcServer.isInRpcCallContext()) {
    return;
  }
  String requestUserName = RpcServer.getRequestUserName().orElse(null);
  String owner = scannerOwners.get(s);
  if (authorizationEnabled && owner != null && !owner.equals(requestUserName)) {
    throw new AccessDeniedException("User '"+ requestUserName +"' is not the scanner owner!");
  }
}