jcifs-0.6b from tgz
authorFelix Schumacher <p0354740@isib001.(none)>
Wed, 6 Aug 2008 14:02:07 +0000 (16:02 +0200)
committerFelix Schumacher <p0354740@isib001.(none)>
Wed, 6 Aug 2008 14:02:07 +0000 (16:02 +0200)
Fri Nov 16 04:07:05 EST 2001

jcifs-0.6b released

This is the first beta of 0.6.

15 files changed:
README.txt
build.xml
examples/Append.java [deleted file]
examples/Dns.java [deleted file]
examples/List.java
examples/ProcTest.java [deleted file]
examples/README.txt [new file with mode: 0644]
src/jcifs/UniAddress.java
src/jcifs/smb/BufferCache.java
src/jcifs/smb/SmbAuthException.java
src/jcifs/smb/SmbException.java
src/jcifs/smb/SmbTransport.java
src/jcifs/smb/SmbURL.java
src/jcifs/util/AuthHandler.java
src/jcifs/util/AuthInfo.java

index 21ea297..f26743d 100644 (file)
@@ -1,6 +1,25 @@
-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" );
@@ -24,19 +43,41 @@ The device is not ready
 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
@@ -49,6 +90,13 @@ So generally the UniAddress class should be used if you wish to interface
 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
index 8561843..17c6fcc 100644 (file)
--- a/build.xml
+++ b/build.xml
                <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>
 
@@ -75,7 +75,7 @@
                                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>
diff --git a/examples/Append.java b/examples/Append.java
deleted file mode 100644 (file)
index a685320..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/* 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();
-       }
-}
diff --git a/examples/Dns.java b/examples/Dns.java
deleted file mode 100644 (file)
index 2a5209f..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-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" ));
-       }
-}
-
index fe4ab54..56c15a1 100644 (file)
@@ -27,7 +27,6 @@ public class List {
 
                SmbFile file = new SmbFile( argv[0] );
 
-               file.list();
                long t1 = System.currentTimeMillis();
                String[] files = file.list();
                long t2 = System.currentTimeMillis() - t1;
diff --git a/examples/ProcTest.java b/examples/ProcTest.java
deleted file mode 100644 (file)
index a8b9758..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-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" );
-       }
-}
diff --git a/examples/README.txt b/examples/README.txt
new file mode 100644 (file)
index 0000000..fc40721
--- /dev/null
@@ -0,0 +1,2 @@
+Many of these examples are quite wrong now that SmbFile methods throw
+SmbException. They will be cleaned up before 0.6 final.
index 81e8873..4eae90f 100644 (file)
@@ -1,3 +1,21 @@
+/* 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;
@@ -118,30 +136,30 @@ public class UniAddress {
        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 )
@@ -162,7 +180,7 @@ public class UniAddress {
                                        // probably an IP address
                                        return true;
                                }
-                               if( data[i] == '.' ) {
+                               if( i < len && data[i] == '.' ) {
                                        dots++;
                                        i++;
                                }
@@ -200,7 +218,11 @@ public class UniAddress {
                                                                                                        // 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 ) {
index f07f331..38c1246 100644 (file)
@@ -1,3 +1,21 @@
+/* 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;
index 0419498..4d6e9d8 100644 (file)
@@ -1,3 +1,21 @@
+/* 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 {
index 6b73a99..54b6c6c 100644 (file)
@@ -19,6 +19,7 @@
 package jcifs.smb;
 
 import java.io.IOException;
+import jcifs.UniAddress;
 
 /**
  * Don't get to attached to these constants, we'll be switching to NT
@@ -324,6 +325,11 @@ public class SmbException extends IOException {
                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;
index ed1d903..641a5aa 100644 (file)
@@ -460,7 +460,9 @@ class SmbTransport implements Runnable {
                }
 
                if( response.received == false ) {
-                       throw new SmbException( SmbException.ERRserverTimeout );
+                       throw new SmbException( SmbException.ERRCLI,
+                                                                       SmbException.ERRserverTimeout,
+                                                                       address );
                }
                switch( response.errorCode & 0xFF ) {
                        case SmbException.SUCCESS:
@@ -569,6 +571,7 @@ class SmbTransport implements Runnable {
 
                                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() );
                        }
@@ -584,7 +587,8 @@ class SmbTransport implements Runnable {
 
                if( response.received == false ) {
                        throw new SmbException( SmbException.ERRCLI,
-                                                                       SmbException.ERRserverTimeout );
+                                                                       SmbException.ERRserverTimeout,
+                                                                       address );
                }
                switch( response.errorCode & 0xFF ) {
                        case SmbException.SUCCESS:
index 04d0787..cefb30a 100644 (file)
@@ -68,9 +68,11 @@ final class SmbURL {
                                        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;
index 3e72557..6ef6ef5 100644 (file)
@@ -1,3 +1,21 @@
+/* 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 {
index c2e9f8b..a8989e1 100644 (file)
@@ -1,3 +1,21 @@
+/* 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 {