From d63e5e876b1bf8896336dfa80312c35156275766 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Tue, 31 May 2016 17:09:34 +0530 Subject: [PATCH] added password validation error msg --- .../util/CredentialManagementResponseBuilder.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java index 2edbb20ebb7..d52bdec3d96 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java @@ -36,6 +36,7 @@ public class CredentialManagementResponseBuilder { private static Log log = LogFactory.getLog(CredentialManagementResponseBuilder.class); private static String PASSWORD_VALIDATION_REGEX_TAG = "PasswordJavaRegEx"; + private static String PASSWORD_VALIDATION_ERROR_MSG_TAG = "PasswordJavaRegExViolationErrorMsg"; /** * Builds the response to change the password of a user @@ -55,8 +56,9 @@ public class CredentialManagementResponseBuilder { .build(); } if (!validateCredential(credentials.getNewPassword())) { - return Response.status(Response.Status.BAD_REQUEST).entity("Password does not match with required format.") - .build(); + String errorMsg = DeviceMgtAPIUtils.getRealmService().getBootstrapRealmConfiguration() + .getUserStoreProperty(PASSWORD_VALIDATION_ERROR_MSG_TAG); + return Response.status(Response.Status.BAD_REQUEST).entity(errorMsg).build(); } userStoreManager.updateCredential(username, credentials.getNewPassword(), credentials.getOldPassword()); @@ -91,8 +93,9 @@ public class CredentialManagementResponseBuilder { .build(); } if (!validateCredential(credentials.getNewPassword())) { - return Response.status(Response.Status.BAD_REQUEST).entity("Password does not match with required format.") - .build(); + String errorMsg = DeviceMgtAPIUtils.getRealmService().getBootstrapRealmConfiguration() + .getUserStoreProperty(PASSWORD_VALIDATION_ERROR_MSG_TAG); + return Response.status(Response.Status.BAD_REQUEST).entity(errorMsg).build(); } userStoreManager.updateCredentialByAdmin(username, credentials.getNewPassword()); return Response.status(Response.Status.OK).entity("UserImpl password by username: " +