-There have been significant changes under the hood. The primitives such as packet encoding/decoding and transport have proven very sturdy however the top level glue and logic driving the client really needed an overhaul in hindsight. The client is much smarter now whereas previously jCIFS was quite chatty and used some messages abusively (NodeStatusRequest). Some other cleanups that took into account allocation of buffers and large numbers of objects have resulted in measureable performance improvements. All of this should be transparent to the user however my confidence in the stabilty of 0.5.1 no longer applies. It will take some time to confirm everything works as advertised. I am confident however that any bugs will only require minor adjustments to fix. Of course the name resolution bug that triggered this crusade has been fixed.
+Fri Nov 16 04:07:05 EST 2001
-There are some API changes. Most methods of SmbFile throw the now public SmbException. Natrually, this will require changes to existing code. For example, if your code was:
+jcifs-0.6b released
+
+This is the first beta of 0.6.
+
+There have been significant changes under the hood. The primitives such
+as packet encoding/decoding and transport have proven very sturdy however
+the top level glue and logic driving the client really needed an overhaul
+in hindsight. The client is much smarter now whereas previously jCIFS was
+quite chatty and used some messages abusively (NodeStatusRequest). Some
+other cleanups that took into account allocation of buffers and
+large numbers of objects have resulted in measureable performance
+improvements. All of this should be transparent to the user however my
+confidence in the stabilty of 0.5.1 no longer applies. It will take some
+time to confirm everything works as advertised. I am confident however
+that any bugs will only require minor adjustments to fix. Of course the
+name resolution bug that triggered this crusade has been fixed.
+
+There are some API changes. Most methods of SmbFile throw the now public
+SmbException. Natrually, this will require changes to existing code. For
+example, if your code was:
if( r.delete() ) {
System.out.println( "delete successfull" );
All pipe instances are busy
...
-not all of which have text messages (and which ones do have messages are in only English at the moment). You can test and make dicisions based on the errorClass and errorCode of an SmbException. All SmbExceptions are thrown through these methods unless an object implementing the AuthHandler interface has been called with the static SmbFile.setAuthHanler method. If an AuthHandler has been specified the following authentication related SmbExceptions:
+not all of which have text messages (and which ones do have messages are
+in only English at the moment). You can test and make dicisions based on
+the errorClass and errorCode of an SmbException. All SmbExceptions are
+thrown through these methods unless an object implementing the AuthHandler
+interface has been called with the static SmbFile.setAuthHanler method. If
+an AuthHandler has been specified the following authentication related
+SmbExceptions:
Access denied
Bad password
-The client does not have the necessary access rights for the requested function
+The client does not have the necessary access rights for the
+ requested function
The user account has expired
The user is not allowed to access this server from this client
The user is not permitted to access the server at this time
The password of the user has expired
-will not be thrown by SmbFile methods but rather passed in the AuthInfo object to the AuthHandler's authenticate() method along with the username, password, domain, and target URL if one of these SmbExceptions occurs. See http://lists.samba.org/pipermail/jcifs/2001-October/001553.html for a related discussion. I believe this is a powerfull feature in itself. This provides for sophisticated error handling and consistent error messages (the messages are the same as those reported by Windows clients). There is also an oppurunity to introduce a ResourceBundle of text messages here. I beleive it will work quite well and in practice I do not believe code will be cluttered with try/catch.
-
-The NbtAddress class was designed to handle NetBIOS name queries similarly to the common InetAddress class. Unfortunately a lapse in judgment integrated DNS queries into this class in jcifs-0.5 (thus the name service bug). The solution is to remove this DNS code and provide a wrapper class that handles both DNS queries as well as NetBIOS queries mainly delegating the work to InetAddress and NbtAddress. This class is UniAddress. Here is how each of these classes should be used:
+will not be thrown by SmbFile methods but rather passed in the AuthInfo
+object to the AuthHandler's authenticate() method along with the username,
+password, domain, and target URL if one of these SmbExceptions occurs. See
+http://lists.samba.org/pipermail/jcifs/2001-October/001553.html for a
+related discussion. I believe this is a powerfull feature in itself. This
+provides for sophisticated error handling and consistent error messages
+(the messages are the same as those reported by Windows clients). There
+is also an oppurunity to introduce a ResourceBundle of text messages
+here. I beleive it will work quite well and in practice I do not believe
+code will be cluttered with try/catch.
+
+The NbtAddress class was designed to handle NetBIOS name queries
+similarly to the common InetAddress class. Unfortunately a lapse in
+judgment integrated DNS queries into this class in jcifs-0.5 (thus the
+name service bug). The solution is to remove this DNS code and provide
+a wrapper class that handles both DNS queries as well as NetBIOS queries
+mainly delegating the work to InetAddress and NbtAddress. This class is
+UniAddress. Here is how each of these classes should be used:
o InetAddress - Lookup a DNS name
o NbtAddress - Lookup a NetBIOS name or perform NetBIOS specific
with name services directly (normally not necessary when working with
the jcifs.smb package).
+In summary the classes that have been added or made public are:
+
+jcifs.UniAddress
+jcifs.util.AuthHandler
+jcifs.util.AuthInfo
+jcifs.smb.SmbException
+
Mon Aug 27 00:29:02 EDT 2001
jcifs-0.5.1
<delete dir="build"/>
</target>
<target name="jar" depends="smb">
- <jar jarfile="jcifs-0.5.2.jar" basedir="build"/>
+ <jar jarfile="jcifs-0.6b.jar" basedir="build"/>
</target>
<target name="tgz">
- <copy todir="dist_tmp/jcifs_0.5.2">
+ <copy todir="dist_tmp/jcifs_0.6b">
<fileset dir="." excludes="ant,**/.*,build,jcifs.prp,**/*.tgz,**/*.zip"/>
</copy>
- <tar tarfile="jcifs-0.5.2.tar" basedir="dist_tmp"/>
- <gzip src="jcifs-0.5.2.tar" zipfile="jcifs-0.5.2.tgz"/>
- <delete file="jcifs-0.5.2.tar"/>
+ <tar tarfile="jcifs-0.6b.tar" basedir="dist_tmp"/>
+ <gzip src="jcifs-0.6b.tar" zipfile="jcifs-0.6b.tgz"/>
+ <delete file="jcifs-0.6b.tar"/>
<delete dir="dist_tmp"/>
</target>
<target name="zip">
- <copy todir="dist_tmp/jcifs_0.5.2">
+ <copy todir="dist_tmp/jcifs_0.6b">
<fileset dir="." excludes="ant,**/.*,build,jcifs.prp,**/*.tgz,**/*.zip"/>
</copy>
<fixcrlf srcdir="dist_tmp" cr="add" tab="remove" tablength="4" excludes="**/*.jar,**/*.exe"/>
- <zip zipfile="jcifs-0.5.2.zip" basedir="dist_tmp"/>
+ <zip zipfile="jcifs-0.6b.zip" basedir="dist_tmp"/>
<delete dir="dist_tmp"/>
</target>
version="true"
use="true"
windowtitle="jcifs API">
- <!--link href="http://java.sun.com/products/jdk/1.2/docs/api/"/-->
+ <link href="http://java.sun.com/products/jdk/1.2/docs/api/"/>
</javadoc>
</target>
</project>
+++ /dev/null
-/* examples for the jcifs smb client library in Java
- * Copyright (C) 2001 "Michael B. Allen" <mballen@erols.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-import jcifs.smb.SmbFile;
-import jcifs.smb.SmbFileOutputStream;
-
-public class Append {
-
- public static void main( String argv[] ) throws Exception {
-
- SmbFile f = new SmbFile( argv[0] );
- SmbFileOutputStream out = new SmbFileOutputStream( f, true );
-
- byte[] msg;
- int i = 0;
- while( i++ < 10 ) {
- msg = new String( "this is msg #" + i ).getBytes();
- out.write( msg );
- Thread.sleep( 17000 );
- }
-
- out.close();
- }
-}
+++ /dev/null
-import jcifs.netbios.NbtAddress;
-import java.net.*;
-
-public class Dns {
-
- public static void main( String argv[] ) throws Exception {
- DatagramSocket s = new DatagramSocket( 0, InetAddress.getByName( "255.255.255.255" ));
- }
-}
-
SmbFile file = new SmbFile( argv[0] );
- file.list();
long t1 = System.currentTimeMillis();
String[] files = file.list();
long t2 = System.currentTimeMillis() - t1;
+++ /dev/null
-import java.io.*;
-
-public class ProcTest {
-
- public static void main( String[] argv ) throws Exception {
- BufferedReader br = new BufferedReader( new InputStreamReader( System.in ));
- String pid = br.readLine();
-
- FileInputStream fis = new FileInputStream( "/proc/" + pid + "/status" );
-
- int ch;
- while(( ch = fis.read() ) != -1 ) {
- System.out.print( (char)ch );
- }
- System.out.println( "done" );
- }
-}
--- /dev/null
+Many of these examples are quite wrong now that SmbFile methods throw
+SmbException. They will be cleaned up before 0.6 final.
+/* jcifs smb client library in Java
+ * Copyright (C) 2000 "Michael B. Allen" <mballen@erols.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
package jcifs;
import java.net.InetAddress;
static NbtAddress lookupServerOrWorkgroup( String name, InetAddress svr )
throws UnknownHostException {
Object lock = new Object();
- QueryThread q1d = new QueryThread( lock, name, 0x1d, null, svr );
+ int type = svr == nbns ? 0x1b : 0x1d;
+ QueryThread q1x = new QueryThread( lock, name, type, null, svr );
QueryThread q20 = new QueryThread( lock, name, 0x20, null, svr );
- q1d.setDaemon( true );
+ q1x.setDaemon( true );
q20.setDaemon( true );
try {
synchronized( lock ) {
- q1d.start();
+ q1x.start();
q20.start();
int i = 2;
- while( i-- > 0 && q1d.ans == null && q20.ans == null ) {
+ while( i-- > 0 && q1x.ans == null && q20.ans == null ) {
lock.wait();
}
}
} catch( InterruptedException ie ) {
throw new UnknownHostException( name );
}
- if( q1d.ans != null ) {
-// why was this: return NbtAddress.getByName( q1d.ans.getHostAddress(), 0x1d, null );
- return q1d.ans;
+ if( q1x.ans != null ) {
+ return q1x.ans;
} else if( q20.ans != null ) {
return q20.ans;
} else {
- throw q1d.uhe;
+ throw q1x.uhe;
}
}
public static UniAddress getByName( String hostname )
// probably an IP address
return true;
}
- if( data[i] == '.' ) {
+ if( i < len && data[i] == '.' ) {
dots++;
i++;
}
// invalid netbios name
continue;
}
- addr = NbtAddress.getByName( hostname, 0x20, null, nbns );
+ if( possibleNTDomainOrWorkgroup ) {
+ addr = lookupServerOrWorkgroup( hostname, nbns );
+ } else {
+ addr = NbtAddress.getByName( hostname, 0x20, null, nbns );
+ }
break;
case RESOLVER_BCAST:
if( hostname.length() > 15 ) {
+/* jcifs smb client library in Java
+ * Copyright (C) 2000 "Michael B. Allen" <mballen@erols.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
package jcifs.smb;
import jcifs.Config;
+/* jcifs smb client library in Java
+ * Copyright (C) 2000 "Michael B. Allen" <mballen@erols.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
package jcifs.smb;
public class SmbAuthException extends SmbException {
package jcifs.smb;
import java.io.IOException;
+import jcifs.UniAddress;
/**
* Don't get to attached to these constants, we'll be switching to NT
this.errorClass = errorClass;
this.errorCode = errorCode;
}
+ SmbException( int errorClass, int errorCode, UniAddress addr ) {
+ super( getErrorString( errorClass, errorCode ) + " " + addr.toString() );
+ this.errorClass = errorClass;
+ this.errorCode = errorCode;
+ }
SmbException( int errorClass, int errorCode, String message ) {
super( message );
this.errorClass = errorClass;
}
if( response.received == false ) {
- throw new SmbException( SmbException.ERRserverTimeout );
+ throw new SmbException( SmbException.ERRCLI,
+ SmbException.ERRserverTimeout,
+ address );
}
switch( response.errorCode & 0xFF ) {
case SmbException.SUCCESS:
do {
// default it 1 so that 0 can be used as forever
+ response.received = false;
response.wait( response.responseTimeout == 1 ? responseTimeout : response.responseTimeout );
} while( response.received && response.hasMoreElements() );
}
if( response.received == false ) {
throw new SmbException( SmbException.ERRCLI,
- SmbException.ERRserverTimeout );
+ SmbException.ERRserverTimeout,
+ address );
}
switch( response.errorCode & 0xFF ) {
case SmbException.SUCCESS:
beg++;
}
if( beg == end && Character.isDigit( url.charAt( start + 2 )) == false ) {
+ int type;
// Could be a workgroup. Need to query the network to find out.
file.address = UniAddress.getByName( url.substring( 6, end ), true );
- if( ((NbtAddress)file.address.getAddress()).getNameType() == 0x1d ) {
+ type = ((NbtAddress)file.address.getAddress()).getNameType();
+ if( type == 0x1d || type == 0x1b ) {
if( name != null ) {
url = "smb://" + name;
name = null;
+/* jcifs smb client library in Java
+ * Copyright (C) 2000 "Michael B. Allen" <mballen@erols.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
package jcifs.util;
public interface AuthHandler {
+/* jcifs smb client library in Java
+ * Copyright (C) 2000 "Michael B. Allen" <mballen@erols.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
package jcifs.util;
public class AuthInfo {