Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-236

SmbFileObject throws NPE when used without authentication

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Nightly Builds
    • 2.1
    • None

    Description

      If you have a shared folder without authentication, SmbFileObject throws an NPE in method createSmbFile().

      Here is what I changed to get it to run:

      private SmbFile createSmbFile(FileName fileName) throws MalformedURLException, SmbException, FileSystemException
      {
      SmbFileName smbFileName = (SmbFileName) fileName;

      String path = smbFileName.getUriWithoutAuth();

      UserAuthenticationData authData = null;
      SmbFile file;
      NtlmPasswordAuthentication auth;
      try
      {
      authData = UserAuthenticatorUtils.authenticate(getFileSystem().getFileSystemOptions(), SmbFileProvider.AUTHENTICATOR_TYPES);
      if (authData!=null)

      { auth = new NtlmPasswordAuthentication( UserAuthenticatorUtils.toString( UserAuthenticatorUtils.getData( authData, UserAuthenticationData.DOMAIN, UserAuthenticatorUtils.toChar(smbFileName.getDomain()))), UserAuthenticatorUtils.toString( UserAuthenticatorUtils.getData( authData, UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(smbFileName.getUserName()))), UserAuthenticatorUtils.toString( UserAuthenticatorUtils.getData( authData, UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(smbFileName.getPassword())))); file = new SmbFile(path, auth); }

      else

      { auth=null; file = new SmbFile(path); }

      }
      finally

      { UserAuthenticatorUtils.cleanup(authData); }

      if (file.isDirectory() && !file.toString().endsWith("/"))
      {
      if (auth!=null)

      { file = new SmbFile(path + "/", auth); }

      else

      { file = new SmbFile(path + "/"); }

      }

      return file;
      }

      Attachments

        Activity

          People

            b.eckenfels Bernd Eckenfels
            mattcasters Matt Casters
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: