• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is Proxy Authenticated or not in Applet

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic