Search in sources :

Example 6 with UpdateProfileProfile

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;
}
Also used : UpdateProfileBean(password.pwm.http.bean.UpdateProfileBean) UpdateProfileProfile(password.pwm.config.profile.UpdateProfileProfile) FormConfiguration(password.pwm.config.value.data.FormConfiguration) PwmOperationalException(password.pwm.error.PwmOperationalException)

Example 7 with UpdateProfileProfile

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;
}
Also used : ErrorInformation(password.pwm.error.ErrorInformation) UpdateProfileBean(password.pwm.http.bean.UpdateProfileBean) UpdateProfileProfile(password.pwm.config.profile.UpdateProfileProfile) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) TokenDestinationItem(password.pwm.bean.TokenDestinationItem)

Aggregations

UpdateProfileProfile (password.pwm.config.profile.UpdateProfileProfile)7 FormConfiguration (password.pwm.config.value.data.FormConfiguration)5 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)4 UpdateProfileBean (password.pwm.http.bean.UpdateProfileBean)4 List (java.util.List)3 HashMap (java.util.HashMap)2 ErrorInformation (password.pwm.error.ErrorInformation)2 PwmOperationalException (password.pwm.error.PwmOperationalException)2 UserInfo (password.pwm.ldap.UserInfo)2 FormMap (password.pwm.util.FormMap)2 MacroMachine (password.pwm.util.macro.MacroMachine)2 ChaiUser (com.novell.ldapchai.ChaiUser)1 ChaiException (com.novell.ldapchai.exception.ChaiException)1 Map (java.util.Map)1 PwmApplication (password.pwm.PwmApplication)1 TokenDestinationItem (password.pwm.bean.TokenDestinationItem)1 Configuration (password.pwm.config.Configuration)1 ProfileType (password.pwm.config.profile.ProfileType)1 PwmDataValidationException (password.pwm.error.PwmDataValidationException)1 PwmException (password.pwm.error.PwmException)1