cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: How to get Subject (user) from jaxrs context
Date Tue, 11 Mar 2014 10:15:52 GMT
Thanks, yes, LoginSecurityContext has this method; it needs to be cast 
from the internal CXF SecurytContext, this can be obtained as follows:

SecurityContext sc = mc.get(SecurityContext.class);

Cheers, Sergey


On 11/03/14 10:05, Colm O hEigeartaigh wrote:
> You can cast the mc.getSecurityContext() to a LoginSecurityContext (if this
> is applicable). This has a "getSubject()" method.
>
> Colm.
>
>
> On Tue, Mar 11, 2014 at 6:09 AM, XiLai Dai <xldai@talend.com> wrote:
>
>> Hi,
>>
>> We have a REST service impl class and just want to get the authentication
>> user info from the impl of one operation, it looks like:
>>
>> public class FlowManagementServiceImpl implements FlowManagementService {
>>      @Context
>> private org.apache.cxf.jaxrs.ext.MessageContext mc;
>>
>>      @GET
>>      @Path("/deploy/{flowName}/{flowVersion}")
>>      @Produces("text/plain")
>>      public Response deployFlow(@PathParam("flowName") String flowName,
>>              @PathParam("flowVersion") String flowVersion) {
>>      ......
>>      System.out.println("role: " +
>> mc.getSecurityContext().getUserPrincipal().getName());
>>      ......
>> }
>> }
>>
>> Seems only the principlal name can be retrieved from MessageContext, how
>> to get the Subject (user) name from the operation? Thanks!
>> (CXF 2.7.10 used)
>>
>> Thanks.
>> Xilai Dai
>>
>
>
>


Mime
View raw message