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 NPE #271

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -161,6 +161,7 @@ private String getUserId(User user, String orgId) throws OrganizationManagementA
try {
AbstractUserStoreManager userStoreManager = (AbstractUserStoreManager) getUserStoreManager(user);
String userId = userStoreManager.getUser(null, user.getUserName()).getUserID();
// Retrieve the user ID of the shared user if an user association exists.
Optional<String> optionalUserId =
OrganizationSharedUserUtil.getUserIdOfAssociatedUserByOrgId(userId, orgId);
return optionalUserId.orElse(userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.wso2.carbon.identity.organization.management.organization.user.sharing.util;

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;
import org.wso2.carbon.user.core.UserStoreException;
import org.wso2.carbon.user.core.common.AbstractUserStoreManager;
Expand Down Expand Up @@ -49,7 +50,11 @@ public static String getUserManagedOrganizationClaim(AbstractUserStoreManager us
public static Optional<String> getUserIdOfAssociatedUserByOrgId(String associatedUserId, String orgId)
throws OrganizationManagementException {

return Optional.ofNullable(OrganizationUserSharingDataHolder.getInstance().getOrganizationUserSharingService()
.getUserAssociationOfAssociatedUserByOrgId(associatedUserId, orgId).getUserId());
UserAssociation userAssociation = OrganizationUserSharingDataHolder.getInstance().getOrganizationUserSharingService()
.getUserAssociationOfAssociatedUserByOrgId(associatedUserId, orgId);
if (userAssociation == null) {
return Optional.empty();
}
return Optional.of(userAssociation.getUserId());
}
}
Loading