You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Penmatsa, Vinay" <vi...@sap.com> on 2012/05/15 23:55:27 UTC

UsernameTokenValidator

Hi,
I just upgraded to 2.6 from 2.4.1
I had a custom UsernameTokenValidator where I override verifyDigestPassword(UsernameToken usernameToken, RequestData data).
Within that I had the following code to get access to request object.

#######
SoapMessage soapMsg = (SoapMessage)data.getMsgContext();
HttpServletRequest request = (HttpServletRequest)soapMsg.get(AbstractHTTPDestination.HTTP_REQUEST);	
#######


In 2.6, soapMsg is null. Is there any other way I can get the HTTP_REQUEST?


Regards,
Vinay



Re: UsernameTokenValidator

Posted by dhogan <di...@forgerock.com>.
I would be happy to.

Dirk



--
View this message in context: http://cxf.547215.n5.nabble.com/UsernameTokenValidator-tp5707938p5737827.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: UsernameTokenValidator

Posted by Colm O hEigeartaigh <co...@apache.org>.
Hi,

Yes I suppose all of the STS Validators should set the Message Context on
the RequestData object. Could you submit a patch?

Colm.


On Fri, Dec 13, 2013 at 4:06 PM, dhogan <di...@forgerock.com> wrote:

> I am running version 2.7.2 of org.apache.cxf.services.sts. I am plugging a
> org.apache.ws.security.validate.UsernameTokenValidator subclass as the
> Validator in the org.apache.cxf.sts.token.validator.UsernameTokenValidator
> class. I was hoping to store some state generated in my
> org.apache.ws.security.validate.UsernameTokenValidator instance in the
> ServletRequest, which I hoped to pull out of the RequestData instance
> passed
> to the
>
> org.apache.ws.security.validate.UsernameTokenValidator.verifyPlaintextPassword(UsernameToken,RequestData)
> method via the getMsgContext() method in the RequestData class. Yet
> getMsgContext() always returns null. I notice that the
> org.apache.cxf.sts.token.validator.UsernameTokenValidator does not populate
> this field by using the getWebServiceContext().getMessageContext() calls on
> the TokenValidatorParameters instance passed to validateToken method. I
> noticed that the SAMLTokenValidator does not do this either. Is this a bug
> (for which I could submit a patch?), or am I missing something?
>
> The PhaseInterceptorChain.getCurrentMessage() work-around works.
>
> Dirk
>
>
>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/UsernameTokenValidator-tp5707938p5737823.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>



-- 
Colm O hEigeartaigh

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

Re: UsernameTokenValidator

Posted by dhogan <di...@forgerock.com>.
I am running version 2.7.2 of org.apache.cxf.services.sts. I am plugging a
org.apache.ws.security.validate.UsernameTokenValidator subclass as the
Validator in the org.apache.cxf.sts.token.validator.UsernameTokenValidator
class. I was hoping to store some state generated in my
org.apache.ws.security.validate.UsernameTokenValidator instance in the
ServletRequest, which I hoped to pull out of the RequestData instance passed
to the
org.apache.ws.security.validate.UsernameTokenValidator.verifyPlaintextPassword(UsernameToken,RequestData)
method via the getMsgContext() method in the RequestData class. Yet
getMsgContext() always returns null. I notice that the
org.apache.cxf.sts.token.validator.UsernameTokenValidator does not populate
this field by using the getWebServiceContext().getMessageContext() calls on
the TokenValidatorParameters instance passed to validateToken method. I
noticed that the SAMLTokenValidator does not do this either. Is this a bug
(for which I could submit a patch?), or am I missing something?

The PhaseInterceptorChain.getCurrentMessage() work-around works.

Dirk




--
View this message in context: http://cxf.547215.n5.nabble.com/UsernameTokenValidator-tp5707938p5737823.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: UsernameTokenValidator

Posted by Daniel Kulp <dk...@apache.org>.
You can get the current message via:

PhaseInterceptorChain.getCurrentMessage()

That can work around the issue until it can be fixed.   That said, a  patch 
that fixes the issue would be quite welcome.

Dan




On Tuesday, May 15, 2012 05:55:27 PM Penmatsa, Vinay wrote:
> Hi,
> I just upgraded to 2.6 from 2.4.1
> I had a custom UsernameTokenValidator where I override
> verifyDigestPassword(UsernameToken usernameToken, RequestData data).
> Within that I had the following code to get access to request object.
> 
> #######
> SoapMessage soapMsg = (SoapMessage)data.getMsgContext();
> HttpServletRequest request =
> (HttpServletRequest)soapMsg.get(AbstractHTTPDestination.HTTP_REQUEST);
> #######
> 
> 
> In 2.6, soapMsg is null. Is there any other way I can get the
> HTTP_REQUEST?
> 
> 
> Regards,
> Vinay
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


RE: UsernameTokenValidator

