Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Automated Basic Authenication with an Applet for the Browser ?

7 views
Skip to first unread message

Francois Belfort

unread,
Sep 14, 2004, 7:16:56 AM9/14/04
to
I like to automate web access to secure pages and proxies, which are
proteced with a Basic Authenication scheme.

The Basic Authentication within an Applet works really well, I get all
the information I need when I attach the

Authorization: Basic base64encodeUID_PW to the request Header.
or
if I use the Authenticator Class of the JDK1.5.

My problem is that the browser does not notice that I already have
a UID/Password combination for the desired web page.

When I did the same with a form based authorisation the URLConnection
was setting the Cookie inside the browser implicitly, the
showDocument() method displayed the secure page, because the browser
used the cookie to access it.

Is there any way to access the cache for the UID and Password of the
browser to set these values that when I invoke the showDocument() to
display the page inside the browser, I don't have to enter the UID and
Password again?

My current code to authenticate myself is this, I also tried a direct
socket connection and a HttpURLConnection there was no difference:


String urlString =
"http://www.demo.com/basicprotectedpage/index.html"
AppletContext appCont = getAppletContext();

//created password authenticator.
mmAuthenticator myPassAuth = new mmAuthenticator(uid,pw);
//setting password.
Authenticator.setDefault(myPassAuth);

//URL created.
URL url = new URL(urlString);
//opening connection
URLConnection conn = url.openConnection();

//setting do input and do output.
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(true);

//Data Input Stream

BufferedReader bin = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
String inputLine;
System.out.println("web page data " );
while ((inputLine = bin.readLine()) != null)

System.out.println(inputLine);

bin.close();

appCont.showDocument(new URL(urlString)); // this should
display the secure page without the prompt for uid password

Thank you in advance. Have a nice day.

FB

0 new messages