private TSStatus checkPrivilege(
      String username,
      PrivilegeUnion union,
      BiFunction<Role, PrivilegeUnion, Boolean> privilegeCheck,
      TCheckUserPrivilegesReq req) {
    User user = iAuthorCache.getUserCache(username);
    if (user != null) {
      if (privilegeCheck.apply(user, union)) {
        return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
      }
      boolean remoteCheck = false;
      for (String rolename : user.getRoleSet()) {
        Role role = iAuthorCache.getRoleCache(rolename);
        if (role == null) {
          remoteCheck = true;
          break;
        }
        if (privilegeCheck.apply(role, union)) {
          return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
        }
      }
      if (remoteCheck) {
        return checkPrivilegeFromConfigNode(req).getStatus();
      }
      return RpcUtils.getStatus(TSStatusCode.NO_PERMISSION);
    }
    return checkPrivilegeFromConfigNode(req).getStatus();
  }
-- check user privileges SYSTEM, TREE, RELATIONAL-- *
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java