Skip to content

Commit

Permalink
use role basic info to resolve audience
Browse files Browse the repository at this point in the history
  • Loading branch information
AnuradhaSK committed Oct 17, 2023
1 parent 120d6fe commit fc0b6d6
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.wso2.carbon.identity.mgt.policy.PolicyViolationException;
import org.wso2.carbon.identity.provisioning.IdentityProvisioningConstants;
import org.wso2.carbon.identity.role.v2.mgt.core.IdentityRoleManagementException;
import org.wso2.carbon.identity.role.v2.mgt.core.RoleBasicInfo;
import org.wso2.carbon.identity.scim2.common.DAO.GroupDAO;
import org.wso2.carbon.identity.scim2.common.cache.SCIMCustomAttributeSchemaCache;
import org.wso2.carbon.identity.scim2.common.exceptions.IdentitySCIMException;
Expand Down Expand Up @@ -4237,18 +4238,18 @@ private void setRolesOfUser(List<String> rolesOfUser, Map<String, Group> groupMe
role.setId(groupObject.getId());
String location = SCIMCommonUtils.getSCIMRoleV2URL(groupObject.getId());
role.setLocation(location);
org.wso2.carbon.identity.role.v2.mgt.core.Role roleWithAudience = null;
try {
roleWithAudience = SCIMCommonComponentHolder.getRoleManagementServiceV2()
.getRole(groupObject.getId(), tenantDomain);
org.wso2.carbon.identity.role.v2.mgt.core.RoleBasicInfo roleBasicInfo =
SCIMCommonComponentHolder.getRoleManagementServiceV2()
.getRoleBasicInfoById(groupObject.getId(), tenantDomain);
role.setAudience(roleBasicInfo.getAudienceId(), roleBasicInfo.getAudienceName(),
roleBasicInfo.getAudience());
} catch (IdentityRoleManagementException e) {
if (log.isDebugEnabled()) {
log.debug("Failed to resolve the audience for role id: " + groupObject.getId(), e);
}
return;
}
role.setAudience(roleWithAudience.getAudienceId(), roleWithAudience.getAudienceName(),
roleWithAudience.getAudience());
scimUser.setRoleV2(role);
} else {
Role role = new Role();
Expand Down Expand Up @@ -4486,18 +4487,17 @@ private void setGroupRoles(Group group) throws org.wso2.carbon.user.core.UserSto
role.setId(groupObject.getId());
String location = SCIMCommonUtils.getSCIMRoleV2URL(groupObject.getId());
role.setLocation(location);
org.wso2.carbon.identity.role.v2.mgt.core.Role roleWithAudience = null;
try {
roleWithAudience = SCIMCommonComponentHolder.getRoleManagementServiceV2()
.getRole(groupObject.getId(), tenantDomain);
RoleBasicInfo roleBasicInfo = SCIMCommonComponentHolder.getRoleManagementServiceV2()
.getRoleBasicInfoById(groupObject.getId(), tenantDomain);
role.setAudience(roleBasicInfo.getAudienceId(), roleBasicInfo.getAudienceName(),
roleBasicInfo.getAudience());
} catch (IdentityRoleManagementException e) {
if (log.isDebugEnabled()) {
log.debug("Failed to resolve the audience for role id: " + groupObject.getId(), e);
}
return;
}
role.setAudience(roleWithAudience.getAudienceId(), roleWithAudience.getAudienceName(),
roleWithAudience.getAudience());
group.setRoleV2(role);
} else {
Role role = new Role();
Expand Down

0 comments on commit fc0b6d6

Please sign in to comment.