Noted, Thanks

On Sun, Jan 25, 2015 at 2:40 PM, Johann Nallathamby <joh...@wso2.com> wrote:

> Hi Lasitha,
>
> If you talking about the REST endpoint for 3rd parties to integrate, that
> we discussed offline, for that the username should be passed with the
> request, because that comes from the first factor of authentication and is
> not done in IS.
>
> Thanks,
> Johann.
>
> On Sun, Jan 25, 2015 at 10:32 AM, Lasitha Wattaladeniya <lasit...@wso2.com
> > wrote:
>
>> Hi johan,
>>
>> Thanks for the input. The code snippet I have shown to get the logged in
>> user from stepMap is only possible if the AuthenticationContext is
>> available. But there are other scenarios AuthenticationContext is not
>> available ( Eg. REST endpoint ), that's where I get the problem
>>
>> On Sun, Jan 25, 2015 at 2:15 AM, Johann Nallathamby <joh...@wso2.com>
>> wrote:
>>
>>> CarbonContext is populated only if you login through carbon
>>> authenticators for management console login, or calling admin services.
>>>
>>> In your case the code snippet you have shown should be the way to get
>>> locally authenticated username from previous authentication steps. As you
>>> might see there is a restriction in the admin UI in choosing which locally
>>> authenticated step to pick as username. Currently we there is no way to
>>> give this in UI.
>>>
>>> So you may continue assuming that all local authenticators return same
>>> username for now and choose first local authenticator. Later we have to see
>>> how to improve this design.
>>>
>>> On Sun, Jan 25, 2015 at 1:06 AM, Lasitha Wattaladeniya <
>>> lasit...@wso2.com> wrote:
>>>
>>>> Hi devs,
>>>>
>>>> I'm trying to access the authorized user using the following code
>>>> snippet,
>>>>
>>>> String currentUser =
>>>> CarbonContext.getThreadLocalCarbonContext().getUsername();
>>>>
>>>> But .getUsername() returns null.
>>>>
>>>> The scenario is , I'm using two authenticators, basicauth => custom
>>>> authenticator (two authentication steps) . I need to access the logged in
>>>> user once it passed the basic authentication. I'm using IS 5.0.0 , Carbon
>>>> 4.2.0. I'm logging in using default username/password admin/admin. I can
>>>> access the tenantdomain and tenantID but not the username.
>>>>
>>>> I can access the username if the AuthenticationContext is available, as
>>>> the following way,
>>>>
>>>>        String username = "";
>>>>         for (int i = context.getSequenceConfig().getStepMap().size() -
>>>> 1; i >= 0; i--) {
>>>>             if
>>>> (context.getSequenceConfig().getStepMap().get(i).getAuthenticatedUser() !=
>>>> null &&
>>>>
>>>> context.getSequenceConfig().getStepMap().get(i).getAuthenticatedAutenticator()
>>>>                         .getApplicationAuthenticator() instanceof
>>>> LocalApplicationAuthenticator) {
>>>>                 username =
>>>> context.getSequenceConfig().getStepMap().get(i).getAuthenticatedUser();
>>>>                 if (log.isDebugEnabled()) {
>>>>                     log.debug("username :" + username);
>>>>                 }
>>>>                 break;
>>>>             }
>>>>         }
>>>>
>>>> But it's not possible to always access the user from the
>>>> authenticationContext. Anyone knows how to get this done through
>>>> CarbonContext ?
>>>>
>>>> Found this thread [1] about the same topic but no luck.
>>>>
>>>> [1].
>>>> http://wso2-oxygen-tank.10903.n7.nabble.com/Dev-PrivilegedCarbonContext-getThreadLocalCarbonContext-getUsername-returns-null-td73948.html
>>>>
>>>> --
>>>> Lasitha Wattaladeniya
>>>> Software Engineer
>>>> WSO2, Inc. | http://wso2.com
>>>> lean. enterprise. middleware
>>>>
>>>> Mobile : +94719397528
>>>> Blog : techreadme.blogspot.com
>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> Dev@wso2.org
>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>
>>>>
>>>
>>>
>>> --
>>> Thanks & Regards,
>>>
>>> *Johann Dilantha Nallathamby*
>>> Associate Technical Lead & Product Lead of WSO2 Identity Server
>>> Integration Technologies Team
>>> WSO2, Inc.
>>> lean.enterprise.middleware
>>>
>>> Mobile - *+94777776950*
>>> Blog - *http://nallaa.wordpress.com <http://nallaa.wordpress.com>*
>>>
>>
>>
>>
>> --
>> Lasitha Wattaladeniya
>> Software Engineer
>> WSO2, Inc. | http://wso2.com
>> lean. enterprise. middleware
>>
>> Mobile : +94719397528
>> Blog : techreadme.blogspot.com
>>
>
>
>
> --
> Thanks & Regards,
>
> *Johann Dilantha Nallathamby*
> Associate Technical Lead & Product Lead of WSO2 Identity Server
> Integration Technologies Team
> WSO2, Inc.
> lean.enterprise.middleware
>
> Mobile - *+94777776950*
> Blog - *http://nallaa.wordpress.com <http://nallaa.wordpress.com>*
>



-- 
Lasitha Wattaladeniya
Software Engineer
WSO2, Inc. | http://wso2.com
lean. enterprise. middleware

Mobile : +94719397528
Blog : techreadme.blogspot.com
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to