Search in sources :

Example 26 with FormConfiguration

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);
}
Also used : Locale(java.util.Locale) PasswordData(password.pwm.util.PasswordData) FormConfiguration(password.pwm.config.value.data.FormConfiguration) NewUserProfile(password.pwm.config.profile.NewUserProfile)

Example 27 with FormConfiguration

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);
}
Also used : Locale(java.util.Locale) PasswordData(password.pwm.util.PasswordData) FormConfiguration(password.pwm.config.value.data.FormConfiguration) NewUserProfile(password.pwm.config.profile.NewUserProfile)

Example 28 with FormConfiguration

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);
}
Also used : Locale(java.util.Locale) PwmApplication(password.pwm.PwmApplication) ArrayList(java.util.ArrayList) UserInfo(password.pwm.ldap.UserInfo) NewUserProfile(password.pwm.config.profile.NewUserProfile) FormConfiguration(password.pwm.config.value.data.FormConfiguration)

Example 29 with FormConfiguration

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;
}
Also used : FormConfiguration(password.pwm.config.value.data.FormConfiguration)

Example 30 with FormConfiguration

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;
}
Also used : Configuration(password.pwm.config.Configuration) FormConfiguration(password.pwm.config.value.data.FormConfiguration) FormConfiguration(password.pwm.config.value.data.FormConfiguration) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

FormConfiguration (password.pwm.config.value.data.FormConfiguration)63 LinkedHashMap (java.util.LinkedHashMap)26 ErrorInformation (password.pwm.error.ErrorInformation)23 Map (java.util.Map)19 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)15 ArrayList (java.util.ArrayList)14 HashMap (java.util.HashMap)14 PwmOperationalException (password.pwm.error.PwmOperationalException)14 List (java.util.List)13 UserIdentity (password.pwm.bean.UserIdentity)13 PwmApplication (password.pwm.PwmApplication)11 UserInfo (password.pwm.ldap.UserInfo)10 ChaiUser (com.novell.ldapchai.ChaiUser)9 Locale (java.util.Locale)9 PwmSession (password.pwm.http.PwmSession)9 SearchConfiguration (password.pwm.ldap.search.SearchConfiguration)9 ChaiOperationException (com.novell.ldapchai.exception.ChaiOperationException)8 Configuration (password.pwm.config.Configuration)7 PwmDataValidationException (password.pwm.error.PwmDataValidationException)7 UserSearchEngine (password.pwm.ldap.search.UserSearchEngine)7