Search in sources :

Example 1 with RestFormDataClient

use of password.pwm.ws.client.rest.form.RestFormDataClient in project pwm by pwm-project.

the class NewUserUtils method remoteSendFormData.

private static void remoteSendFormData(final PwmRequest pwmRequest, final NewUserForm newUserForm, final FormDataRequestBean.Mode mode) throws PwmUnrecoverableException, PwmDataValidationException {
    final RestFormDataClient restFormDataClient = new RestFormDataClient(pwmRequest.getPwmApplication(), pwmRequest.getSessionLabel());
    if (!restFormDataClient.isEnabled()) {
        return;
    }
    final NewUserBean newUserBean = NewUserServlet.getNewUserBean(pwmRequest);
    final NewUserProfile newUserProfile = NewUserServlet.getNewUserProfile(pwmRequest);
    final FormDataRequestBean.FormInfo formInfo = FormDataRequestBean.FormInfo.builder().mode(mode).moduleProfileID(newUserBean.getProfileID()).sessionID(pwmRequest.getPwmSession().getLoginInfoBean().getGuid()).module(FormDataRequestBean.FormType.NewUser).build();
    final FormDataRequestBean formDataRequestBean = FormDataRequestBean.builder().formInfo(formInfo).formConfigurations(newUserProfile.readSettingAsForm(PwmSetting.NEWUSER_FORM)).formValues(newUserForm.getFormData()).build();
    final FormDataResponseBean formDataResponseBean = restFormDataClient.invoke(formDataRequestBean, pwmRequest.getLocale());
    if (formDataResponseBean.isError()) {
        final ErrorInformation error = new ErrorInformation(PwmError.ERROR_REMOTE_ERROR_VALUE, formDataResponseBean.getErrorDetail(), new String[] { formDataResponseBean.getErrorMessage() });
        throw new PwmDataValidationException(error);
    }
}
Also used : FormDataResponseBean(password.pwm.ws.client.rest.form.FormDataResponseBean) ErrorInformation(password.pwm.error.ErrorInformation) PwmDataValidationException(password.pwm.error.PwmDataValidationException) RestFormDataClient(password.pwm.ws.client.rest.form.RestFormDataClient) FormDataRequestBean(password.pwm.ws.client.rest.form.FormDataRequestBean) NewUserBean(password.pwm.http.bean.NewUserBean) NewUserProfile(password.pwm.config.profile.NewUserProfile)

Aggregations

NewUserProfile (password.pwm.config.profile.NewUserProfile)1 ErrorInformation (password.pwm.error.ErrorInformation)1 PwmDataValidationException (password.pwm.error.PwmDataValidationException)1 NewUserBean (password.pwm.http.bean.NewUserBean)1 FormDataRequestBean (password.pwm.ws.client.rest.form.FormDataRequestBean)1 FormDataResponseBean (password.pwm.ws.client.rest.form.FormDataResponseBean)1 RestFormDataClient (password.pwm.ws.client.rest.form.RestFormDataClient)1