use of password.pwm.config.profile.UpdateProfileProfile in project pwm by pwm-project.
the class UpdateProfileServlet method restValidateForm.
@ActionHandler(action = "validate")
ProcessStatus restValidateForm(final PwmRequest pwmRequest) throws IOException, ServletException, PwmUnrecoverableException, ChaiUnavailableException {
final UpdateProfileBean updateProfileBean = getBean(pwmRequest);
final UpdateProfileProfile updateProfileProfile = getProfile(pwmRequest);
boolean success = true;
String userMessage = Message.getLocalizedMessage(pwmRequest.getLocale(), Message.Success_UpdateForm, pwmRequest.getConfig());
try {
// read in the responses from the request
final Map<FormConfiguration, String> formValues = UpdateProfileUtil.readFromJsonRequest(pwmRequest, updateProfileProfile, updateProfileBean);
// verify form meets the form requirements
UpdateProfileUtil.verifyFormAttributes(pwmRequest.getPwmApplication(), pwmRequest.getUserInfoIfLoggedIn(), pwmRequest.getLocale(), formValues, true);
updateProfileBean.getFormData().putAll(FormUtility.asStringMap(formValues));
} catch (PwmOperationalException e) {
success = false;
userMessage = e.getErrorInformation().toUserStr(pwmRequest.getPwmSession(), pwmRequest.getPwmApplication());
}
final ValidateResponse response = new ValidateResponse();
response.setMessage(userMessage);
response.setSuccess(success);
pwmRequest.outputJsonResult(RestResultBean.withData(response));
return ProcessStatus.Halt;
}
use of password.pwm.config.profile.UpdateProfileProfile in project pwm by pwm-project.
the class UpdateProfileServlet method handleEnterCodeRequest.
@ActionHandler(action = "enterCode")
ProcessStatus handleEnterCodeRequest(final PwmRequest pwmRequest) throws PwmUnrecoverableException, ServletException, IOException {
setLastError(pwmRequest, null);
final UpdateProfileBean updateProfileBean = getBean(pwmRequest);
final UpdateProfileProfile updateProfileProfile = getProfile(pwmRequest);
final String userEnteredCode = pwmRequest.readParameterAsString(PwmConstants.PARAM_TOKEN);
final TokenDestinationItem tokenDestinationItem = UpdateProfileUtil.tokenDestinationItemForCurrentValidation(pwmRequest, updateProfileBean, updateProfileProfile);
ErrorInformation errorInformation = null;
try {
TokenUtil.checkEnteredCode(pwmRequest, userEnteredCode, tokenDestinationItem, pwmRequest.getUserInfoIfLoggedIn(), TokenType.UPDATE, TokenService.TokenEntryType.authenticated);
} catch (PwmUnrecoverableException e) {
LOGGER.debug(pwmRequest, "error while checking entered token: ");
errorInformation = e.getErrorInformation();
}
if (errorInformation != null) {
setLastError(pwmRequest, errorInformation);
UpdateProfileUtil.forwardToEnterCode(pwmRequest, updateProfileProfile, updateProfileBean);
return ProcessStatus.Halt;
}
LOGGER.debug(pwmRequest, "marking token as passed " + JsonUtil.serialize(tokenDestinationItem));
updateProfileBean.getCompletedTokenFields().add(updateProfileBean.getCurrentTokenField());
updateProfileBean.setTokenSent(false);
updateProfileBean.setCurrentTokenField(null);
if (pwmRequest.getConfig().readSettingAsBoolean(PwmSetting.DISPLAY_TOKEN_SUCCESS_BUTTON)) {
pwmRequest.setAttribute(PwmRequestAttribute.TokenDestItems, tokenDestinationItem);
pwmRequest.forwardToJsp(JspUrl.UPDATE_ATTRIBUTES_TOKEN_SUCCESS);
return ProcessStatus.Halt;
}
return ProcessStatus.Continue;
}
Aggregations