private static FileObject resolveFileObject(String filePath, FileSystemOptions options, OtrosUserAuthenticator authenticator, AuthStore persistentAuthStore, AuthStore sessionAuthStore) throws FileSystemException {

    FileObject resolveFile;

    VFSURIParser parser = new VFSURIParser(filePath);

    //Get file type to force authentication
    try {
      resolveFile = getFileSystemManager().resolveFile(filePath, options);
      resolveFile.getType();
    } catch (FileSystemException e) {
      LOGGER.error("Error resolving file " + URI_UTILS.getFriendlyURI(filePath), e);
      Throwable rootCause = Throwables.getRootCause(e);
      boolean authorizationFailed = checkForWrongCredentials(rootCause);
      if (authorizationFailed) {
        LOGGER.error("Wrong user name or password for " + filePath);
        //clear last data
        //authenticator can be null if user/password was entered in URL
        if (authenticator != null) {
          Optional.ofNullable(authenticator.getLastUserAuthenticationData()).ifPresent(
            lastUserAuthenticationData -> {
              lastUserAuthenticationData.remove(UserAuthenticationDataWrapper.PASSWORD);
              String user = new String(lastUserAuthenticationData.getData(UserAuthenticationData.USERNAME));
              UserAuthenticationInfo auInfo = new UserAuthenticationInfo(parser.getProtocol().getName(), parser.getHostname(), user);
              sessionAuthStore.remove(auInfo);
              sessionAuthStore.add(auInfo, lastUserAuthenticationData);
              LOGGER.info("Removing password for {} on {}", new String(lastUserAuthenticationData.getData(UserAuthenticationData.USERNAME)), filePath);
            }
          );
        }
      }
      throw e;
    }

    if (resolveFile != null && authenticator != null && authenticator.getLastUserAuthenticationData() != null) {
      UserAuthenticationDataWrapper lastUserAuthenticationData = authenticator.getLastUserAuthenticationData();
      Map<Type, char[]> addedTypes = lastUserAuthenticationData.getAddedTypes();
      String user = new String(addedTypes.get(UserAuthenticationData.USERNAME));
      UserAuthenticationInfo auInfo = new UserAuthenticationInfo(parser.getProtocol().getName(), parser.getHostname(), user);
      sessionAuthStore.add(auInfo, lastUserAuthenticationData.copy());
      if (authenticator.isPasswordSave()) {
        LOGGER.info("Saving password for {}://{}@{}", parser.getProtocol().getName(), user, parser.getHostname());
        persistentAuthStore.add(auInfo, lastUserAuthenticationData);
        saveAuthStore();
      }
    }
    return resolveFile;
  }
Returns a file representation

@param filePath The file path
@param options  The filesystem options
@return a file representation
@throws FileSystemException
olv-vfs/src/main/java/pl/otros/vfs/browser/util/VFSUtils.java