@Override
  public User loadEntity(String entityName) throws IOException {
    File entityFile = checkFileAvailable(entityName, "");
    if (entityFile == null) {
      return null;
    }
    FileInputStream inputStream = new FileInputStream(entityFile);
    try (DataInputStream dataInputStream =
        new DataInputStream(new BufferedInputStream(inputStream))) {
      boolean fromOldVersion = false;
      int tag = dataInputStream.readInt();
      if (tag < 0) {
        fromOldVersion = true;
      }
      User user = new User();

      if (fromOldVersion) {
        String name =
            IOUtils.readString(dataInputStream, STRING_ENCODING, strBufferLocal, -1 * tag);
        user.setName(name);
        user.setPassword(IOUtils.readString(dataInputStream, STRING_ENCODING, strBufferLocal));
        user.setSysPrivilegesWithMask(dataInputStream.readInt());
        List<PathPrivilege> pathPrivilegeList = new ArrayList<>();
        for (int i = 0; dataInputStream.available() != 0; i++) {
          pathPrivilegeList.add(
              IOUtils.readPathPrivilege(dataInputStream, STRING_ENCODING, strBufferLocal));
        }
        user.setPrivilegeList(pathPrivilegeList);
      } else {
        assert (tag == VERSION);
        user.setName(IOUtils.readString(dataInputStream, STRING_ENCODING, strBufferLocal));
        user.setPassword(IOUtils.readString(dataInputStream, STRING_ENCODING, strBufferLocal));
        loadPrivileges(dataInputStream, user);
      }

      File roleOfUser = checkFileAvailable(entityName, "_role");
      Set<String> roleSet = new HashSet<>();
      if (roleOfUser != null && roleOfUser.exists()) {
        inputStream = new FileInputStream(roleOfUser);
        try (DataInputStream roleInputStream =
            new DataInputStream(new BufferedInputStream(inputStream))) {
          for (int i = 0; roleInputStream.available() != 0; i++) {
            String roleName = IOUtils.readString(roleInputStream, STRING_ENCODING, strBufferLocal);
            roleSet.add(roleName);
          }
        }
      }
      user.setRoleSet(roleSet);
      return user;

    } catch (Exception e) {
      throw new IOException(e);
    } finally {
      strBufferLocal.remove();
    }
  }
Deserialize a user from its user file.

@param entityName The name of the user to be deserialized.
@return The user object or null if no such user.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/auth/user/LocalFileUserAccessor.java