|
@@ -29,6 +29,7 @@ import com.novell.ldapchai.provider.ChaiSetting;
|
|
import com.novell.ldapchai.provider.DirectoryVendor;
|
|
import com.novell.ldapchai.provider.DirectoryVendor;
|
|
import password.pwm.AppProperty;
|
|
import password.pwm.AppProperty;
|
|
import password.pwm.PwmApplication;
|
|
import password.pwm.PwmApplication;
|
|
|
|
+import password.pwm.VerificationMethodSystem;
|
|
import password.pwm.bean.EmailItemBean;
|
|
import password.pwm.bean.EmailItemBean;
|
|
import password.pwm.bean.LoginInfoBean;
|
|
import password.pwm.bean.LoginInfoBean;
|
|
import password.pwm.bean.SessionLabel;
|
|
import password.pwm.bean.SessionLabel;
|
|
@@ -47,10 +48,13 @@ import password.pwm.error.PwmDataValidationException;
|
|
import password.pwm.error.PwmError;
|
|
import password.pwm.error.PwmError;
|
|
import password.pwm.error.PwmOperationalException;
|
|
import password.pwm.error.PwmOperationalException;
|
|
import password.pwm.error.PwmUnrecoverableException;
|
|
import password.pwm.error.PwmUnrecoverableException;
|
|
|
|
+import password.pwm.http.JspUrl;
|
|
import password.pwm.http.ProcessStatus;
|
|
import password.pwm.http.ProcessStatus;
|
|
import password.pwm.http.PwmRequest;
|
|
import password.pwm.http.PwmRequest;
|
|
|
|
+import password.pwm.http.PwmRequestAttribute;
|
|
import password.pwm.http.PwmSession;
|
|
import password.pwm.http.PwmSession;
|
|
import password.pwm.http.bean.NewUserBean;
|
|
import password.pwm.http.bean.NewUserBean;
|
|
|
|
+import password.pwm.http.servlet.forgottenpw.RemoteVerificationMethod;
|
|
import password.pwm.ldap.UserInfo;
|
|
import password.pwm.ldap.UserInfo;
|
|
import password.pwm.ldap.UserInfoBean;
|
|
import password.pwm.ldap.UserInfoBean;
|
|
import password.pwm.ldap.auth.PwmAuthenticationSource;
|
|
import password.pwm.ldap.auth.PwmAuthenticationSource;
|
|
@@ -62,7 +66,6 @@ import password.pwm.svc.stats.Statistic;
|
|
import password.pwm.svc.token.TokenType;
|
|
import password.pwm.svc.token.TokenType;
|
|
import password.pwm.svc.token.TokenUtil;
|
|
import password.pwm.svc.token.TokenUtil;
|
|
import password.pwm.util.PasswordData;
|
|
import password.pwm.util.PasswordData;
|
|
-import password.pwm.util.password.RandomPasswordGenerator;
|
|
|
|
import password.pwm.util.form.FormUtility;
|
|
import password.pwm.util.form.FormUtility;
|
|
import password.pwm.util.java.JavaHelper;
|
|
import password.pwm.util.java.JavaHelper;
|
|
import password.pwm.util.java.JsonUtil;
|
|
import password.pwm.util.java.JsonUtil;
|
|
@@ -72,6 +75,7 @@ import password.pwm.util.logging.PwmLogger;
|
|
import password.pwm.util.macro.MacroMachine;
|
|
import password.pwm.util.macro.MacroMachine;
|
|
import password.pwm.util.operations.ActionExecutor;
|
|
import password.pwm.util.operations.ActionExecutor;
|
|
import password.pwm.util.password.PasswordUtility;
|
|
import password.pwm.util.password.PasswordUtility;
|
|
|
|
+import password.pwm.util.password.RandomPasswordGenerator;
|
|
import password.pwm.ws.client.rest.form.FormDataRequestBean;
|
|
import password.pwm.ws.client.rest.form.FormDataRequestBean;
|
|
import password.pwm.ws.client.rest.form.FormDataResponseBean;
|
|
import password.pwm.ws.client.rest.form.FormDataResponseBean;
|
|
import password.pwm.ws.client.rest.form.RestFormDataClient;
|
|
import password.pwm.ws.client.rest.form.RestFormDataClient;
|
|
@@ -162,11 +166,11 @@ class NewUserUtils
|
|
|
|
|
|
// add the auto-add object classes
|
|
// add the auto-add object classes
|
|
{
|
|
{
|
|
- final LdapProfile defaultLDAPProfile = pwmApplication.getConfig().getDefaultLdapProfile();
|
|
|
|
|
|
+ final LdapProfile defaultLDAPProfile = newUserProfile.getLdapProfile();
|
|
createObjectClasses.addAll( defaultLDAPProfile.readSettingAsStringArray( PwmSetting.AUTO_ADD_OBJECT_CLASSES ) );
|
|
createObjectClasses.addAll( defaultLDAPProfile.readSettingAsStringArray( PwmSetting.AUTO_ADD_OBJECT_CLASSES ) );
|
|
}
|
|
}
|
|
|
|
|
|
- final ChaiProvider chaiProvider = pwmApplication.getConfig().getDefaultLdapProfile().getProxyChaiProvider( pwmApplication );
|
|
|
|
|
|
+ final ChaiProvider chaiProvider = newUserProfile.getLdapProfile().getProxyChaiProvider( pwmApplication );
|
|
try
|
|
try
|
|
{
|
|
{
|
|
// create the ldap entry
|
|
// create the ldap entry
|
|
@@ -302,7 +306,7 @@ class NewUserUtils
|
|
remoteWriteFormData( pwmRequest, newUserForm );
|
|
remoteWriteFormData( pwmRequest, newUserForm );
|
|
|
|
|
|
// authenticate the user to pwm
|
|
// authenticate the user to pwm
|
|
- final UserIdentity userIdentity = new UserIdentity( newUserDN, pwmApplication.getConfig().getDefaultLdapProfile().getIdentifier() );
|
|
|
|
|
|
+ final UserIdentity userIdentity = new UserIdentity( newUserDN, newUserProfile.getLdapProfile().getIdentifier() );
|
|
final SessionAuthenticator sessionAuthenticator = new SessionAuthenticator( pwmApplication, pwmRequest, PwmAuthenticationSource.NEW_USER_REGISTRATION );
|
|
final SessionAuthenticator sessionAuthenticator = new SessionAuthenticator( pwmApplication, pwmRequest, PwmAuthenticationSource.NEW_USER_REGISTRATION );
|
|
sessionAuthenticator.authenticateUser( userIdentity, userPassword );
|
|
sessionAuthenticator.authenticateUser( userIdentity, userPassword );
|
|
|
|
|
|
@@ -345,8 +349,9 @@ class NewUserUtils
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
|
|
+ final NewUserProfile newUserProfile = NewUserServlet.getNewUserProfile( pwmRequest );
|
|
NewUserUtils.LOGGER.warn( pwmRequest, () -> "deleting ldap user account " + userDN );
|
|
NewUserUtils.LOGGER.warn( pwmRequest, () -> "deleting ldap user account " + userDN );
|
|
- pwmRequest.getConfig().getDefaultLdapProfile().getProxyChaiProvider( pwmRequest.getPwmApplication() ).deleteEntry( userDN );
|
|
|
|
|
|
+ newUserProfile.getLdapProfile().getProxyChaiProvider( pwmRequest.getPwmApplication() ).deleteEntry( userDN );
|
|
NewUserUtils.LOGGER.warn( pwmRequest, () -> "ldap user account " + userDN + " has been deleted" );
|
|
NewUserUtils.LOGGER.warn( pwmRequest, () -> "ldap user account " + userDN + " has been deleted" );
|
|
}
|
|
}
|
|
catch ( final ChaiUnavailableException | ChaiOperationException e )
|
|
catch ( final ChaiUnavailableException | ChaiOperationException e )
|
|
@@ -363,8 +368,8 @@ class NewUserUtils
|
|
)
|
|
)
|
|
throws PwmUnrecoverableException, ChaiUnavailableException
|
|
throws PwmUnrecoverableException, ChaiUnavailableException
|
|
{
|
|
{
|
|
- final MacroMachine macroMachine = createMacroMachineForNewUser( pwmRequest.getPwmApplication(), pwmRequest.getLabel(), formValues, null );
|
|
|
|
final NewUserProfile newUserProfile = NewUserServlet.getNewUserProfile( pwmRequest );
|
|
final NewUserProfile newUserProfile = NewUserServlet.getNewUserProfile( pwmRequest );
|
|
|
|
+ final MacroMachine macroMachine = createMacroMachineForNewUser( pwmRequest.getPwmApplication(), newUserProfile, pwmRequest.getLabel(), formValues, null );
|
|
final List<String> configuredNames = newUserProfile.readSettingAsStringArray( PwmSetting.NEWUSER_USERNAME_DEFINITION );
|
|
final List<String> configuredNames = newUserProfile.readSettingAsStringArray( PwmSetting.NEWUSER_USERNAME_DEFINITION );
|
|
final List<String> failedValues = new ArrayList<>();
|
|
final List<String> failedValues = new ArrayList<>();
|
|
|
|
|
|
@@ -374,7 +379,7 @@ class NewUserUtils
|
|
|
|
|
|
if ( configuredNames == null || configuredNames.isEmpty() || configuredNames.iterator().next().isEmpty() )
|
|
if ( configuredNames == null || configuredNames.isEmpty() || configuredNames.iterator().next().isEmpty() )
|
|
{
|
|
{
|
|
- final String namingAttribute = pwmRequest.getConfig().getDefaultLdapProfile().readSettingAsString( PwmSetting.LDAP_NAMING_ATTRIBUTE );
|
|
|
|
|
|
+ final String namingAttribute = newUserProfile.getLdapProfile().readSettingAsString( PwmSetting.LDAP_NAMING_ATTRIBUTE );
|
|
String namingValue = null;
|
|
String namingValue = null;
|
|
for ( final String formKey : formValues.getFormData().keySet() )
|
|
for ( final String formKey : formValues.getFormData().keySet() )
|
|
{
|
|
{
|
|
@@ -408,7 +413,7 @@ class NewUserUtils
|
|
if ( !testIfEntryNameExists( pwmRequest, expandedName ) )
|
|
if ( !testIfEntryNameExists( pwmRequest, expandedName ) )
|
|
{
|
|
{
|
|
NewUserUtils.LOGGER.trace( pwmRequest, () -> "generated entry name for new user is unique: " + expandedName );
|
|
NewUserUtils.LOGGER.trace( pwmRequest, () -> "generated entry name for new user is unique: " + expandedName );
|
|
- final String namingAttribute = pwmRequest.getConfig().getDefaultLdapProfile().readSettingAsString( PwmSetting.LDAP_NAMING_ATTRIBUTE );
|
|
|
|
|
|
+ final String namingAttribute = newUserProfile.getLdapProfile().readSettingAsString( PwmSetting.LDAP_NAMING_ATTRIBUTE );
|
|
final String escapedName = StringUtil.escapeLdapDN( expandedName );
|
|
final String escapedName = StringUtil.escapeLdapDN( expandedName );
|
|
generatedDN = namingAttribute + "=" + escapedName + "," + expandedContext;
|
|
generatedDN = namingAttribute + "=" + escapedName + "," + expandedContext;
|
|
NewUserUtils.LOGGER.debug( pwmRequest, () -> "generated dn for new user: " + generatedDN );
|
|
NewUserUtils.LOGGER.debug( pwmRequest, () -> "generated dn for new user: " + generatedDN );
|
|
@@ -482,29 +487,41 @@ class NewUserUtils
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ static UserInfoBean createUserInfoBeanForNewUser(
|
|
|
|
+ final PwmApplication pwmApplication,
|
|
|
|
+ final NewUserProfile newUserProfile,
|
|
|
|
+ final NewUserForm newUserForm
|
|
|
|
+ )
|
|
|
|
+ throws PwmUnrecoverableException
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+ final Map<String, String> formValues = newUserForm.getFormData();
|
|
|
|
+
|
|
|
|
+ final String emailAddressAttribute = newUserProfile.getLdapProfile().readSettingAsString(
|
|
|
|
+ PwmSetting.EMAIL_USER_MAIL_ATTRIBUTE );
|
|
|
|
+
|
|
|
|
+ final String usernameAttribute = newUserProfile.getLdapProfile().readSettingAsString( PwmSetting.LDAP_USERNAME_ATTRIBUTE );
|
|
|
|
+
|
|
|
|
+ return UserInfoBean.builder()
|
|
|
|
+ .userEmailAddress( formValues.get( emailAddressAttribute ) )
|
|
|
|
+ .username( formValues.get( usernameAttribute ) )
|
|
|
|
+ .attributes( formValues )
|
|
|
|
+ .build();
|
|
|
|
+ }
|
|
|
|
+
|
|
static MacroMachine createMacroMachineForNewUser(
|
|
static MacroMachine createMacroMachineForNewUser(
|
|
final PwmApplication pwmApplication,
|
|
final PwmApplication pwmApplication,
|
|
|
|
+ final NewUserProfile newUserProfile,
|
|
final SessionLabel sessionLabel,
|
|
final SessionLabel sessionLabel,
|
|
final NewUserForm newUserForm,
|
|
final NewUserForm newUserForm,
|
|
final TokenDestinationItem tokenDestinationItem
|
|
final TokenDestinationItem tokenDestinationItem
|
|
)
|
|
)
|
|
throws PwmUnrecoverableException
|
|
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();
|
|
final LoginInfoBean stubLoginBean = new LoginInfoBean();
|
|
stubLoginBean.setUserCurrentPassword( newUserForm.getNewUserPassword() );
|
|
stubLoginBean.setUserCurrentPassword( newUserForm.getNewUserPassword() );
|
|
|
|
|
|
- final UserInfoBean stubUserBean = UserInfoBean.builder()
|
|
|
|
- .userEmailAddress( formValues.get( emailAddressAttribute ) )
|
|
|
|
- .username( formValues.get( usernameAttribute ) )
|
|
|
|
- .attributes( formValues )
|
|
|
|
- .build();
|
|
|
|
|
|
+ final UserInfoBean stubUserBean = createUserInfoBeanForNewUser( pwmApplication, newUserProfile, newUserForm );
|
|
|
|
|
|
final MacroMachine.StringReplacer stringReplacer = tokenDestinationItem == null
|
|
final MacroMachine.StringReplacer stringReplacer = tokenDestinationItem == null
|
|
? null
|
|
? null
|
|
@@ -608,7 +625,7 @@ class NewUserUtils
|
|
throws PwmUnrecoverableException
|
|
throws PwmUnrecoverableException
|
|
{
|
|
{
|
|
final List<FormConfiguration> formFields = newUserProfile.readSettingAsForm( PwmSetting.NEWUSER_FORM );
|
|
final List<FormConfiguration> formFields = newUserProfile.readSettingAsForm( PwmSetting.NEWUSER_FORM );
|
|
- final LdapProfile defaultLDAPProfile = pwmRequest.getConfig().getDefaultLdapProfile();
|
|
|
|
|
|
+ final LdapProfile defaultLDAPProfile = newUserProfile.getLdapProfile();
|
|
|
|
|
|
final Map<String, TokenDestinationItem.Type> workingMap = new LinkedHashMap<>( FormUtility.identifyFormItemsNeedingPotentialTokenValidation(
|
|
final Map<String, TokenDestinationItem.Type> workingMap = new LinkedHashMap<>( FormUtility.identifyFormItemsNeedingPotentialTokenValidation(
|
|
defaultLDAPProfile,
|
|
defaultLDAPProfile,
|
|
@@ -649,6 +666,60 @@ class NewUserUtils
|
|
return Collections.unmodifiableMap( workingMap );
|
|
return Collections.unmodifiableMap( workingMap );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ static ProcessStatus checkForExternalResponsesVerificationProgress(
|
|
|
|
+ final PwmRequest pwmRequest,
|
|
|
|
+ final NewUserBean newUserBean,
|
|
|
|
+ final NewUserProfile newUserProfile
|
|
|
|
+ )
|
|
|
|
+ throws PwmUnrecoverableException, ServletException, IOException
|
|
|
|
+ {
|
|
|
|
+ if ( newUserProfile.readSettingAsBoolean( PwmSetting.NEWUSER_EXTERNAL_VERIFICATION ) )
|
|
|
|
+ {
|
|
|
|
+ if ( !newUserBean.isExternalResponsesPassed() )
|
|
|
|
+ {
|
|
|
|
+ final VerificationMethodSystem remoteMethod = readRemoteVerificationMethod( pwmRequest, newUserBean );
|
|
|
|
+
|
|
|
|
+ final List<VerificationMethodSystem.UserPrompt> prompts = remoteMethod.getCurrentPrompts();
|
|
|
|
+ final String displayInstructions = remoteMethod.getCurrentDisplayInstructions();
|
|
|
|
+
|
|
|
|
+ pwmRequest.setAttribute( PwmRequestAttribute.ExternalResponsePrompts, new ArrayList<>( prompts ) );
|
|
|
|
+ pwmRequest.setAttribute( PwmRequestAttribute.ExternalResponseInstructions, displayInstructions );
|
|
|
|
+ pwmRequest.forwardToJsp( JspUrl.NEW_USER_REMOTE );
|
|
|
|
+ return ProcessStatus.Halt;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ProcessStatus.Continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static VerificationMethodSystem readRemoteVerificationMethod(
|
|
|
|
+ final PwmRequest pwmRequest,
|
|
|
|
+ final NewUserBean newUserBean
|
|
|
|
+ )
|
|
|
|
+ throws PwmUnrecoverableException
|
|
|
|
+ {
|
|
|
|
+ final NewUserProfile newUserProfile = NewUserServlet.getNewUserProfile( pwmRequest );
|
|
|
|
+ final UserInfo userInfo = createUserInfoBeanForNewUser( pwmRequest.getPwmApplication(), newUserProfile, newUserBean.getNewUserForm() );
|
|
|
|
+
|
|
|
|
+ final VerificationMethodSystem remoteMethod;
|
|
|
|
+ if ( newUserBean.getRemoteRecoveryMethod() == null )
|
|
|
|
+ {
|
|
|
|
+ remoteMethod = new RemoteVerificationMethod();
|
|
|
|
+ remoteMethod.init(
|
|
|
|
+ pwmRequest.getPwmApplication(),
|
|
|
|
+ userInfo,
|
|
|
|
+ pwmRequest.getLabel(),
|
|
|
|
+ pwmRequest.getLocale()
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ remoteMethod = newUserBean.getRemoteRecoveryMethod();
|
|
|
|
+ }
|
|
|
|
+ newUserBean.setRemoteRecoveryMethod( remoteMethod );
|
|
|
|
+ return remoteMethod;
|
|
|
|
+ }
|
|
|
|
+
|
|
static ProcessStatus checkForTokenVerificationProgress(
|
|
static ProcessStatus checkForTokenVerificationProgress(
|
|
final PwmRequest pwmRequest,
|
|
final PwmRequest pwmRequest,
|
|
final NewUserBean newUserBean,
|
|
final NewUserBean newUserBean,
|
|
@@ -689,6 +760,7 @@ class NewUserUtils
|
|
final Map<String, String> tokenPayloadMap = NewUserFormUtils.toTokenPayload( pwmRequest, newUserBean );
|
|
final Map<String, String> tokenPayloadMap = NewUserFormUtils.toTokenPayload( pwmRequest, newUserBean );
|
|
final MacroMachine macroMachine = createMacroMachineForNewUser(
|
|
final MacroMachine macroMachine = createMacroMachineForNewUser(
|
|
pwmRequest.getPwmApplication(),
|
|
pwmRequest.getPwmApplication(),
|
|
|
|
+ newUserProfile,
|
|
pwmRequest.getLabel(),
|
|
pwmRequest.getLabel(),
|
|
newUserBean.getNewUserForm(),
|
|
newUserBean.getNewUserForm(),
|
|
tokenDestinationItem );
|
|
tokenDestinationItem );
|
|
@@ -733,7 +805,7 @@ class NewUserUtils
|
|
}
|
|
}
|
|
|
|
|
|
final List<FormConfiguration> formFields = newUserProfile.readSettingAsForm( PwmSetting.NEWUSER_FORM );
|
|
final List<FormConfiguration> formFields = newUserProfile.readSettingAsForm( PwmSetting.NEWUSER_FORM );
|
|
- final LdapProfile defaultLDAPProfile = pwmRequest.getConfig().getDefaultLdapProfile();
|
|
|
|
|
|
+ final LdapProfile defaultLDAPProfile = newUserProfile.getLdapProfile();
|
|
|
|
|
|
final Map<String, TokenDestinationItem.Type> tokenTypeMap = FormUtility.identifyFormItemsNeedingPotentialTokenValidation(
|
|
final Map<String, TokenDestinationItem.Type> tokenTypeMap = FormUtility.identifyFormItemsNeedingPotentialTokenValidation(
|
|
defaultLDAPProfile,
|
|
defaultLDAPProfile,
|