You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by patch_78 <pa...@hotmail.com> on 2014/08/27 21:19:58 UTC
Two wsse:UsernameToken in a request with different wsse:Username
Hi,
I do not understand why my soap request to web service containing two
wsse:UsernameToken with different wsse:Username as below. The "svein@yyy.no"
is the first user who login, while the "pth999@xxx.no" is the current user
<wsse:UsernameToken wsu:Id="UsernameToken-2094ECD36680474492140916671301035"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>svein@yyy.no</wsse:Username>
<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">liO&%KL</wsse:Password>
</wsse:UsernameToken>
<wsse:UsernameToken
wsu:Id="UsernameToken-3A2F8DC1BC22CCE9451409166713057101">
<wsse:Username>pth999@xxx.no</wsse:Username>
<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">liO&%KL</wsse:Password>
</wsse:UsernameToken>
This is code where I add wsse:UsernameToken into the request.
private void initUserManagementPort() {
String username = getUserSession().getUserName(); // get the value for
<wsse:Username>
service = new UserManagementService();
port = service.getUserManagementPort();
Map ctx = ((BindingProvider) port).getRequestContext();
ctx.put("ws-security.username", username);
ctx.put("ws-security.callback-handler",
ClientCallbackHandler.class.getName());
}
--
View this message in context: http://cxf.547215.n5.nabble.com/Two-wsse-UsernameToken-in-a-request-with-different-wsse-Username-tp5748229.html
Sent from the cxf-user mailing list archive at Nabble.com.
RE: Two wsse:UsernameToken in a request with different
wsse:Username
Posted by patch_78 <pa...@hotmail.com>.
Hi,
Do you mean only set
((BindingProvider)proxy).getRequestContext().put("thread.local.request.context",
"true") ? Unfortunately it does not work.
The first wsse:Username generated is always sent to WSP. This setting is not
taken into account.
((BindingProvider) port).getRequestContext().put("ws-security.username",
"CURRENT USER ID");
regards,
Patcharee
--
View this message in context: http://cxf.547215.n5.nabble.com/Two-wsse-UsernameToken-in-a-request-with-different-wsse-Username-tp5748229p5748316.html
Sent from the cxf-user mailing list archive at Nabble.com.
RE: Two wsse:UsernameToken in a request with different
wsse:Username
Posted by patch_78 <pa...@hotmail.com>.
Actually I got the problem because only one SBIClient had been used for all
requests. After I used SBIClient for each user session, the problem was
gone.
Thanks for your reply.
--
View this message in context: http://cxf.547215.n5.nabble.com/Two-wsse-UsernameToken-in-a-request-with-different-wsse-Username-tp5748229p5749137.html
Sent from the cxf-user mailing list archive at Nabble.com.
RE: Two wsse:UsernameToken in a request with different wsse:Username
Posted by Andrei Shakirin <as...@talend.com>.
Hi,
Could you try to create a new client proxy per web request (not share proxy between different web requests) and see that effect disappears or not?
Regards,
Andrei.
> -----Original Message-----
> From: patch_78 [mailto:patch_78@hotmail.com]
> Sent: Sonntag, 31. August 2014 20:52
> To: users@cxf.apache.org
> Subject: RE: Two wsse:UsernameToken in a request with different
> wsse:Username
>
> Hi,
>
> FYI my client will get a usernametoken from STS before sending request to WSP
> according to the policy. There is one thing I can notice is in the client
> CallbackHandler.handle which is called before sending request to the STS.
>
> WSPasswordCallback pc = (WSPasswordCallback) callbacks[i]; pc.getIdentifier();
> ---> This is always the first user login.
>
> Even this setting is occured before the client CallbackHandler.handle
>
> ((BindingProvider) port).getRequestContext().put("ws-security.username",
> "CURRENT USER ID");
>
> Any suggestions?
>
> regards,
> Patcharee
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Two-wsse-
> UsernameToken-in-a-request-with-different-wsse-Username-
> tp5748229p5748322.html
> Sent from the cxf-user mailing list archive at Nabble.com.
RE: Two wsse:UsernameToken in a request with different
wsse:Username
Posted by patch_78 <pa...@hotmail.com>.
Hi,
FYI my client will get a usernametoken from STS before sending request to
WSP according to the policy. There is one thing I can notice is in the
client CallbackHandler.handle which is called before sending request to the
STS.
WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
pc.getIdentifier(); ---> This is always the first user login.
Even this setting is occured before the client CallbackHandler.handle
((BindingProvider) port).getRequestContext().put("ws-security.username",
"CURRENT USER ID");
Any suggestions?
regards,
Patcharee
--
View this message in context: http://cxf.547215.n5.nabble.com/Two-wsse-UsernameToken-in-a-request-with-different-wsse-Username-tp5748229p5748322.html
Sent from the cxf-user mailing list archive at Nabble.com.
RE: Two wsse:UsernameToken in a request with different wsse:Username
Posted by Andrei Shakirin <as...@talend.com>.
Hi,
I think this can be concurrency issue.
Try to activate thread local setting in request context: ((BindingProvider)proxy).getRequestContext().put("thread.local.request.context", "true");
or create new client proxy per thread (according to the JAX-WS spec, the client proxies are NOT thread safe).
Refer CXF FAQ for details: http://cxf.apache.org/faq.html#FAQ-AreJAX-WSclientproxiesthreadsafe?
Regards,
Andrei.
> -----Original Message-----
> From: patch_78 [mailto:patch_78@hotmail.com]
> Sent: Samstag, 30. August 2014 09:51
> To: users@cxf.apache.org
> Subject: RE: Two wsse:UsernameToken in a request with different
> wsse:Username
>
> Hi,
>
> Yes. My client is a web application. The initUserManagementPort() is a method
> of a SESSION object which is created for each user login to the web application.
> It seems the <wsse:UsernameToken> of the FIRST login user is cached somehow
> and is always sent to the web service provider.
>
> Do you have any ideas how I can fix this?
>
> Patcharee
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Two-wsse-
> UsernameToken-in-a-request-with-different-wsse-Username-
> tp5748229p5748310.html
> Sent from the cxf-user mailing list archive at Nabble.com.
RE: Two wsse:UsernameToken in a request with different
wsse:Username
Posted by patch_78 <pa...@hotmail.com>.
Hi,
Yes. My client is a web application. The initUserManagementPort() is a
method of a SESSION object which is created for each user login to the web
application. It seems the <wsse:UsernameToken> of the FIRST login user is
cached somehow and is always sent to the web service provider.
Do you have any ideas how I can fix this?
Patcharee
--
View this message in context: http://cxf.547215.n5.nabble.com/Two-wsse-UsernameToken-in-a-request-with-different-wsse-Username-tp5748229p5748310.html
Sent from the cxf-user mailing list archive at Nabble.com.
RE: Two wsse:UsernameToken in a request with different wsse:Username
Posted by Andrei Shakirin <as...@talend.com>.
Hi,
Interesting ... could this be the case that initUserManagementPort() is called multiple times with different user contexts?
Regards,
Andrei.
> -----Original Message-----
> From: patch_78 [mailto:patch_78@hotmail.com]
> Sent: Mittwoch, 27. August 2014 21:20
> To: users@cxf.apache.org
> Subject: Two wsse:UsernameToken in a request with different wsse:Username
>
> Hi,
>
> I do not understand why my soap request to web service containing two
> wsse:UsernameToken with different wsse:Username as below. The
> "svein@yyy.no"
> is the first user who login, while the "pth999@xxx.no" is the current user
>
> <wsse:UsernameToken wsu:Id="UsernameToken-
> 2094ECD36680474492140916671301035"
> xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
> wssecurity-secext-1.0.xsd"
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
> wssecurity-utility-1.0.xsd">
> <wsse:Username>svein@yyy.no</wsse:Username>
> <wsse:Password
> Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-
> token-profile-1.0#PasswordText">liO&%KL</wsse:Password>
> </wsse:UsernameToken>
> <wsse:UsernameToken
> wsu:Id="UsernameToken-3A2F8DC1BC22CCE9451409166713057101">
> <wsse:Username>pth999@xxx.no</wsse:Username>
> <wsse:Password
> Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-
> token-profile-1.0#PasswordText">liO&%KL</wsse:Password>
> </wsse:UsernameToken>
>
> This is code where I add wsse:UsernameToken into the request.
>
> private void initUserManagementPort() {
> String username = getUserSession().getUserName(); // get the value
> for <wsse:Username>
> service = new UserManagementService();
> port = service.getUserManagementPort();
>
> Map ctx = ((BindingProvider) port).getRequestContext();
> ctx.put("ws-security.username", username);
> ctx.put("ws-security.callback-handler",
> ClientCallbackHandler.class.getName());
>
> }
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Two-wsse-
> UsernameToken-in-a-request-with-different-wsse-Username-tp5748229.html
> Sent from the cxf-user mailing list archive at Nabble.com.