commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Casters (JIRA)" <j...@apache.org>
Subject [jira] Created: (VFS-236) SmbFileObject throws NPE when used without authentication
Date Thu, 05 Feb 2009 23:07:59 GMT
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
             Fix For: 2.0


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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message