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