[jcifs] jcifs bug

Allen, Michael B (RSCH) Michael_B_Allen at ml.com
Wed Mar 27 12:39:59 EST 2002


> -----Original Message-----
> From:	Bernie Wieser [SMTP:bernie.wieser at calgary.qcdata.com]
> 
> BTW, on Handler, I completely removed the parseURL because the superclass
> seems to do the right thing parsing SMB urls, and conveniently considers
> domain;
> as part of auth. (restated will not blow chunks on ;)
> 
	Well that's great to hear because we can eventually use that but the generic jcifs
	distribution still needs to support Java < 1.3. In fact we still support 1.1. I see no reason
	to break that. I don't suppose you tried the Java < 1.3 Handler.java I sent out before
	(also below)? Any chance you could pop it into your env for a minute just to test it for
	us?

	Mike

--8<--

/* jcifs smb client library in Java
 * Copyright (C) 2000  "Michael B. Allen" <mballen at 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 java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.io.IOException;

public class Handler extends URLStreamHandler {

	public URLConnection openConnection( URL u ) throws IOException {
		SmbFile f = new SmbFile( this.toExternalForm(u) );
		return new SmbURLConnection( u, f );
	}

	protected void parseURL( URL u, String spec, int start, int limit ) {
		SmbFile f;
		String authority;
		int port = -1;

		try {
			f = new SmbFile( spec, null, start, limit );

			if( f.authInfo.username != null ) {
				String userinfo = f.authInfo.username;
				if( f.authInfo.domain != null ) {
					userinfo = f.authInfo.domain + ';' + userinfo;
				}
				if( f.authInfo.password != null ) {
					userinfo += ':' + f.authInfo.password;
				}
				authority = userinfo + '@' + f.server;
			} else {
				authority = f.server;
			}
			if (f.port > 0 && f.port != 139) {
				port = f.port;
			}

			setURL( u, "smb", authority, port,
					'/' + f.share + f.canonicalPath, null );

		} catch( IOException ioe ) {
			Log.printStackTrace( "smb URLStreamHandler exception", ioe );
		}
	}
}






More information about the jcifs mailing list