public static List<UserPermission> getUserPermissions(Connection connection, String tableRegex,
    byte[] columnFamily, byte[] columnQualifier, String userName) throws Throwable {
    if (tableRegex == null || tableRegex.isEmpty() || tableRegex.charAt(0) == '@') {
      throw new IllegalArgumentException("Table name can't be null or empty or a namespace.");
    }
    List<UserPermission> permList = new ArrayList<UserPermission>();
    try (Admin admin = connection.getAdmin()) {
      List<TableDescriptor> htds = admin.listTableDescriptors(Pattern.compile(tableRegex), true);
      // Retrieve table permissions
      for (TableDescriptor htd : htds) {
        permList.addAll(admin.getUserPermissions(
          GetUserPermissionsRequest.newBuilder(htd.getTableName()).withFamily(columnFamily)
            .withQualifier(columnQualifier).withUserName(userName).build()));
      }
    }
    return permList;
  }
List all the userPermissions matching the given table pattern, column family and column
qualifier.
@param connection      Connection
@param tableRegex      The regular expression string to match against. It shouldn't be null,
                       empty or a namespace regular expression.
@param columnFamily    Column family
@param columnQualifier Column qualifier
@param userName        User name, if empty then all user permissions will be retrieved.
@return List of UserPermissions
@throws Throwable on failure
hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlClient.java