Posted by "Penmatsa, Vinay" <vi...@sap.com>.
Ah! I was indeed using WSS4JInInterceptor. I was adding interceptors manually. Now I'm trying to use the policy framework. So, this time it hit the UsernameTokenInterceptor.
So, is the fix to override the UsernameTokenInterceptor and populate the request data context?

Thanks,
Vinay


-----Original Message-----
From: Colm O hEigeartaigh [mailto:coheigea@apache.org] 
Sent: Wednesday, May 16, 2012 4:34 AM
To: users@cxf.apache.org
Subject: Re: UsernameTokenValidator

Are you sure that you are using the UsernameTokenInterceptor instead
of the WSS4JInInterceptor? The reason I ask is that I don't see any
change in how the RequestData is constructed in the
UsernameTokenInterceptor in 2.4.1:

http://svn.apache.org/viewvc/cxf/tags/cxf-2.4.1/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java?view=markup

In any case the RequestData should probably be setting the message
context here as well.

Colm.

On Tue, May 15, 2012 at 11:05 PM, Penmatsa, Vinay
<vi...@sap.com> wrote:
> It might be that UsernameTokenInterceptor is not populating the RequestData's msgcontext.
> Is this deliberate?
> UsernameTokenInterceptor.getPrincipal() line #178
>
> -Vinay
>
>
>
> -----Original Message-----
> From: Penmatsa, Vinay [mailto:vinay.penmatsa@sap.com]
> Sent: Tuesday, May 15, 2012 5:55 PM
> To: users@cxf.apache.org
> Subject: UsernameTokenValidator
>
> Hi,
> I just upgraded to 2.6 from 2.4.1
> I had a custom UsernameTokenValidator where I override verifyDigestPassword(UsernameToken usernameToken, RequestData data).
> Within that I had the following code to get access to request object.
>
> #######
> SoapMessage soapMsg = (SoapMessage)data.getMsgContext();
> HttpServletRequest request = (HttpServletRequest)soapMsg.get(AbstractHTTPDestination.HTTP_REQUEST);
> #######
>
>
> In 2.6, soapMsg is null. Is there any other way I can get the HTTP_REQUEST?
>
>
> Regards,
> Vinay
>
>



-- 
Colm O hEigeartaigh

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

Re: UsernameTokenValidator

Posted by Colm O hEigeartaigh <co...@apache.org>.
Are you sure that you are using the UsernameTokenInterceptor instead
of the WSS4JInInterceptor? The reason I ask is that I don't see any
change in how the RequestData is constructed in the
UsernameTokenInterceptor in 2.4.1:

http://svn.apache.org/viewvc/cxf/tags/cxf-2.4.1/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java?view=markup

In any case the RequestData should probably be setting the message
context here as well.

Colm.

On Tue, May 15, 2012 at 11:05 PM, Penmatsa, Vinay
<vi...@sap.com> wrote:
> It might be that UsernameTokenInterceptor is not populating the RequestData's msgcontext.
> Is this deliberate?
> UsernameTokenInterceptor.getPrincipal() line #178
>
> -Vinay
>
>
>
> -----Original Message-----
> From: Penmatsa, Vinay [mailto:vinay.penmatsa@sap.com]
> Sent: Tuesday, May 15, 2012 5:55 PM
> To: users@cxf.apache.org
> Subject: UsernameTokenValidator
>
> Hi,
> I just upgraded to 2.6 from 2.4.1
> I had a custom UsernameTokenValidator where I override verifyDigestPassword(UsernameToken usernameToken, RequestData data).
> Within that I had the following code to get access to request object.
>
> #######
> SoapMessage soapMsg = (SoapMessage)data.getMsgContext();
> HttpServletRequest request = (HttpServletRequest)soapMsg.get(AbstractHTTPDestination.HTTP_REQUEST);
> #######
>
>
> In 2.6, soapMsg is null. Is there any other way I can get the HTTP_REQUEST?
>
>
> Regards,
> Vinay
>
>



-- 
Colm O hEigeartaigh

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

RE: UsernameTokenValidator

Posted by "Penmatsa, Vinay" <vi...@sap.com>.
It might be that UsernameTokenInterceptor is not populating the RequestData's msgcontext.
Is this deliberate?
UsernameTokenInterceptor.getPrincipal() line #178

-Vinay



-----Original Message-----
From: Penmatsa, Vinay [mailto:vinay.penmatsa@sap.com] 
Sent: Tuesday, May 15, 2012 5:55 PM
To: users@cxf.apache.org
Subject: UsernameTokenValidator

Hi,
I just upgraded to 2.6 from 2.4.1
I had a custom UsernameTokenValidator where I override verifyDigestPassword(UsernameToken usernameToken, RequestData data).
Within that I had the following code to get access to request object.

#######
SoapMessage soapMsg = (SoapMessage)data.getMsgContext();
HttpServletRequest request = (HttpServletRequest)soapMsg.get(AbstractHTTPDestination.HTTP_REQUEST);	
#######


In 2.6, soapMsg is null. Is there any other way I can get the HTTP_REQUEST?


Regards,
Vinay