use of password.pwm.ldap.UserInfoBean in project pwm by pwm-project.
the class NewUserUtils method createMacroMachineForNewUser.
static MacroMachine createMacroMachineForNewUser(final PwmApplication pwmApplication, final SessionLabel sessionLabel, final NewUserForm newUserForm, final TokenDestinationItem tokenDestinationItem) throws PwmUnrecoverableException {
final Map<String, String> formValues = newUserForm.getFormData();
final String emailAddressAttribute = pwmApplication.getConfig().getDefaultLdapProfile().readSettingAsString(PwmSetting.EMAIL_USER_MAIL_ATTRIBUTE);
final String usernameAttribute = pwmApplication.getConfig().getDefaultLdapProfile().readSettingAsString(PwmSetting.LDAP_USERNAME_ATTRIBUTE);
final LoginInfoBean stubLoginBean = new LoginInfoBean();
stubLoginBean.setUserCurrentPassword(newUserForm.getNewUserPassword());
final UserInfoBean stubUserBean = UserInfoBean.builder().userEmailAddress(formValues.get(emailAddressAttribute)).username(formValues.get(usernameAttribute)).attributes(formValues).build();
final MacroMachine.StringReplacer stringReplacer = tokenDestinationItem == null ? null : TokenUtil.makeTokenDestStringReplacer(tokenDestinationItem);
return MacroMachine.forUser(pwmApplication, sessionLabel, stubUserBean, stubLoginBean, stringReplacer);
}
Aggregations