Search in sources :

Example 56 with FormConfiguration

use of password.pwm.config.value.data.FormConfiguration in project pwm by pwm-project.

the class NewUserServlet method forwardToFormPage.

private void forwardToFormPage(final PwmRequest pwmRequest, final NewUserBean newUserBean) throws ServletException, PwmUnrecoverableException, IOException {
    final List<FormConfiguration> formConfigurations = getFormDefinition(pwmRequest);
    final NewUserProfile newUserProfile = getNewUserProfile(pwmRequest);
    final boolean promptForPassword = newUserProfile.readSettingAsBoolean(PwmSetting.NEWUSER_PROMPT_FOR_PASSWORD);
    final Map<FormConfiguration, String> formData = new HashMap<>();
    if (newUserBean.getRemoteInputData() != null) {
        final Map<String, String> remoteData = newUserBean.getRemoteInputData();
        for (final FormConfiguration formConfiguration : formConfigurations) {
            if (remoteData.containsKey(formConfiguration.getName())) {
                formData.put(formConfiguration, remoteData.get(formConfiguration.getName()));
            }
        }
    }
    pwmRequest.addFormInfoToRequestAttr(formConfigurations, formData, false, promptForPassword);
    {
        final boolean showBack = !newUserBean.isUrlSpecifiedProfile() && pwmRequest.getConfig().getNewUserProfiles().keySet().size() > 1;
        pwmRequest.setAttribute(PwmRequestAttribute.NewUser_FormShowBackButton, showBack);
    }
    pwmRequest.forwardToJsp(JspUrl.NEW_USER);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FormConfiguration(password.pwm.config.value.data.FormConfiguration) NewUserProfile(password.pwm.config.profile.NewUserProfile)

Example 57 with FormConfiguration

use of password.pwm.config.value.data.FormConfiguration in project pwm by pwm-project.

the class NewUserUtils method determineTokenValidationsRequired.

static Map<String, TokenDestinationItem.Type> determineTokenValidationsRequired(final PwmRequest pwmRequest, final NewUserBean newUserBean, final NewUserProfile newUserProfile) throws PwmUnrecoverableException {
    final List<FormConfiguration> formFields = newUserProfile.readSettingAsForm(PwmSetting.NEWUSER_FORM);
    final LdapProfile defaultLDAPProfile = pwmRequest.getConfig().getDefaultLdapProfile();
    final Map<String, TokenDestinationItem.Type> workingMap = new LinkedHashMap<>(FormUtility.identifyFormItemsNeedingPotentialTokenValidation(defaultLDAPProfile, formFields));
    final Set<TokenDestinationItem.Type> interestedTypes = new HashSet<>();
    if (newUserProfile.readSettingAsBoolean(PwmSetting.NEWUSER_EMAIL_VERIFICATION)) {
        interestedTypes.add(TokenDestinationItem.Type.email);
    }
    if (newUserProfile.readSettingAsBoolean(PwmSetting.NEWUSER_SMS_VERIFICATION)) {
        interestedTypes.add(TokenDestinationItem.Type.sms);
    }
    if (!JavaHelper.isEmpty(workingMap)) {
        final Map<String, String> formData = newUserBean.getNewUserForm().getFormData();
        for (final Iterator<Map.Entry<String, TokenDestinationItem.Type>> iter = workingMap.entrySet().iterator(); iter.hasNext(); ) {
            final Map.Entry<String, TokenDestinationItem.Type> entry = iter.next();
            final String attrName = entry.getKey();
            final TokenDestinationItem.Type type = entry.getValue();
            if (!interestedTypes.contains(type)) {
                iter.remove();
            }
            if (!formData.containsKey(attrName)) {
                iter.remove();
            }
        }
    }
    return Collections.unmodifiableMap(workingMap);
}
Also used : LdapProfile(password.pwm.config.profile.LdapProfile) TokenDestinationItem(password.pwm.bean.TokenDestinationItem) LinkedHashMap(java.util.LinkedHashMap) TokenType(password.pwm.svc.token.TokenType) FormConfiguration(password.pwm.config.value.data.FormConfiguration) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 58 with FormConfiguration

use of password.pwm.config.value.data.FormConfiguration in project pwm by pwm-project.

the class NewUserUtils method tokenDestinationItemForCurrentValidation.

static TokenDestinationItem tokenDestinationItemForCurrentValidation(final PwmRequest pwmRequest, final NewUserBean newUserBean, final NewUserProfile newUserProfile) throws PwmUnrecoverableException {
    if (!newUserBean.isFormPassed()) {
        return null;
    }
    final List<FormConfiguration> formFields = newUserProfile.readSettingAsForm(PwmSetting.NEWUSER_FORM);
    final LdapProfile defaultLDAPProfile = pwmRequest.getConfig().getDefaultLdapProfile();
    final Map<String, TokenDestinationItem.Type> tokenTypeMap = FormUtility.identifyFormItemsNeedingPotentialTokenValidation(defaultLDAPProfile, formFields);
    final String value = newUserBean.getNewUserForm().getFormData().get(newUserBean.getCurrentTokenField());
    final TokenDestinationItem.Type type = tokenTypeMap.get(newUserBean.getCurrentTokenField());
    return TokenDestinationItem.builder().display(value).id("1").value(value).type(type).build();
}
Also used : TokenType(password.pwm.svc.token.TokenType) FormConfiguration(password.pwm.config.value.data.FormConfiguration) LdapProfile(password.pwm.config.profile.LdapProfile) TokenDestinationItem(password.pwm.bean.TokenDestinationItem)

Example 59 with FormConfiguration

use of password.pwm.config.value.data.FormConfiguration in project pwm by pwm-project.

the class ForgottenPasswordUtil method initForgottenPasswordBean.

static void initForgottenPasswordBean(final PwmRequest pwmRequest, final UserIdentity userIdentity, final ForgottenPasswordBean forgottenPasswordBean) throws PwmUnrecoverableException, PwmOperationalException {
    final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
    final Locale locale = pwmRequest.getLocale();
    final SessionLabel sessionLabel = pwmRequest.getSessionLabel();
    forgottenPasswordBean.setUserIdentity(userIdentity);
    final UserInfo userInfo = readUserInfo(pwmRequest, forgottenPasswordBean);
    final ForgottenPasswordProfile forgottenPasswordProfile = forgottenPasswordProfile(pwmApplication, pwmRequest.getSessionLabel(), userIdentity);
    final String forgottenProfileID = forgottenPasswordProfile.getIdentifier();
    forgottenPasswordBean.setForgottenPasswordProfileID(forgottenProfileID);
    final ForgottenPasswordBean.RecoveryFlags recoveryFlags = calculateRecoveryFlags(pwmApplication, forgottenProfileID);
    final ChallengeSet challengeSet;
    if (recoveryFlags.getRequiredAuthMethods().contains(IdentityVerificationMethod.CHALLENGE_RESPONSES) || recoveryFlags.getOptionalAuthMethods().contains(IdentityVerificationMethod.CHALLENGE_RESPONSES)) {
        final ResponseSet responseSet;
        try {
            final ChaiUser theUser = pwmApplication.getProxiedChaiUser(userInfo.getUserIdentity());
            responseSet = pwmApplication.getCrService().readUserResponseSet(sessionLabel, userInfo.getUserIdentity(), theUser);
            challengeSet = responseSet == null ? null : responseSet.getPresentableChallengeSet();
        } catch (ChaiValidationException e) {
            final String errorMsg = "unable to determine presentable challengeSet for stored responses: " + e.getMessage();
            final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_NO_CHALLENGES, errorMsg);
            throw new PwmUnrecoverableException(errorInformation);
        } catch (ChaiUnavailableException e) {
            throw new PwmUnrecoverableException(PwmError.forChaiError(e.getErrorCode()));
        }
    } else {
        challengeSet = null;
    }
    if (!recoveryFlags.isAllowWhenLdapIntruderLocked()) {
        try {
            final ChaiUser chaiUser = pwmApplication.getProxiedChaiUser(userInfo.getUserIdentity());
            if (chaiUser.isPasswordLocked()) {
                throw new PwmUnrecoverableException(new ErrorInformation(PwmError.ERROR_INTRUDER_LDAP));
            }
        } catch (ChaiOperationException e) {
            final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_UNKNOWN, "error checking user '" + userInfo.getUserIdentity() + "' ldap intruder lock status: " + e.getMessage());
            LOGGER.error(sessionLabel, errorInformation);
            throw new PwmUnrecoverableException(errorInformation);
        } catch (ChaiUnavailableException e) {
            throw new PwmUnrecoverableException(PwmError.forChaiError(e.getErrorCode()));
        }
    }
    final List<FormConfiguration> attributeForm;
    try {
        attributeForm = figureAttributeForm(forgottenPasswordProfile, forgottenPasswordBean, pwmRequest, userIdentity);
    } catch (ChaiUnavailableException e) {
        throw new PwmUnrecoverableException(PwmError.forChaiError(e.getErrorCode()));
    }
    forgottenPasswordBean.setUserLocale(locale);
    forgottenPasswordBean.setPresentableChallengeSet(challengeSet);
    forgottenPasswordBean.setAttributeForm(attributeForm);
    forgottenPasswordBean.setRecoveryFlags(recoveryFlags);
    forgottenPasswordBean.setProgress(new ForgottenPasswordBean.Progress());
    for (final IdentityVerificationMethod recoveryVerificationMethods : recoveryFlags.getRequiredAuthMethods()) {
        verifyRequirementsForAuthMethod(pwmRequest, forgottenPasswordBean, recoveryVerificationMethods);
    }
}
Also used : Locale(java.util.Locale) ForgottenPasswordProfile(password.pwm.config.profile.ForgottenPasswordProfile) IdentityVerificationMethod(password.pwm.config.option.IdentityVerificationMethod) PwmApplication(password.pwm.PwmApplication) ChallengeSet(com.novell.ldapchai.cr.ChallengeSet) ChaiUnavailableException(com.novell.ldapchai.exception.ChaiUnavailableException) ResponseSet(com.novell.ldapchai.cr.ResponseSet) UserInfo(password.pwm.ldap.UserInfo) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) SessionLabel(password.pwm.bean.SessionLabel) ErrorInformation(password.pwm.error.ErrorInformation) ChaiValidationException(com.novell.ldapchai.exception.ChaiValidationException) ChaiUser(com.novell.ldapchai.ChaiUser) FormConfiguration(password.pwm.config.value.data.FormConfiguration) ChaiOperationException(com.novell.ldapchai.exception.ChaiOperationException) ForgottenPasswordBean(password.pwm.http.bean.ForgottenPasswordBean)

