Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues when the managedOrg claim is not available. #288

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dommain -> domain

btw, since this is an identity claim it can be stored in identity db (most of the cases)
Here, are we handling that claim not available in tenant ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is added to handle scenarios where exceptions occur for migrated clients without having the claim

}
return null;
}
return claimsMap.get(CLAIM_MANAGED_ORGANIZATION);
}

Expand Down
Loading