From bd65ad6b0fbb7b3c9d1b5ecc525aa72daf0c8d3d Mon Sep 17 00:00:00 2001 From: Amanda Ariyaratne Date: Thu, 4 Jan 2024 10:28:21 +0530 Subject: [PATCH] Fix patch groups with path as members --- .../core/protocol/endpoints/GroupResourceManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/GroupResourceManager.java b/modules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/GroupResourceManager.java index 1e95b61b2..a0efb0f45 100644 --- a/modules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/GroupResourceManager.java +++ b/modules/charon-core/src/main/java/org/wso2/charon3/core/protocol/endpoints/GroupResourceManager.java @@ -16,6 +16,7 @@ package org.wso2.charon3.core.protocol.endpoints; import org.apache.commons.lang.StringUtils; +import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; @@ -676,7 +677,8 @@ private boolean isDeleteAllUsersOperationFound(List patchOperati for (PatchOperation patchOperation : patchOperations) { String operation = patchOperation.getOperation(); String path = patchOperation.getPath(); - if (!(patchOperation.getValues() instanceof String)) { + if (!(SCIMConstants.OperationalConstants.ADD).equals(operation) + && !(patchOperation.getValues() instanceof String)) { JSONObject valuesJson = (JSONObject) patchOperation.getValues(); if (operation.equals(SCIMConstants.OperationalConstants.REPLACE) && ((path != null && path.equals(SCIMConstants.GroupSchemaConstants.MEMBERS)) || @@ -854,7 +856,7 @@ private void processGroupPatchOperations(Map> patch patchOperation.setValues(attributePrefixedJson); } else if (patchOperation.getPath().equals(SCIMConstants.GroupSchemaConstants.MEMBERS) && patchOperation.getValues() != null) { - JSONObject valuesPropertyJson = (JSONObject) patchOperation.getValues(); + JSONArray valuesPropertyJson = (JSONArray) patchOperation.getValues(); JSONObject attributePrefixedJson = new JSONObject(); attributePrefixedJson.put(SCIMConstants.GroupSchemaConstants.MEMBERS, valuesPropertyJson);