From 5b04cc4bf678c999b6fb817f3bc3c875a9e46e05 Mon Sep 17 00:00:00 2001 From: sadilchamishka Date: Wed, 15 Nov 2023 06:49:04 +0530 Subject: [PATCH] Remove the obsolete logic of resolving the authenticated username of organization SSO users --- .../management/service/util/Utils.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/util/Utils.java b/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/util/Utils.java index ced166cf..d874569d 100644 --- a/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/util/Utils.java +++ b/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/util/Utils.java @@ -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; @@ -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(); }