Skip to content

Commit

Permalink
Fix issues when the managedOrg claim is not available.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanikaRuchini committed Nov 9, 2023
1 parent 846fabf commit d7e8c80
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String, String> claimsMap = userStoreManager
.getUserClaimValuesWithID(userId, new String[]{CLAIM_MANAGED_ORGANIZATION}, userDomain);
Map<String, String> 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);
}

Expand Down

0 comments on commit d7e8c80

Please sign in to comment.