But don't use "Basic" Auth unless you want junior High School kids to
be able to break into your server.   At the least Use "Digest"

Alasdair Liddell wrote:
> 
> Try the following
> 
>     String user = "user:password";
>     String encoded = new sun.misc.BASE64Encoder().encode(user.getBytes());
> 
>     URL url = new URL(url_string);
>     URLConnection urlConn = url.openConnection();
>     urlConn.setRequestProperty("Authorization", "Basic " + encoded);
> 
> Alasdair
> 
> > -----Original Message-----
> > From: Scot Mcphee [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, September 10, 2002 10:10
> > To: JDJList
> > Subject: [jdjlist] username/password in java.net.URL?
> >
> >
> > I am trying to put the username and password required by a
> > server into the
> > java.net.URL class so I can get some data off a password
> > protected server.
> > The URL class always returns a FileNotFound exception. There
> > doesn't seem to
> > be any way to set the authentication information other than
> > in the full URL
> > string as per the standard way;
> >
> > http://user:password@hostname/path
> >
> > the URL works great in either IE or Mozilla. However this code;
> >
> > String location = "http://user:password@hostname/path";;
> > URL url = new URL(location);
> > URLConnection urlC = url.openConnection();
> > urlC.connect();
> >
> > always produces the exception;
> >
> > java.io.FileNotFoundException: http://user:password@hostname/path
> >
> > If I try this;
> >
> > url.getAuthority();
> >
> > it returns;
> >
> > user:password@hostname
> >
> > I've the various other separators in RFC2396 but all others return
> > "MalformedURLException". The individual components
> > constructor of the URL
> > class doesn't include the authority info as a separate item.
> > The JavaDoc has
> > a 'set' method but it's a protected member.
> >
> > Does anyone have any idea how I can progress further? Do I
> > have to subclass
> > it? Is there another technique?
> >
> > thanks
> > scot.
> >
> >
> > ___________________________________________
> > Scot Mcphee -                 Snr Developer
> >             -       (mobile) +61-412-957414
> > ___________________________________________
> > Tigerex     -        http://www.tigerex.net
> >             -          (bus) +61-2-82593613
> > ___________________________________________
> >
> >
> >
> > To change your JDJList options, please visit:
> > http://www.sys-con.com/java/list.cfm
> >
> 
> To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm


To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm

Reply via email to