You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Sergey Beryozkin <sb...@progress.com> on 2009/07/08 17:35:27 UTC

Re: Does JAX-RS clients, WebClient or JAXRSClientFactory, support basic HTTP auth?

Hi,

I've done some initial work in this area.
Proxies and HTTP-centric clients can retrieve their underlying configuration like this :

BookStory proxy = ..
WebClient wc = ..

ClientConfiguration cfgProxy = WebClient.getConfig(proxy);
ClientConfiguration cfgWebClient = WebClient.getConfig(wc);

this underlines the fact that proxies and web clients sit on top of the shared implementation and also keeps WebClient interface 
very http-centric.

HTTPConduit hc1 = (HTTPConduit)cfgProxy.getConduit();
cfgProxy.getInInterceptors();

I might also introduce the possibility to return unmodifyable ClientConfigurations (if requested from JAXRSClientFactoryBean or from 
jaxrs:client)

Request and response contexts are also supported now but the client runtime does not do anything beyond setting them on the 
message/exchange. So at the moment only user interceptors might want to play with them. May be the core CXF interceptors might 
utilize them if some well-known properties are set.

cheers, Sergey


----- Original Message ----- 
From: "Daniel Kulp" <dk...@apache.org>
To: <us...@cxf.apache.org>
Cc: "Sergey Beryozkin" <sb...@progress.com>
Sent: Monday, June 22, 2009 8:41 PM
Subject: Re: Does JAX-RS clients, WebClient or JAXRSClientFactory, support basic HTTP auth?


>
> Sergey,
>
> Could a request/response context thing be added to the client proxies for JAX-
> RS like for the webservice clients?    That would simplify some of this as the
> properties would be exactly like the webservice clients.
>
> Dan
>
>
> On Mon June 22 2009 3:38:02 pm Sergey Beryozkin wrote:
>> Hi
>>
>> Both http-centric WebClients and proxies use JAXRSClientFactoryBean to
>> create WebClient and proxy instances. They use HTTPConduit under the
>> hood and can use all the configuration supported by HTTP conduit, to do
>> with all sorts of http and/or jetty transport details. If no spring
>> configuration location is provided initially then they will use a
>> default bus.
>> JAXRSClientFactory & Web client have factory methods which take username
>> & password, but you don't have to provide it from the code if you don't
>> want to.
>>
>> Have a look here please :
>> http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apa
>> che/cxf/systest/jaxrs/security/
>>
>> there's jaxrs-https.xml spring config, and this test :
>>
>> http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apa
>> che/cxf/systest/jaxrs/security/JAXRSHttpsBookTest.java
>>
>> no username/password is used there but you can provide the spring-config
>> plus username/password at the creation time
>>
>> Hope it helps
>>
>> Thanks, Sergey
>>
>>
>> -----Original Message-----
>> From: Gabriel Guardincerri [mailto:gguardin@gmail.com]
>> Sent: 22 June 2009 18:45
>> To: users@cxf.apache.org
>> Subject: Does JAX-RS clients, WebClient or JAXRSClientFactory, support
>> basic HTTP auth?
>>
>>
>> Hi,
>>
>> I'm using basic http authentication to authenticate REST calls. And of
>> course, on the client side I need a way to set the credentials. So, is
>> there
>> a way to do that with proxy-based or http-centric approaches that are in
>> described at
>> http://cwiki.apache.org/CXF20DOC/jax-rs.html#JAX-RS-ClientAPI
>> http://cwiki.apache.org/CXF20DOC/jax-rs.html#JAX-RS-ClientAPI ? Or any
>> other
>> way?
>>
>> Thanks,
>>
>> Gabriel
>
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog