You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Chris Campbell <cc...@quaris.com> on 2007/09/04 18:22:13 UTC

Request context ?

I am using basic-auth with an Interceptor to look up user
credentials. However, in my WebService implementations I need to get
the result of that lookup.

Is there a sanctioned/best way to do this in CXF? Is there some sort
of request context that I am missing?

Re: Request context ?

Posted by Willem Jiang <ni...@iona.com>.
Hi ,

If you are want to look up the user credentials in an interceptor, you 
could use the below codes
public void handleMessage(Message message) throws Fault {
     AuthorizationPolicy policy = 
message.getContent(AuthorizationPolicy.class);
     ...
}

Willem.

Daniel Kulp wrote:
> On Tuesday 04 September 2007, Chris Campbell wrote:
>   
>> I am using basic-auth with an Interceptor to look up user
>> credentials. However, in my WebService implementations I need to get
>> the result of that lookup.
>>
>> Is there a sanctioned/best way to do this in CXF? Is there some sort
>> of request context that I am missing?
>>     
>
>
> Assuming JAX-WS, add:
>     @Resource
>     protected WebServiceContext wsContext;
> to your impl.   The context will get injected into your impl.   From 
> there, you should be able to do:
> MessageContext mc = wsContext.getMessageContext();
> mc.get(AuthorizationPolicy.class.getName());
> or:
> mc.get(BindingProvider.USER_NAME);
> or similar to pull stuff out.
>
>   

Re: Request context ?

Posted by Daniel Kulp <dk...@apache.org>.
On Tuesday 04 September 2007, Chris Campbell wrote:
> I am using basic-auth with an Interceptor to look up user
> credentials. However, in my WebService implementations I need to get
> the result of that lookup.
>
> Is there a sanctioned/best way to do this in CXF? Is there some sort
> of request context that I am missing?


Assuming JAX-WS, add:
    @Resource
    protected WebServiceContext wsContext;
to your impl.   The context will get injected into your impl.   From 
there, you should be able to do:
MessageContext mc = wsContext.getMessageContext();
mc.get(AuthorizationPolicy.class.getName());
or:
mc.get(BindingProvider.USER_NAME);
or similar to pull stuff out.

-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog