users@jersey.java.net

Re: [Jersey] Jersey Client and Basic Authentication

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 20 Aug 2008 15:03:38 +0200

Hi Lars, Mike,

Unfortunately this is not implemented and you need to do it yourself. It
is something i want to do but do not currently have the time to
implement it. Contributions most welcome!

The right place for this is to support client side filters for specific
auth needs. Such filter instances can be added to the Client and
utilized for every WebResource created from that Client, or added to a
WebResource itself.

Paul.

Lars Tackmann wrote:
> On Wed, Aug 20, 2008 at 12:45 PM, Mike Jones <mike.a.jones_at_gmail.com> wrote:
>> Hello
>>
>> I'm using Jersey with Spring security and I'm in the process of
>> creating some tests that use embedded Jetty and the Jersey client. I
>> need to perform some basic authentication with the client - do I need
>> to encode the credentials in Base64 myself and add them to the headers
>> in the jersey client? Am I missing some nice (and probably obvious)
>> helper methods for this?
>
> I have also been on the lookout for this, but have not found it.
> Currently I simply use
>
> public static String encode(String username, String password) {
> final String credentials = username + ":" + password;
> BASE64Encoder encoder = new sun.misc.BASE64Encoder();
> return encoder.encode(credentials.getBytes());
> }
>
> you can also use the encoder from commons-digest if you want to escape
> the Sun compile warnings.
>
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109