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

SmbFileObject throws NPE when used without authentication

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: 2.1
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: