From 832dde618142859bcc2f373978c4f215cbb9f05b Mon Sep 17 00:00:00 2001 From: dinuwan97 Date: Mon, 5 Dec 2022 13:05:18 +0530 Subject: [PATCH] Add realm configuration to get primary user store domain name. --- .../scim2/common/impl/SCIMUserManager.java | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java index 9b5471089..35bcff586 100644 --- a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java +++ b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java @@ -2044,17 +2044,31 @@ private Set getMultiAttributeFilteredUser private int getMaxLimit(String domainName) { int givenMax = UserCoreConstants.MAX_USER_ROLE_LIST; - if (StringUtils.isEmpty(domainName)) { - domainName = UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME; - } - if (carbonUM.getSecondaryUserStoreManager(domainName).getRealmConfiguration() - .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_MAX_USER_LIST) != null) { - givenMax = Integer.parseInt(carbonUM.getSecondaryUserStoreManager(domainName).getRealmConfiguration() - .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_MAX_USER_LIST)); + try { + if (StringUtils.isEmpty(domainName)) { + domainName = carbonUM.getRealmConfiguration().getUserStoreProperty(UserCoreConstants.RealmConfig. + PROPERTY_DOMAIN_NAME); + if(StringUtils.isEmpty(domainName)){ + domainName = UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME; + } + if (log.isDebugEnabled()) { + log.debug("Primary user store DomainName picked as " + domainName); + } + } + if (carbonUM.getSecondaryUserStoreManager(domainName).getRealmConfiguration() + .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_MAX_USER_LIST) != null) { + givenMax = Integer.parseInt(carbonUM.getSecondaryUserStoreManager(domainName).getRealmConfiguration() + .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_MAX_USER_LIST)); + } + + return givenMax; + + } catch(NullPointerException e) { + String msg = "PRIMARY user store domain name cannot be a null value."; + throw new NullPointerException(msg); } - return givenMax; } /**