use of password.pwm.config.value.data.FormConfiguration in project pwm by pwm-project.
the class NewUserFormUtils method readFromRequest.
static NewUserForm readFromRequest(final PwmRequest pwmRequest, final NewUserBean newUserBean) throws PwmDataValidationException, PwmUnrecoverableException {
final Locale userLocale = pwmRequest.getLocale();
final List<FormConfiguration> newUserForm = NewUserServlet.getFormDefinition(pwmRequest);
final Map<FormConfiguration, String> userFormValues = FormUtility.readFormValuesFromRequest(pwmRequest, newUserForm, userLocale);
final PasswordData passwordData1 = pwmRequest.readParameterAsPassword(NewUserServlet.FIELD_PASSWORD1);
final PasswordData passwordData2 = pwmRequest.readParameterAsPassword(NewUserServlet.FIELD_PASSWORD2);
final NewUserProfile newUserProfile = NewUserServlet.getNewUserProfile(pwmRequest);
return injectRemoteValuesIntoForm(userFormValues, newUserBean.getRemoteInputData(), newUserProfile, passwordData1, passwordData2);
}
use of password.pwm.config.value.data.FormConfiguration in project pwm by pwm-project.
the class NewUserFormUtils method readFromJsonRequest.
static NewUserForm readFromJsonRequest(final PwmRequest pwmRequest, final NewUserBean newUserBean) throws IOException, PwmUnrecoverableException, PwmDataValidationException {
final Locale userLocale = pwmRequest.getLocale();
final List<FormConfiguration> newUserForm = NewUserServlet.getFormDefinition(pwmRequest);
final Map<String, String> jsonBodyMap = pwmRequest.readBodyAsJsonStringMap();
final Map<FormConfiguration, String> userFormValues = FormUtility.readFormValuesFromMap(jsonBodyMap, newUserForm, userLocale);
final PasswordData passwordData1 = jsonBodyMap.containsKey(NewUserServlet.FIELD_PASSWORD1) && !jsonBodyMap.get(NewUserServlet.FIELD_PASSWORD1).isEmpty() ? new PasswordData(jsonBodyMap.get(NewUserServlet.FIELD_PASSWORD1)) : null;
final PasswordData passwordData2 = jsonBodyMap.containsKey(NewUserServlet.FIELD_PASSWORD2) && !jsonBodyMap.get(NewUserServlet.FIELD_PASSWORD2).isEmpty() ? new PasswordData(jsonBodyMap.get(NewUserServlet.FIELD_PASSWORD2)) : null;
final NewUserProfile newUserProfile = NewUserServlet.getNewUserProfile(pwmRequest);
return injectRemoteValuesIntoForm(userFormValues, newUserBean.getRemoteInputData(), newUserProfile, passwordData1, passwordData2);
}
use of password.pwm.config.value.data.FormConfiguration in project pwm by pwm-project.
the class NewUserServlet method verifyForm.
static PasswordUtility.PasswordCheckInfo verifyForm(final PwmRequest pwmRequest, final NewUserForm newUserForm, final boolean allowResultCaching) throws PwmDataValidationException, PwmUnrecoverableException, ChaiUnavailableException {
final Locale locale = pwmRequest.getLocale();
final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
final NewUserProfile newUserProfile = getNewUserProfile(pwmRequest);
final List<FormConfiguration> formDefinition = newUserProfile.readSettingAsForm(PwmSetting.NEWUSER_FORM);
final Map<FormConfiguration, String> formValueData = FormUtility.readFormValuesFromMap(newUserForm.getFormData(), formDefinition, locale);
FormUtility.validateFormValues(pwmApplication.getConfig(), formValueData, locale);
final List<FormUtility.ValidationFlag> validationFlags = new ArrayList<>();
validationFlags.add(FormUtility.ValidationFlag.checkReadOnlyAndHidden);
if (allowResultCaching) {
validationFlags.add(FormUtility.ValidationFlag.allowResultCaching);
}
FormUtility.validateFormValueUniqueness(pwmApplication, formValueData, locale, Collections.emptyList(), validationFlags.toArray(new FormUtility.ValidationFlag[validationFlags.size()]));
NewUserUtils.remoteVerifyFormData(pwmRequest, newUserForm);
final UserInfo uiBean = UserInfoBean.builder().cachedPasswordRuleAttributes(FormUtility.asStringMap(formValueData)).passwordPolicy(newUserProfile.getNewUserPasswordPolicy(pwmApplication, locale)).build();
final boolean promptForPassword = newUserProfile.readSettingAsBoolean(PwmSetting.NEWUSER_PROMPT_FOR_PASSWORD);
if (promptForPassword) {
return PasswordUtility.checkEnteredPassword(pwmApplication, locale, null, uiBean, null, newUserForm.getNewUserPassword(), newUserForm.getConfirmPassword());
}
return new PasswordUtility.PasswordCheckInfo(null, true, 0, PasswordUtility.PasswordCheckInfo.MatchStatus.MATCH, 0);
}
use of password.pwm.config.value.data.FormConfiguration in project pwm by pwm-project.
the class NewUserServlet method showFormPage.
private boolean showFormPage(final NewUserProfile profile) {
final boolean promptForPassword = profile.readSettingAsBoolean(PwmSetting.NEWUSER_PROMPT_FOR_PASSWORD);
boolean formNeedsShowing = false;
final List<FormConfiguration> formConfigurations = profile.readSettingAsForm(PwmSetting.NEWUSER_FORM);
for (final FormConfiguration formConfiguration : formConfigurations) {
if (formConfiguration.getType() != FormConfiguration.Type.hidden) {
formNeedsShowing = true;
}
}
return formNeedsShowing || promptForPassword;
}
use of password.pwm.config.value.data.FormConfiguration in project pwm by pwm-project.
the class PeopleSearchClientConfigBean method fromConfig.
static PeopleSearchClientConfigBean fromConfig(final PwmApplication pwmApplication, final PeopleSearchConfiguration peopleSearchConfiguration, final Locale locale, final UserIdentity userIdentity, final SessionLabel sessionLabel) throws PwmUnrecoverableException {
final Configuration configuration = pwmApplication.getConfig();
final Map<String, String> searchColumns = new LinkedHashMap<>();
final List<FormConfiguration> searchForm = configuration.readSettingAsForm(PwmSetting.PEOPLE_SEARCH_RESULT_FORM);
for (final FormConfiguration formConfiguration : searchForm) {
searchColumns.put(formConfiguration.getName(), formConfiguration.getLabel(locale));
}
final PeopleSearchClientConfigBean peopleSearchClientConfigBean = new PeopleSearchClientConfigBean();
peopleSearchClientConfigBean.setSearchColumns(searchColumns);
peopleSearchClientConfigBean.setEnablePhoto(peopleSearchConfiguration.isPhotosEnabled(userIdentity, sessionLabel));
peopleSearchClientConfigBean.setOrgChartEnabled(peopleSearchConfiguration.isOrgChartEnabled());
peopleSearchClientConfigBean.setOrgChartShowChildCount(peopleSearchConfiguration.isOrgChartShowChildCount());
peopleSearchClientConfigBean.setOrgChartMaxParents(peopleSearchConfiguration.getOrgChartMaxParents());
return peopleSearchClientConfigBean;
}
Aggregations