Two way to do it:
1) More current way:
a) Extend the Authenticator class
b) install it
myAuth = new MyAuthenticator ();
Authenticator.setDefault (this.myAuth);
c)Read in your URL
try {
URL url = new URL (urlString);
InputStream content = (InputStream)url.getContent();
BufferedReader in =
new BufferedReader (new InputStreamReader (content));
2) manage the interaction yourself (old style)
String userpass = new String
(_userDomain+"/"+_username+":"+_password);
URL url = new URL (urlString);
String encoding = new sun.misc.BASE64Encoder().encode
(userpass.getBytes());
URLConnection uc = url.openConnection();
uc.setRequestProperty ("Authorization", "Basic " + encoding);
InputStream content = (InputStream)uc.getInputStream();
BufferedReader in =
new BufferedReader (new InputStreamReader (content));
------
That's it.
Thor HW
----- Original Message -----
From: Booth, Peter <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, December 03, 1999 7:52 AM
Subject: FW: How can a Java application connect to a user authenticated se
rvlet?
> > Hello,
> >
> > I am developing a distributed application that consists
> > of a Java applet and a Java servlet. The servlet will run
> > in a DMZ on a web server that is using basic authentication
> > over HTTPS.
> >
> > I also need to have a small daemon process
> > (Java application) on a client machine that makes connections
> > to the servlet.
> >
> > How can a Java application access a URL that has basic
> > user authentication?
> >
> > How can a Java application access a secure (HTTPS) URL,
> > when it isn't running in a browser?
> >
> > Peter Booth
> > [EMAIL PROTECTED]
>
> This message is for the named person's use only. It may contain
> confidential, proprietary or legally privileged information. No
> confidentiality or privilege is waived or lost by any mistransmission.
> If you receive this message in error, please immediately delete it and all
> copies of it from your system, destroy any hard copies of it and notify
the
> sender. You must not, directly or indirectly, use, disclose, distribute,
> print, or copy any part of this message if you are not the intended
> recipient. CREDIT SUISSE GROUP, CREDIT SUISSE FIRST BOSTON, and each of
> their subsidiaries each reserve the right to monitor all e-mail
> communications through its networks. Any views expressed in this message
> are those of the individual sender, except where the message states
> otherwise and the sender is authorised to state them to be the views of
> any such entity.
> .
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html