[jcifs] URLStreamHandler [was jcifs bug]
Allen, Michael B (RSCH)
Michael_B_Allen at ml.com
Thu Mar 28 10:34:00 EST 2002
> -----Original Message-----
> From: Bernie Wieser [SMTP:bernie.wieser at calgary.qcdata.com]
> Sent: Wednesday, March 27, 2002 1:43 PM
> To: Allen, Michael B (RSCH)
> Subject: RE: [jcifs] jcifs bug
>
> The URL remains uninitialized if there is a nmblookup error.
> The default parse URL [should] work under 1.2 as well, but I don't
> have 1.2 to test with. We are very regulated... I cannot install
> it (at work.) [A compromise, though not maybe not necessary if
> 1.2 parseURL also "does the right thing", would be
> to call the superclass' parseURL in the catch block, or...
> call it by default and setURL( u, authority, u.getPort(), ...)]
>
No, I think the authority stuff was added in 1.3. Remember with the below
1.1 Handler the result of a lookup failure is a MalformedURLException vs.
UnknownHostException on openConnection(). It's not accurate or elegant
but it will work.
Mike
> B.
>
> -----Original Message-----
> From: Allen, Michael B (RSCH) [mailto:Michael_B_Allen at ml.com]
> Sent: Tuesday, March 26, 2002 6:40 PM
> To: 'Bernie Wieser'
> Cc: 'jcifs at samba.org'
> Subject: RE: [jcifs] jcifs bug
>
>
>
> > -----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