You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by esmok <ds...@gmail.com> on 2008/10/08 09:10:41 UTC

Access username token from skelton

Hi,
I'm developing some web services using cxf currently. I need to access
username in ws-security usernamtoken from skelton. Is there a way to do
that.

Thanks
-- 
View this message in context: http://www.nabble.com/Access-username-token-from-skelton-tp19873466p19873466.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Access username token from skelton

Posted by Glen Mazza <gl...@gmail.com>.
Use JAX-WS handlers[1] or Service-side, use the Provider interface to work
with the raw XML.  Also note Kumar Jayanti's blog entry, listed at the
bottom of [1]--I believe WebServiceContext is another option for you.

HTH,
Glen

[1] http://www.jroller.com/gmazza/entry/using_the_opensaml_library_in


esmok wrote:
> 
> Hi,
> I'm developing some web services using cxf currently. I need to access
> username in ws-security usernamtoken from skelton. Is there a way to do
> that.
> 
> Thanks
> 

-- 
View this message in context: http://www.nabble.com/Access-username-token-from-skelton-tp19873466p19880904.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Access username token from skelton

Posted by esmok <ds...@gmail.com>.
Thanks for the tip.
I tried to use the WebServiceContext. But it seems that from service
WebServiceContext is injected but MessageContext is not set (it is null). 

Here is the code I use.

@WebService
public class MyService implements ServicePortType {

    @Resource
    private WebServiceContext context;

    @WebMethod
    public ResponseType send(@WebParam(partName = "Parameters", name =
"RequestElement")
    RequestType parameters) throws WSError {
         try {
            MessageContext ctx = (MessageContext)
context.getMessageContext();
            List recv = (List)ctx.get("RECV_RESULTS");
            WSHandlerResult wsResult = (WSHandlerResult)recv.get(0);
            WSSecurityEngineResult wsseResult =
(WSSecurityEngineResult)wsResult.getResults().get(0);
            Principal principal =
(Principal)wsseResult.get(WSSecurityEngineResult.TAG_PRINCIPAL);

            principal.getName();

        } catch (Exception e) {
            e.printStackTrace();
        }
       
        ResponseElement response = new ResponseElement();
        return response;
    }
}

In here a null poiter exception is thrown from line "List recv =
(List)ctx.get("RECV_RESULTS");"

So what I did was use the ThreadLocal to store the usernametoken in
CallbackHandler class and access it from service class. It is ok for the
moment but would be greate if context can be used.
I'm using CXF with mule 2.0.2, so this may be an issue with mule. I posted
it in their forum as well.
Anyway many thanks for lighting my path.
-- 
View this message in context: http://www.nabble.com/Access-username-token-from-skelton-tp19873466p19911511.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Access username token from skelton

Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday 08 October 2008, esmok wrote:
> Hi,
> I'm developing some web services using cxf currently. I need to access
> username in ws-security usernamtoken from skelton. Is there a way to
> do that.
>
> Thanks

If you inject in the WebServiceContext into your impl, you can get the 
WSS4J results vector from it.   From that, you can grab all the 
ws-security information that you want.

-- 
J. Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog