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 8148eec97..08895096c 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 @@ -127,6 +127,8 @@ import static org.apache.commons.collections.CollectionUtils.isNotEmpty; import static org.wso2.carbon.identity.core.util.IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR; +import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_EMAIL_DOMAIN_ASSOCIATED_WITH_DIFFERENT_ORGANIZATION; +import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_EMAIL_DOMAIN_NOT_MAPPED_TO_ORGANIZATION; import static org.wso2.carbon.identity.scim2.common.utils.SCIMCommonUtils.buildCustomSchema; import static org.wso2.carbon.identity.scim2.common.utils.SCIMCommonUtils.getCustomSchemaURI; import static org.wso2.carbon.identity.scim2.common.utils.SCIMCommonUtils @@ -420,6 +422,14 @@ private void handleErrorsOnUserNameAndPasswordPolicy(Throwable e) throws BadRequ throw new BadRequestException(ERROR_CODE_PASSWORD_HISTORY_VIOLATION + " - " + e.getMessage(), ResponseCodeConstants.INVALID_VALUE); } + if (e instanceof org.wso2.carbon.user.core.UserStoreException) { + String errorCode = ((org.wso2.carbon.user.core.UserStoreException) e).getErrorCode(); + if (StringUtils.equals(errorCode, + (ERROR_CODE_EMAIL_DOMAIN_ASSOCIATED_WITH_DIFFERENT_ORGANIZATION.getCode())) || + StringUtils.equals(errorCode, ERROR_CODE_EMAIL_DOMAIN_NOT_MAPPED_TO_ORGANIZATION.getCode())) { + throw new BadRequestException(e.getMessage(), ResponseCodeConstants.INVALID_VALUE); + } + } e = e.getCause(); i++; } diff --git a/pom.xml b/pom.xml index 13896331f..c728a33c3 100644 --- a/pom.xml +++ b/pom.xml @@ -267,7 +267,7 @@ 20030203.000129 1.8.12 4.0.10 - 1.0.70 + 1.0.76