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);
}
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);
}
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();
}
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);
}
}
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();
}
Aggregations