You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Updated) (JIRA)" <ji...@apache.org> on 2012/04/20 15:18:43 UTC
[jira] [Updated] (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 ]
Gary D. Gregory updated VFS-236:
--------------------------------
Fix Version/s: (was: 2.0)
2.1
> 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.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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira