From ee3c96899369c915ad87589f6a64cb7f40e1e831 Mon Sep 17 00:00:00 2001 From: kumardeepak5 Date: Tue, 19 Nov 2024 10:13:15 +0000 Subject: [PATCH] change response code from 500 to 400 in case invalid chnanel id is provided --- .../rest/api/user/recovery/v2/impl/core/Constants.java | 1 + .../api/user/recovery/v2/impl/core/utils/RecoveryUtil.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/Constants.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/Constants.java index dde101bf1..576317c37 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/Constants.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/Constants.java @@ -38,6 +38,7 @@ public class Constants { public static final String STATUS_PRECONDITION_FAILED_MESSAGE_DEFAULT = "Precondition Failed"; public static final String STATUS_INTERNAL_SERVER_ERROR_DESCRIPTION_DEFAULT = "The server encountered an internal error. Please contact administrator."; + public static final String STATUS_BAD_REQUEST_DEFAULT = "Bad Request"; // Recovery type. public static final String RECOVERY_WITH_NOTIFICATIONS = "recoverWithNotifications"; diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/utils/RecoveryUtil.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/utils/RecoveryUtil.java index e097532d9..9dea04df9 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/utils/RecoveryUtil.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/utils/RecoveryUtil.java @@ -256,6 +256,10 @@ public static WebApplicationException handleIdentityRecoveryException(IdentityRe getCode().equals(e.getErrorCode())) { return RecoveryUtil.buildRetryPasswordResetObject(tenantDomain, errorDescription, errorCode, code, correlationId); + } else if (IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_INVALID_CHANNEL_ID.getCode().equals( + e.getErrorCode())) { + errorMessage = Constants.STATUS_BAD_REQUEST_DEFAULT; + status = Response.Status.BAD_REQUEST; } if (e instanceof IdentityRecoveryClientException) {