cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <>
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 ();
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();

J. Daniel Kulp
Principal Engineer
P: 781-902-8727    C: 508-380-7194

View raw message