private boolean checkEntityPrivileges(Role role, PrivilegeUnion union) {
    switch (union.getModelType()) {
      case TREE:
        if (union.isGrantOption()) {
          return role.checkPathPrivilegeGrantOpt(union.getPath(), union.getPrivilegeType());
        }
        return role.checkPathPrivilege(union.getPath(), union.getPrivilegeType());
      case RELATIONAL:
        // check any scope privilege
        if (union.isForAny()) {
          if (union.getPrivilegeType() == null) {
            return role.checkAnyVisible();
          }
          if (union.isGrantOption()) {
            return role.checkAnyScopePrivilegeGrantOption(union.getPrivilegeType());
          }
          return role.checkAnyScopePrivilege(union.getPrivilegeType());
        } else if (union.getTbName() == null) {
          if (union.getPrivilegeType() == null) {
            return role.checkDBVisible(union.getDBName());
          }
          if (union.isGrantOption()) {
            return role.checkDatabasePrivilegeGrantOption(
                union.getDBName(), union.getPrivilegeType());
          }
          return role.checkDatabasePrivilege(union.getDBName(), union.getPrivilegeType());
        } else {
          if (union.getPrivilegeType() == null) {
            return role.checkTBVisible(union.getDBName(), union.getTbName());
          }
          if (union.isGrantOption()) {
            return role.checkTablePrivilegeGrantOption(
                union.getDBName(), union.getTbName(), union.getPrivilegeType());
          }
          return role.checkTablePrivilege(
              union.getDBName(), union.getTbName(), union.getPrivilegeType());
        }
      case SYSTEM:
        if (union.isGrantOption()) {
          return role.checkSysPriGrantOpt(union.getPrivilegeType());
        }
        return role.checkSysPrivilege(union.getPrivilegeType());
    }
    return false;
  }
Checks if a user has admin privileges
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/auth/authorizer/BasicAuthorizer.java