You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Bernd Eckenfels (JIRA)" <ji...@apache.org> on 2015/04/12 19:47:12 UTC

[jira] [Resolved] (VFS-236) SmbFileObject throws NPE when used without authentication

     [ https://issues.apache.org/jira/browse/VFS-236?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bernd Eckenfels resolved VFS-236.
---------------------------------
    Resolution: Fixed
      Assignee: Bernd Eckenfels

Since this did not worked before the new behavior can be either GUEST or ANONYMOUS.

The code looks best with just passing null to SmbFile (which internally will be a Guest login).

If you need Anonymous access instead one would have to set up a ANONYMOUS=(""\"":"") credential. I guess the later could not be done by purely using the URL syntax (but you could use the smb system properties).

Committed in http://svn.apache.org/r1673034

> SmbFileObject throws NPE when used without authentication
> ---------------------------------------------------------
>
>                 Key: VFS-236
>                 URL: https://issues.apache.org/jira/browse/VFS-236
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: Nightly Builds
>            Reporter: Matt Casters
>            Assignee: Bernd Eckenfels
>             Fix For: 2.1
>
>
> 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;
>     }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)