• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is Proxy Authenticated or not in Applet

 
arvind puppala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I need to show proxy details to the user in an applet and I got the proxy host and port by using the JDK API and I need to check is the proxy is authenticated or not and I used the below code in the applet

public boolean checkHttpAuthentication() {
logger.info("Start of detecting proxy authentication settings");
HttpURLConnection urlConnection = null;

try {
String host = SiteSurveyAppletConstants.HTTP_PROXY_DETECT_URL;

URL url = new URL(host);
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.setUseCaches(false);

int statusCode = urlConnection.getResponseCode();
logger.info("statusCode : " + statusCode);

if(statusCode == 207) {
isProxyAuthenticated = true;
}
} catch (Exception e) {
logger.error("Error occured\n", e);
}
logger.info("End of detecting proxy authentication settings");
return isProxyAuthenticated;
}


When I access the applet a dialog box (Firefox browser dialog box) is prompting to enter the user credential and applet is loaded into the browser after entering the user credentials, but if you see the code in above snippet, it's not returning me the 407 status code, it's returning me the 200.

In my application applet will first fetch the proxy settings and will do some processing (connecting to the server) and will load into the browser. So for connecting to the server I need to know whether the proxy is authenticated or not. If it is authenticated then I need to open a dialog box asking the user to enter the credentials and will use those credentials for connecting back to the server

Can anyone help me what is causing the problem

Thanks
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello aravind-

Welcome to JavaRanch.

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

As to your question, you don't seem to be setting any proxy properties. The code connects directly to the proxy server (at least that's how I interpret SiteSurveyAppletConstants.HTTP_PROXY_DETECT_URL); that's not how HTTP through a proxy works. You should connect to the actual host, and set a few properties with the proxy details first.
 
arvind puppala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf,

I have updated my profile and Thanks for replying to my post. I have tested the sample application by setting the below properties but still it's behaving it in the same way.

System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", httpHostName);
System.setProperty("http.proxyPort", "" + httpPort);

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic