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.
--
Yours sincerely
Lars Tackmann