Avatar of sachmans
sachmans
 asked on

Java Applet Proxy Authentication Issue.

Hi there.

I have an Java Applet that runs in a browser.
It essentially acts as a SOCKS proxy server and tunnels a single connection through a HTTP proxy server (if one is present) to an external TCP service.

This Applet works fine, except when the proxy server requires authentication.

I have proxy detection code in my applet. If the proxy server requires authentication then the applet will pop-up a username/password dialog for the proxy server credentials. This is ok. I think the code that triggers the dialog is:

ProxyInfo info[] = ProxyService.getProxyInfo(new URL(host));
                  
The problem is that once the proxy server is determined I connect through it using Non-Blocking Sockets, which doesn't use the proxy credentials that were typed in earlier. I can pass the proxy credentials through in the header of the HTTP request that is used for initialising the tunnel, but these must be typed in again by the user.

I just don't want to have to ask the user for creditials twice.

I have tried using a custom java.net.Authenticator object, but I have been unable to override the default popup, or hard-code the username and password in my own Authenticator.

So essentially I need to know:

Is there a way to suppress the authentication dialog that popups when I detect the proxy server? This way I can prompt the user for the username and password in the HTML page and then pass it to the applets outgoing TCP connection.

OR

Is there away to get the username and password that was typed into the popup dialog so that I can pass the Username and password through to the proxy when i create the outgoing TCP connection?

Thanks.

Peter
Java

Avatar of undefined
Last Comment
CEHJ

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
CEHJ

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61