Skip to content

Commit

Permalink
Remove the obsolete logic of resolving the authenticated username of …
Browse files Browse the repository at this point in the history
…organization SSO users
  • Loading branch information
sadilchamishka committed Nov 15, 2023
1 parent 3127e2f commit 5b04cc4
Showing 1 changed file with 0 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.wso2.carbon.user.api.UserStoreManager;
import org.wso2.carbon.user.core.Permission;
import org.wso2.carbon.user.core.common.AbstractUserStoreManager;
import org.wso2.carbon.user.core.common.User;
import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.user.core.util.UserCoreUtil;
import org.wso2.carbon.user.mgt.UserMgtConstants;
Expand Down Expand Up @@ -223,20 +222,6 @@ public static String getOrganizationId() {
*/
public static String getAuthenticatedUsername() {

String userResidentOrganizationId = PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getUserResidentOrganizationId();
/* When user accessing a different organization, the user resident organization is populated in the carbon
context. That value can be used to find the username from the user ID. */
if (StringUtils.isNotEmpty(userResidentOrganizationId)) {
try {
User user = getUserStoreManager(userResidentOrganizationId).getUser(getUserId(), null);
if (user != null) {
return user.getUsername();
}
} catch (OrganizationManagementException | UserStoreException e) {
LOG.debug("Authenticated user's username could not be resolved.", e);
}
}
return PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
}

Expand Down

0 comments on commit 5b04cc4

Please sign in to comment.