users@jersey.java.net

Re: [Jersey] Jersey Client and Basic Authentication

From: Alex Sherwin <alex.sherwin_at_acadiasoft.com>
Date: Tue, 18 Nov 2008 16:36:03 -0500

Hi Jorge,
Do you think you would be able to share your implementation? I'm looking to
use BASIC authentication from within the Jersey client. I've been toying
with apaches http connection lib (both stable 3.1 and beta 4.0 versions)
without much success. I can do basic auth using that client only, but I
very much dislike the client as a whole and I'm not really sure how to "plug
it in" to Jersey in the same manner that you have.



On Mon, Nov 10, 2008 at 1:03 PM, Jorge L Williams <Jorge.Williams_at_inl.gov>wrote:

>
> Hey guys,
>
> I've added support for Basic, Digest, and NTLM authentication and
> preemptive authentication by adding an Apache HTTPClient backend to Jersey
> client. Cookie handling is also supported -- though off by default. This
> also fixes other errors associated with URLConnections like not being able
> to retrieve 401 error codes. Also, HTTPClient seems perform better than
> URLConnection -- though I haven't done any real benchmarking -- it does feel
> snappier! As as side note, I've also modified the WADL2Java
> implementation so that it uses Jersey client as a backend -- as a way of
> providing support for these features from a generated WADL client.
>
> I took the approach of simply creating a root ClientHandler and
> ClientConfig class (under impl). I didn't touch any of the Jersey Client
> API code. Basically the usage looks something like this:
>
>
>
> DefaultHttpClientConfig clientConfig = new DefaultHttpClientConfig();
>
> //
> // Set the credentials (realm, host, port, username, password)
> //
> clientConfig.setCredentials (null, "host.inl.gov", 443, username,
> password);
> clientConfig.getProperties().put
> (HttpClientConfig.PROPERTY_PREEMPTIVE_AUTHENTICATION, Boolean.TRUE);
>
> Client c = new Client (new HttpClientHandler(), config);
>
>
>
> I've been testing my implementation for a week or so and things seems
> stable. Unfortunately, I'm on my way out the door now and I'll be away
> from work for the rest of the week. I won't be able to get a patch to you
> guys till sometime next week at the earliest. Figured I'd mentioned it now
> since there seems to be interests in some of these features.
>
> -jOrGe W.
>
>
>
> *Jeff Schmidt <jas_at_535consulting.com>*
>
> 11/10/2008 09:48 AM
> Please respond to
> users_at_jersey.dev.java.net
>
> To
> users_at_jersey.dev.java.net
> cc
> Subject
> Re: [Jersey] Jersey Client and Basic Authentication
>
>
>
>
> This would be great! :)
>
> Might I be so bold as to hope for preemptive authentication and cookie
> handling in order to maintain an HTTP session?
>
> Thanks!
>
> Jeff
> --
> Jeff Schmidt
>
> On Nov 10, 2008, at 1:38 AM, Paul Sandoz wrote:
>
>
> On Nov 8, 2008, at 6:26 PM, Mike Jones wrote:
>
> Hi Paul,
>
> Is it worth revisiting Basic and Digest authentication support for the
> client now that 1.0 is released?
>
> Yes.
>
>
> I'd be more than happy to try and
> help out.
>
>
> Great. How do you want to proceed? Do you want to send a patch?
>
> Paul.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: *users-unsubscribe_at_jersey.dev.java.net*<users-unsubscribe_at_jersey.dev.java.net>
> For additional commands, e-mail: *users-help_at_jersey.dev.java.net*<users-help_at_jersey.dev.java.net>
>
>
>
>
>
>


-- 
Alexander Sherwin