public static AccessControlProtos.GrantRequest buildGrantRequest(String username,
    TableName tableName, byte[] family, byte[] qualifier, boolean mergeExistingPermissions,
    AccessControlProtos.Permission.Action... actions) {
    AccessControlProtos.Permission.Builder ret = AccessControlProtos.Permission.newBuilder();
    AccessControlProtos.TablePermission.Builder permissionBuilder =
      AccessControlProtos.TablePermission.newBuilder();
    for (AccessControlProtos.Permission.Action a : actions) {
      permissionBuilder.addAction(a);
    }

    Objects.requireNonNull(tableName, "TableName cannot be null");

    permissionBuilder.setTableName(ProtobufUtil.toProtoTableName(tableName));

    if (family != null) {
      permissionBuilder.setFamily(UnsafeByteOperations.unsafeWrap(family));
    }
    if (qualifier != null) {
      permissionBuilder.setQualifier(UnsafeByteOperations.unsafeWrap(qualifier));
    }
    ret.setType(AccessControlProtos.Permission.Type.Table).setTablePermission(permissionBuilder);
    return AccessControlProtos.GrantRequest.newBuilder()
      .setUserPermission(AccessControlProtos.UserPermission.newBuilder()
        .setUser(ByteString.copyFromUtf8(username)).setPermission(ret))
      .setMergeExistingPermissions(mergeExistingPermissions).build();
  }
Create a request to grant user table permissions.
@param username  the short user name who to grant permissions
@param tableName optional table name the permissions apply
@param family    optional column family
@param qualifier optional qualifier
@param actions   the permissions to be granted
@return A {@link AccessControlProtos} GrantRequest
@throws NullPointerException if {@code tableName} is {@code null}
hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlUtil.java