users@jersey.java.net

Re: [Jersey] Basic Auth on the client side

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 28 Jan 2009 17:44:51 +0100

On Jan 28, 2009, at 5:22 PM, Matthieu Riou wrote:

> Hi,
>
> I was wondering what were the options to do Basic Auth with the
> Jersey client in 1.0.1. I've seen an e-mail thread dating back from
> November where a patch had been proposed but it doesn't seem it's
> been integrated in 1.0.1 or maybe in a different form. I've been
> staring at the Javadoc for quite some time but couldn't find
> anything that looked like auth methods.
>

Currently the only way is to use the java.net.Authenticator [1]
because by default HttpURLConnection is utilized. Which is not ideal
because it is a static, per JVM, configuration.

We are working on support using the Apache HTTP client where basic
auth can be set up on a per client basis. I hope this can make the
1.0.2 release, i just need to work on the implementation to ensure it
is thread safe.

Paul.

[1] http://java.sun.com/javase/6/docs/technotes/guides/net/http-auth.html