posted 21 years ago
Hi all
Imagine situation:
a. You need to access a password protected page (HTTP authorization)
b. You are behind a corporate firewall wich asks you for another
user/password credentials
So you have to pass proxy authorization first and page authorization second.
It's ok for me to pass separately 1 or second stage using simple
"authenticator" class but how to combine them?
As a sample i pass you code which works fine only for one step of
authorization. Question is how to pass 2 consequent authorization requests?
"MyAuthenticator.class"
......
class MyAuthenticator extends Authenticator
{
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication ("user","password".toCharArray());
}
}
.....
Invoking method in main class
.................
java.net.Authenticator.setDefault (new MyAuthenticator ());
URL curl=new URL("password protected URL");
.................