[jcifs] Reporting a bug on NtlmPasswordAuthentication when using Android
paulo louro
paulo_louro at msn.com
Sun Sep 18 04:29:45 MDT 2011
Hello,
I hope this is the right way to report a bug, if not my apologies.
The problem is related with the implementation of the string.indexOf('@') method on Android API.
In the function NtlmPasswordAuthentication in the jcifs.smb.NtlmPasswordAuthentication.java class. when creating and authentication without the username or password ( = null) then the indexOf was generating the NullPointerException.
To solve the following issue i included a simple check on the username against null.
If im not mistaking this is needed when a GUEST connection is needed to the server.
/**
* Create an <tt>NtlmPasswordAuthentication</tt> object from a
* domain, username, and password. Parameters that are <tt>null</tt>
* will be substituted with <tt>jcifs.smb.client.domain</tt>,
* <tt>jcifs.smb.client.username</tt>, <tt>jcifs.smb.client.password</tt>
* property values.
*/
public NtlmPasswordAuthentication( String domain, String username, String password ) {
int ci;
if(username != null){
ci = username.indexOf('@');
if (ci > 0) {
domain = username.substring(ci + 1);
username = username.substring(0, ci);
} else {
ci = username.indexOf('\\');
if (ci > 0) {
domain = username.substring(0, ci);
username = username.substring(ci + 1);
}
}
}
this.domain = domain;
this.username = username;
this.password = password;
initDefaults();
if( domain == null ) this.domain = DEFAULT_DOMAIN;
if( username == null ) this.username = DEFAULT_USERNAME;
if( password == null ) this.password = DEFAULT_PASSWORD;
}
--Paulo Louro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/jcifs/attachments/20110918/34699b9a/attachment.html>
More information about the jCIFS
mailing list