14

HttpClient is a Java library to browse websites.
I want to use it with Kerberos. The Kerberos part of HttpClient's documentation mostly says:

The best way to start is to grab the KerberosHttpClient.java file in examples and try and get it to work.

However, KerberosHttpClient.java is nowhere to be found (source, binaries, doc)
It is difficult to do anything without this file.

Where can I find KerberosHttpClient.java?
Or is there a better document explaining how to use HttpClient with Kerberos?

Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373

1 Answers1

11

In sources you will find the file ClientKerberosAuthentication.java with that example.

httpcomponents-client-4.2/httpclient/src/examples/org/apache/http/examples/client/ClientKerberosAuthentication.java

By the way, setting up Kerberos authentication requires many steps at KDC side (ActiveDirectory I guess) and HTTP server side too. I recommend you this generic server setup documentation even if targeting mod_auth_kerb, it addresses concepts and troubleshooting required to achieve the job.

Yves Martin
  • 10,217
  • 2
  • 38
  • 77
  • 10
    [Here's a link to ClientKerberosAuthentication.java](http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.2.2/httpclient/src/examples/org/apache/http/examples/client/ClientKerberosAuthentication.java) in SVN – Miles Dec 18 '12 at 03:08
  • 2
    The sample seems to be missing for the latest version 4.3.3. Anyone? – Andy Dufresne May 27 '14 at 12:15
  • 2
    @Andy, It's certainly because DefaultHttpClient used in the [ClientKerberosAuthentication](http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.2.2/httpclient/src/examples/org/apache/http/examples/client/ClientKerberosAuthentication.java) has been deprecated in version 4.3, and no new example was provided – FrankyFred Jun 03 '14 at 12:58
  • You may find this answer useful: http://stackoverflow.com/questions/21629132/httpclient-set-credentials-for-kerberos-authentication – eljeko Aug 07 '15 at 12:28