How to make HttpClient use Kerberos?

Nicolas Raoul picture Nicolas Raoul · Jun 18, 2012 · Viewed 12.5k times · Source

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?

Answer

Yves Martin picture Yves Martin · Jun 19, 2012

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.