users@jersey.java.net

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

From: Rabick, Mark A (IS) <"Rabick,>
Date: Thu, 30 Apr 2009 16:46:30 -0500

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>