Skip to content

Commit

Permalink
Add role properties to the SCIM2 Role response
Browse files Browse the repository at this point in the history
  • Loading branch information
ShanChathusanda93 committed Dec 11, 2024
1 parent af6e5f2 commit 60d602e
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.wso2.carbon.identity.role.v2.mgt.core.model.Permission;
import org.wso2.carbon.identity.role.v2.mgt.core.model.Role;
import org.wso2.carbon.identity.role.v2.mgt.core.model.RoleBasicInfo;
import org.wso2.carbon.identity.role.v2.mgt.core.model.RoleProperty;
import org.wso2.carbon.identity.role.v2.mgt.core.model.UserBasicInfo;
import org.wso2.carbon.identity.role.v2.mgt.core.util.RoleManagementUtils;
import org.wso2.carbon.identity.role.v2.mgt.core.util.UserIDResolver;
Expand Down Expand Up @@ -307,6 +308,20 @@ private List<MultiValuedComplexType> convertPermissionsToMultiValuedComplexType(
return permissionValues;
}

private List<MultiValuedComplexType> convertRolePropertiesToMultiValuedComplexType(List<RoleProperty> roleProperties) {

List<MultiValuedComplexType> rolePropertyValues = new ArrayList<>();
if (roleProperties != null) {
for (RoleProperty roleProperty : roleProperties) {
MultiValuedComplexType rolePropertyComplexObject = new MultiValuedComplexType();
rolePropertyComplexObject.setValue(roleProperty.getValue());
rolePropertyComplexObject.setDisplay(roleProperty.getName());
rolePropertyValues.add(rolePropertyComplexObject);
}
}
return rolePropertyValues;
}

public void deleteRole(String roleID) throws CharonException, NotFoundException, BadRequestException {

try {
Expand Down Expand Up @@ -614,6 +629,9 @@ private List<RoleV2> getScimRolesList(List<Role> roles, List<String> requiredAtt
if (systemRoles.contains(role.getName())) {
scimRole.setSystemRole(true);
}
List<MultiValuedComplexType> roleProperties =
convertRolePropertiesToMultiValuedComplexType(role.getRoleProperties());
scimRole.setRoleProperties(roleProperties);
if (requiredAttributes != null) {
if (requiredAttributes.contains(USERS)) {
// Set role's assigned users.
Expand Down

0 comments on commit 60d602e

Please sign in to comment.