From 30f7a32c55b16434223cc8bdc30d795cf4979a13 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Thu, 19 Oct 2023 23:32:30 +0530 Subject: [PATCH 1/2] Fix unmodifiable list referencing issue --- .../webapp/publisher/APIPublisherServiceImpl.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 1691776be5..086c1666b9 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -184,7 +184,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { scope.setDisplayName(apiScope.getName()); scope.setDescription(apiScope.getDescription()); scope.setName(apiScope.getKey()); - List bindings = apiScope.getRoles(); + List bindings = new ArrayList<>(apiScope.getRoles()); bindings.add(ADMIN_ROLE_KEY); scope.setBindings(bindings); publisherRESTAPIServices.addNewSharedScope(apiApplicationKey, accessTokenInfo, scope); @@ -259,7 +259,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { scope.setName(apiScope.getKey()); scope.setDescription(apiScope.getDescription()); scope.setDisplayName(apiScope.getName()); - List bindings = apiScope.getRoles(); + List bindings = new ArrayList<>(apiScope.getRoles()); bindings.add(ADMIN_ROLE_KEY); scope.setBindings(bindings); publisherRESTAPIServices.addNewSharedScope(apiApplicationKey, accessTokenInfo, scope); @@ -282,7 +282,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { scope.setName(apiScope.getKey()); scope.setDescription(apiScope.getDescription()); scope.setDisplayName(apiScope.getName()); - List bindings = apiScope.getRoles(); + List bindings = new ArrayList<>(apiScope.getRoles()); bindings.add(ADMIN_ROLE_KEY); scope.setBindings(bindings); publisherRESTAPIServices.addNewSharedScope(apiApplicationKey, accessTokenInfo, scope); @@ -459,10 +459,8 @@ public class APIPublisherServiceImpl implements APIPublisherService { //todo check whether scope is available or not ScopeMapping scopeMapping = defaultPermission.getScopeMapping(); - String[] roles = scopeMapping.getDefaultRoles().split(","); - List bindings = Arrays.asList(roles); - bindings.add(ADMIN_ROLE_KEY); - + List bindings = new ArrayList<>( + Arrays.asList(scopeMapping.getDefaultRoles().split(","))); scope.setName(scopeMapping.getKey()); scope.setDescription(scopeMapping.getName()); scope.setDisplayName(scopeMapping.getName()); From a7387fda315e1e76bbdb0b7aae8d27f6def88763 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Thu, 19 Oct 2023 23:36:57 +0530 Subject: [PATCH 2/2] Add missed role key --- .../core/apimgt/webapp/publisher/APIPublisherServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 086c1666b9..f163859572 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -461,6 +461,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { List bindings = new ArrayList<>( Arrays.asList(scopeMapping.getDefaultRoles().split(","))); + bindings.add(ADMIN_ROLE_KEY); scope.setName(scopeMapping.getKey()); scope.setDescription(scopeMapping.getName()); scope.setDisplayName(scopeMapping.getName());