cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: basic auth with JaxWsProxyFactoryBean
Date Fri, 31 Aug 2007 16:52:03 GMT
On Thursday 30 August 2007, Chris Campbell wrote:
> I want to setup basic auth, using an AuthInterceptor on the server
> side, as discussed in another thread.
>
> I am using JaxWsProxyFactoryBean on client side, simple frontend
> style, but it is unclear to me how to put the AuthorizationPolicy
> object into the request.

There are basically three ways:

Standard JAX-WS way:
BindingProvider bp = (BindingProvider)port;
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "BJ");
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd");

(note the keys MUST be the BindingProvider keys, not just "username")


Purely CXF way per request: 
AuthorizationPolicy policy = new AuthorizationPolicy ();
policy.setUsername("...");
policy.setPassword("...");
BindingProvider bp = (BindingProvider)port;
bp.getRequestContext().put(AuthorizationPolicy.class.getName(), policy);


Purely CXF way to control the conduit directly:
Client client = ClientProxy.getClient(greeter);
HTTPConduit httpConduit = (HTTPConduit)client.getConduit();
AuthorizationPolicy policy = new AuthorizationPolicy();
policy.setUserName("BJ2");
policy.setPassword("pswd");
httpConduit.setAuthorization(policy);

-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

Mime
View raw message