users@jersey.java.net

RE: [Jersey] HTTP Basic Authentication (header encoding)

From: Rabick, Mark A (IS) <"Rabick,>
Date: Thu, 30 Apr 2009 18:08:25 -0500

I'm getting an NPE in Line 67 of HTTPBasicAuthFilter if I try it as you
have it below:

                HTTPBasicAuthFilter authFilter = new
HTTPBasicAuthFilter("weblogic","weblogic");
                client = Client.create();
                client.addFilter(authFilter);

...

        
nodeResource.type(MediaType.APPLICATION_XML)
        
.accept(MediaType.APPLICATION_XML)
                                        .post(nodeV1);

--mark

Ps. I noticed an issue from 4/24 to fix the internal encoding .. I'm
running the 1.0.3 release. Maybe I don't have the fix?


_______________________________________________
Mark A. Rabick - Software Engineer
Em: mark.rabick_at_ngc.com

 

> -----Original Message-----
> From: Pavel.Bucek_at_Sun.COM [mailto:Pavel.Bucek_at_Sun.COM]
> Sent: Thursday, April 30, 2009 5:41 PM
> To: users_at_jersey.dev.java.net
> Subject: Re: [Jersey] HTTP Basic Authentication (header encoding)
>
>
> Hello,
>
> see MainTest.java in https-clientserver-grizzly sample:
>
> ==========
>
> Client c = Client.create();
>
> // client basic auth demonstration
> c.addFilter(new HTTPBasicAuthFilter("user", "password"));
>
> System.out.println("Client: GET " + Server.BASE_URI);
>
> WebResource r = c.resource(Server.BASE_URI);
>
> String page = (String) r.path("/").get(String.class);
>
> ==========
>
> And how this works? When you create WebResource instance, it
> has reference to the original client and every request is
> passed through it (so filter will be used for all WebResource
> instances created from that particular Client).
>
> Or you can set filter even on WebResource instance:
>
> ==========
> Client c = Client.create();
>
> WebResource r = c.resource(Server.BASE_URI);
>
> r.addFilter(new HTTPBasicAuthFilter("user", "password"));
>
> String page = (String) r.path("/").get(String.class);
> ==========
>
>
> Hope it helps.
>
> Pavel
>
>
> Rabick, Mark A (IS) wrote:
> > I forgot to prefix the header with "Basic " but my I'm trying to
> > figure out how to use the HTTPBasicAuthFilter and
> ClientHandler code
> > but I can't find an example:
> >
> >
> > HTTPBasicAuthFilter authFilter = new
> > HTTPBasicAuthFilter("weblogic","weblogic");
> > ClientConfig cc = new DefaultClientConfig();
> > Client c = Client.create(cc);
> > c.addFilter(authFilter);
> > webResource =
> > c.resource("http://localhost:7001/i3/cnodb/cdal/rest");
> >
> > but I'm not sure how this all harnesses together...
> >
> > -mark
> >
> > _______________________________________________
> > Mark A. Rabick - Software Engineer
> > Em: mark.rabick_at_ngc.com
> >
> >
> >
> >
> > ________________________________
> >
> > From: Craig.McClanahan_at_Sun.COM [mailto:Craig.McClanahan_at_Sun.COM]
> >
> > Sent: Thursday, April 30, 2009 4:37 PM
> > To: users_at_jersey.dev.java.net
> > Subject: Re: [Jersey] HTTP Basic Authentication (header
> > encoding)
> >
> >
> > Rabick, Mark A (IS) wrote:
> >
> > Does anyone have a code snippet for creating
> the Base64 encoded
> > user/password combination for a Jersey server configured for BASIC
> > authentication?
> >
> > In the Jersey client code, is it just:
> >
> > nodeBaseResource.header("Authorization",
> >
> "base64encoded_userid:password").type("application/xml").post(nodeV1);
> >
> > ... for a post request?
> >
> > Close. The header value has to be slightly different, though:
> >
> >
> >
> > nodeBaseResource.header("Authorization", "Basic " +
> >
> "base64encoded_userid:password").type("application/xml").post(nodeV1);
> >
> > Craig
> >
> >
> > --mark
> > _______________________________________________
> > Mark A. Rabick
> > Software Engineer
> > Northrop Grumman - Integrated Mission Systems
> > (IS/DSD/IMS)
> > 3200 Samson Way
> > Bellevue, NE 68123
> > Ph: (402) 293-7091
> > Em: mark.rabick_at_ngc.com
> > Remember PFC Ross A. McGinnis...
> > http://www.army.mil/medalofhonor/McGinnis/index.html
> > <http://www.army.mil/medalofhonor/McGinnis/index.html>
> > ... MA2 Michael A. Monsoor, Lt. Michael P. Murphy, Cpl.
> > Jason Dunham, SFC Paul Ray Smith and the rest...
> > http://www.cmohs.org/recipients/most_recent.htm
> > <http://www.cmohs.org/recipients/most_recent.htm>
> >
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> > For additional commands, e-mail: users-help_at_jersey.dev.java.net
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>