Skip to content

Commit

Permalink
Improve scim attribute update
Browse files Browse the repository at this point in the history
  • Loading branch information
somindatommy committed Feb 3, 2024
1 parent 91d1295 commit c816851
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import org.wso2.carbon.user.core.UserStoreManager;
import org.wso2.carbon.user.core.claim.ClaimManager;
import org.wso2.carbon.user.core.common.AbstractUserStoreManager;
import org.wso2.carbon.user.core.common.Claim;
import org.wso2.carbon.user.core.constants.UserCoreClaimConstants;
import org.wso2.carbon.user.core.constants.UserCoreErrorConstants;
import org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager;
Expand Down Expand Up @@ -2664,10 +2663,9 @@ public Group createGroup(Group group, Map<String, Boolean> requiredAttributes)
}
}
}
Map<String, String> claimsInLocalDialect =
SCIMCommonUtils.convertSCIMtoLocalDialect(AttributeMapper.getClaimsMap(group));
// From SCIM we only need to generate the role name. Other attributes are handled by the user core.
org.wso2.carbon.user.core.common.Group createdGroup =
carbonUM.addGroup(roleNameWithDomain, members, buildGroupMetaClaimsList(claimsInLocalDialect));
carbonUM.addGroup(roleNameWithDomain, members, null);
group = buildGroup(createdGroup);
if (log.isDebugEnabled()) {
log.debug("Group: " + group.getDisplayName() + " is created through SCIM.");
Expand All @@ -2693,26 +2691,6 @@ public Group createGroup(Group group, Map<String, Boolean> requiredAttributes)
return group;
}

/**
* Convert the claimsInLocalDialect to a list of Claims. NOTE: This method drops the RESOURCE_TYPE_CLAIM claim
* dialect being added to the returned claims list.
*
* @param claimsInLocalDialect Map of claims in local dialect.
* @return List of claims.
*/
private List<Claim> buildGroupMetaClaimsList(Map<String, String> claimsInLocalDialect) {

List<Claim> claimsList = new ArrayList<>();
for (Map.Entry<String, String> entry : claimsInLocalDialect.entrySet()) {
String claimUri = entry.getKey();
if (RESOURCE_TYPE_CLAIM.equals(claimUri)) {
continue;
}
claimsList.add(new Claim(entry.getKey(), entry.getValue()));
}
return claimsList;
}

@Override
public Group getGroup(String id, Map<String, Boolean> requiredAttributes) throws CharonException {

Expand Down
Loading

0 comments on commit c816851

Please sign in to comment.