Sometimes when we accessing APIs, there are situations when authenticated user again WSO2 not provided user store domain. But it's essential to get the which user store the user has authenticated. It can be a user in Primary Store or Secondary User Stores. UserCoreUtil class has following method which will gives you the domain that user has authenticated.
if (!username.contains(CarbonConstants.DOMAIN_SEPARATOR)) {
String userStoreDomain = UserCoreUtil.getDomainFromThreadLocal();
if (!StringUtils.isEmpty(userStoreDomain)) {
username = UserCoreUtil.getDomainFromThreadLocal() + CarbonConstants.DOMAIN_SEPARATOR + username;
}
}
No comments:
Post a Comment