From d7e8c80cfb590eebe4a85eadc91ec2398b27ba8e Mon Sep 17 00:00:00 2001 From: ChanikaRuchini Date: Thu, 9 Nov 2023 22:52:46 +0530 Subject: [PATCH] Fix issues when the managedOrg claim is not available. --- .../sharing/util/OrganizationSharedUserUtil.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/components/org.wso2.carbon.identity.organization.management.organization.user.sharing/src/main/java/org/wso2/carbon/identity/organization/management/organization/user/sharing/util/OrganizationSharedUserUtil.java b/components/org.wso2.carbon.identity.organization.management.organization.user.sharing/src/main/java/org/wso2/carbon/identity/organization/management/organization/user/sharing/util/OrganizationSharedUserUtil.java index 5daec7b47..472f85395 100644 --- a/components/org.wso2.carbon.identity.organization.management.organization.user.sharing/src/main/java/org/wso2/carbon/identity/organization/management/organization/user/sharing/util/OrganizationSharedUserUtil.java +++ b/components/org.wso2.carbon.identity.organization.management.organization.user.sharing/src/main/java/org/wso2/carbon/identity/organization/management/organization/user/sharing/util/OrganizationSharedUserUtil.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.organization.management.organization.user.sharing.util; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.organization.management.organization.user.sharing.internal.OrganizationUserSharingDataHolder; import org.wso2.carbon.identity.organization.management.organization.user.sharing.models.UserAssociation; import org.wso2.carbon.identity.organization.management.service.exception.OrganizationManagementException; @@ -34,12 +36,22 @@ */ public class OrganizationSharedUserUtil { + private static final Log LOG = LogFactory.getLog(OrganizationSharedUserUtil.class); + public static String getUserManagedOrganizationClaim(AbstractUserStoreManager userStoreManager, String userId) throws UserStoreException { String userDomain = userStoreManager.getUser(userId, null).getUserStoreDomain(); - Map claimsMap = userStoreManager - .getUserClaimValuesWithID(userId, new String[]{CLAIM_MANAGED_ORGANIZATION}, userDomain); + Map claimsMap = null; + try { + claimsMap = userStoreManager + .getUserClaimValuesWithID(userId, new String[]{CLAIM_MANAGED_ORGANIZATION}, userDomain); + } catch (UserStoreException e) { + if (LOG.isDebugEnabled()) { + LOG.debug("ManagedOrg claim is not available in the userstore dommain: " + userDomain); + } + return null; + } return claimsMap.get(CLAIM_MANAGED_ORGANIZATION); }