Example 60 with FormConfiguration

use of password.pwm.config.value.data.FormConfiguration in project pwm by pwm-project.

the class HelpdeskServletUtil method getSearchFilter.

static String getSearchFilter(final Configuration configuration, final HelpdeskProfile helpdeskProfile) {
    final String configuredFilter = helpdeskProfile.readSettingAsString(PwmSetting.HELPDESK_SEARCH_FILTER);
    if (configuredFilter != null && !configuredFilter.isEmpty()) {
        return configuredFilter;
    }
    final List<String> defaultObjectClasses = configuration.readSettingAsStringArray(PwmSetting.DEFAULT_OBJECT_CLASSES);
    final List<FormConfiguration> searchAttributes = helpdeskProfile.readSettingAsForm(PwmSetting.HELPDESK_SEARCH_FORM);
    final StringBuilder filter = new StringBuilder();
    // open AND clause for objectclasses and attributes
    filter.append("(&");
    for (final String objectClass : defaultObjectClasses) {
        filter.append("(objectClass=").append(objectClass).append(")");
    }
    // open OR clause for attributes
    filter.append("(|");
    for (final FormConfiguration formConfiguration : searchAttributes) {
        if (formConfiguration != null && formConfiguration.getName() != null) {
            final String searchAttribute = formConfiguration.getName();
            filter.append("(").append(searchAttribute).append("=*").append(PwmConstants.VALUE_REPLACEMENT_USERNAME).append("*)");
        }
    }
    // close OR clause
    filter.append(")");
    // close AND clause
    filter.append(")");
    return filter.toString();
}
Also used : FormConfiguration(password.pwm.config.value.data.FormConfiguration)

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