hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Claassen <ma...@donnell.com>
Subject RE: HTTPClient ntlm smart card
Date Tue, 26 Jun 2012 19:07:35 GMT
I am jumping in on this a bit late, but this sounds similar to a problem I had.  What I did
was to use
HttpsURLConnection.getDefaultSSLSocketFactory() and wrap that with the HttpClient's socket
factory class.  This way, when HttpClient
connects a socket, it uses the "native" one.  (In my case, I was using Webstart, and needed
to access the one it used.)  

You may need to establish an HttpsURLConnection (and throw it away) first to initialize the
connection.  I don't know if that is
necessary now or not.  (There was a bug in early Java 6 that necessitated this.)

It is a bit tedious to do this in HttpClient 4.1, and you end up just copying lots of code
since there are private variables that
get in the way.  In 4.2, there is a constructor to HttpClient's socket factory that will wrap
a socket factory for you.

-----Original Message-----
From: Matthew Young [mailto:matthew.young@forsakringskassan.se] 
Sent: Tuesday, June 26, 2012 11:20 AM
To: httpclient-users@hc.apache.org
Subject: Re: HTTPClient ntlm smart card


Tested the following:
  String url = "http://www.google.com/", proxy = "<our proxy>", port = "8080";
  URL server = new URL(url);
  Properties systemProperties = System.getProperties();
  systemProperties.setProperty("http.proxyHost", proxy);
  systemProperties.setProperty("http.proxyPort", port);
  HttpURLConnection connection = (HttpURLConnection) server.openConnection();
  connection.connect();
  BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));

  String inputLine;
  while ((inputLine = in.readLine()) != null) 
    System.out.println(inputLine);
  in.close();

And just like you said it works.  Will look at the HttpURLConnection code. 
Thanks
--
View this message in context: http://old.nabble.com/HTTPClient-ntlm-smart-card-tp34070660p34073158.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message