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
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev