Look at the last test here:

http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenTest.java?view=markup

((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME,
"Alice");

Colm.


On Tue, Sep 24, 2013 at 10:33 AM, Thomas Manson
<[email protected]>wrote:

> Hi Colm,
>
>   I'm back working on this subject (was on pause as I was working for other
> clients)
>
>   I've checked out the SVN repo you gave me, and I've looked through the
> samples configurations (client.xml) and I can't find anything appropriate.
>
>  In the UT (Username Token I guess), the username is always provided in the
> configuration file.
>  The saml/x509 configuration still refers to Alice.properties...
>
>
>   In my case, the username shouldn't appear in the configuration files, as
> I need to use the J2EE Principal as login, and call the webservice to
> authenticate the user.
>
>   Could you point me to the right direction  ?
>
> Thomas.
>
>
>
>
>
> On Sat, Jul 13, 2013 at 1:45 AM, Thomas Manson
> <[email protected]>wrote:
>
> > Thanks, it will surely help a lot :)
> >
> > Thomas.
> >
> >
> > On Fri, Jul 12, 2013 at 6:05 PM, Colm O hEigeartaigh <
> [email protected]>wrote:
> >
> >> Please take a look at the tests here:
> >>
> >>
> >>
> http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-security-examples/
> >>
> >> Colm.
> >>
> >>
> >> On Fri, Jul 12, 2013 at 4:22 PM, Thomas Manson
> >> <[email protected]>wrote:
> >>
> >> > Do you have any other pointer that this page :
> >> >
> >> > cxf.apache.org/docs/ws-securitypolicy.html
> >> >
> >> > it's way to short for me as documentation to build something that
> work.
> >> > When I read the properties described, I feel there's a mix between
> >> server
> >> > side properties (which I'm not interested as I'm just implementing a
> >> > client)... + it starts with extra properties... where are the basic
> >> ones?
> >> >
> >> > what would help is a full example of the code of a client.
> >> >
> >> > I'm quite lost ;)
> >> >
> >> >
> >> >
> >> >
> >> > On Fri, Jul 12, 2013 at 5:09 PM, Colm O hEigeartaigh <
> >> [email protected]
> >> > >wrote:
> >> >
> >> > >
> >> > > If you follow the WS-SecurityPolicy approach then it will work, as
> >> all of
> >> > > the configuration is taken from the context rather than a properties
> >> Map.
> >> > >
> >> > > Colm.
> >> > >
> >> > >
> >> > > On Fri, Jul 12, 2013 at 4:01 PM, Thomas Manson <
> >> > [email protected]
> >> > > > wrote:
> >> > >
> >> > >>  I already does what you say as follow, but it mean one instance of
> >> the
> >> > >> client per user connected.
> >> > >>
> >> > >>
> >> > >> I've search quite some time dans didn't find a way to set something
> >> like
> >> > >> the password callback handler.
> >> > >>
> >> > >>
> >> > >>
> >> > >>  JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> >> > >>
> >> > >>     factory.setServiceClass(WorkListService.class);
> >> > >>
> >> > >>     factory.setAddress(this.endpoint);
> >> > >>
> >> > >>     //
> >> > >>
> >> >
> >>
> factory.setWsdlLocation("D:/ARTIC/SOURCE/artic/trunk/webapp/src/main/webapp/WSDL/brm.wsdl");
> >> > >>
> >> > >>     factory.setServiceName(new QName("
> >> http://services.brm.n2.tibco.com
> >> > ",
> >> > >> "WorkListService"));
> >> > >>
> >> > >>     WorkListService workListService = (WorkListService)
> >> > factory.create();
> >> > >>
> >> > >>
> >> > >>        Client client = ClientProxy.getClient(workListService);
> >> > >>
> >> > >>
> >> > >>     Map<String, Object> properties = new HashMap<String, Object>();
> >> > >>
> >> > >>     properties.put(WSHandlerConstants.ACTION          ,
> >> > >> WSHandlerConstants.USERNAME_TOKEN);
> >> > >>
> >> > >>     properties.put(WSHandlerConstants.USER            ,
> >> this.username);
> >> > >>
> >> > >>     properties.put(WSHandlerConstants.PASSWORD_TYPE   ,
> WSConstants.
> >> > >> PW_TEXT);// "PasswordDigest"
> >> > >>
> >> > >>     properties.put(WSHandlerConstants.PW_CALLBACK_REF ,
> >> > newPasswordCallbackHandler(
> >> > >> this.username, password, "password"));
> >> > >>
> >> > >>
> >> > >>     client.getOutInterceptors().add(new
> >> > WSS4JOutInterceptor(properties));
> >> > >>
> >> > >>
> >> > >> On Fri, Jul 12, 2013 at 4:36 PM, Colm O hEigeartaigh <
> >> > [email protected]
> >> > >> > wrote:
> >> > >>
> >> > >>> ou could create a CXF interceptor that sets the username on the
> fly,
> >> > >>> before the WSS4JOutInterceptor is called.
> >> > >>
> >> > >>
> >> > >>
> >> > >>
> >> > >
> >> > >
> >> > > --
> >> > > Colm O hEigeartaigh
> >> > >
> >> > > Talend Community Coder
> >> > > http://coders.talend.com
> >> > >
> >> >
> >>
> >>
> >>
> >> --
> >> Colm O hEigeartaigh
> >>
> >> Talend Community Coder
> >> http://coders.talend.com
> >>
> >
> >
>



-- 
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com

Reply via email to