From 00bd74734a639517930f904e98c2208b9737d0c3 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Wed, 21 Jun 2023 23:32:48 +0530 Subject: [PATCH] Remove apim_reserved_user when fetching users --- .../jaxrs/service/impl/UserManagementServiceImpl.java | 9 +++++++++ .../mgt/core/device/mgt/api/jaxrs/util/Constants.java | 1 + 2 files changed, 10 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java index d8db5e3776..29a64a9238 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java @@ -455,6 +455,9 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(users.size()); BasicUserInfo user; for (String username : users) { + if (Constants.APIM_RESERVED_USER.equals(username)) { + continue; + } user = getBasicUserInfo(username); userList.add(user); } @@ -515,6 +518,9 @@ public class UserManagementServiceImpl implements UserManagementService { if (StringUtils.isNotEmpty(username)) { commonUsers = getUserList(null, username); } + if (commonUsers != null) { + commonUsers.remove(Constants.APIM_RESERVED_USER); + } if (!skipSearch(commonUsers) && StringUtils.isNotEmpty(firstName)) { tempList = getUserList(Constants.USER_CLAIM_FIRST_NAME, firstName); @@ -689,6 +695,9 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(); UserInfo user; for (String username : users) { + if (Constants.APIM_RESERVED_USER.equals(username)) { + continue; + } user = new UserInfo(); user.setUsername(username); user.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS)); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java index 300e47b147..c9ad2e182e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java @@ -30,6 +30,7 @@ public class Constants { public static final String USER_CLAIM_MODIFIED = "http://wso2.org/claims/modified"; public static final String USER_CLAIM_DEVICES = "http://wso2.org/claims/devices"; public static final String PRIMARY_USER_STORE = "PRIMARY"; + public static final String APIM_RESERVED_USER = "apim_reserved_user"; public static final String DEFAULT_STREAM_VERSION = "1.0.0"; public static final String SCOPE = "scope"; public static final String JDBC_USERSTOREMANAGER = "org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager";