added password validation error msg

revert-70aa11f8
ayyoob 8 years ago
parent 74a96015a7
commit d63e5e876b

@ -36,6 +36,7 @@ public class CredentialManagementResponseBuilder {
private static Log log = LogFactory.getLog(CredentialManagementResponseBuilder.class); private static Log log = LogFactory.getLog(CredentialManagementResponseBuilder.class);
private static String PASSWORD_VALIDATION_REGEX_TAG = "PasswordJavaRegEx"; 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 * Builds the response to change the password of a user
@ -55,8 +56,9 @@ public class CredentialManagementResponseBuilder {
.build(); .build();
} }
if (!validateCredential(credentials.getNewPassword())) { if (!validateCredential(credentials.getNewPassword())) {
return Response.status(Response.Status.BAD_REQUEST).entity("Password does not match with required format.") String errorMsg = DeviceMgtAPIUtils.getRealmService().getBootstrapRealmConfiguration()
.build(); .getUserStoreProperty(PASSWORD_VALIDATION_ERROR_MSG_TAG);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMsg).build();
} }
userStoreManager.updateCredential(username, credentials.getNewPassword(), userStoreManager.updateCredential(username, credentials.getNewPassword(),
credentials.getOldPassword()); credentials.getOldPassword());
@ -91,8 +93,9 @@ public class CredentialManagementResponseBuilder {
.build(); .build();
} }
if (!validateCredential(credentials.getNewPassword())) { if (!validateCredential(credentials.getNewPassword())) {
return Response.status(Response.Status.BAD_REQUEST).entity("Password does not match with required format.") String errorMsg = DeviceMgtAPIUtils.getRealmService().getBootstrapRealmConfiguration()
.build(); .getUserStoreProperty(PASSWORD_VALIDATION_ERROR_MSG_TAG);
return Response.status(Response.Status.BAD_REQUEST).entity(errorMsg).build();
} }
userStoreManager.updateCredentialByAdmin(username, credentials.getNewPassword()); userStoreManager.updateCredentialByAdmin(username, credentials.getNewPassword());
return Response.status(Response.Status.OK).entity("UserImpl password by username: " + return Response.status(Response.Status.OK).entity("UserImpl password by username: " +

Loading…
Cancel
Save