mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
MNT-17199 - CSV user import: if password is left blank it should be randomly generated
Modified UserCSVUploadPost behaviour to use an empty string for password creation instead of the user's first name. Modified RepositoryAuthenticationDao > createUser behaviour to treat the case when the password is an empty string or null. Added a Unit test. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@136902 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -30,8 +30,9 @@ import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.sf.acegisecurity.GrantedAuthority;
|
||||
import net.sf.acegisecurity.GrantedAuthorityImpl;
|
||||
import net.sf.acegisecurity.UserDetails;
|
||||
@@ -352,7 +353,14 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao, In
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||
properties.put(ContentModel.PROP_USER_USERNAME, caseSensitiveUserName);
|
||||
String salt = GUID.generate();
|
||||
properties.put(ContentModel.PROP_SALT, salt);
|
||||
properties.put(ContentModel.PROP_SALT, salt);
|
||||
|
||||
boolean emptyPassword = rawPassword != null ? "".equals(new String(rawPassword)) : true;
|
||||
|
||||
if (emptyPassword)
|
||||
{
|
||||
rawPassword = UUID.randomUUID().toString().toCharArray();
|
||||
}
|
||||
|
||||
if (hashedPassword == null)
|
||||
{
|
||||
@@ -373,8 +381,8 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao, In
|
||||
properties.put(ContentModel.PROP_PASSWORD_HASH, hashedPassword);
|
||||
properties.put(ContentModel.PROP_HASH_INDICATOR, (Serializable) Arrays.asList(compositePasswordEncoder.getPreferredEncoding()));
|
||||
properties.put(ContentModel.PROP_ACCOUNT_EXPIRES, Boolean.valueOf(false));
|
||||
properties.put(ContentModel.PROP_CREDENTIALS_EXPIRE, Boolean.valueOf(false));
|
||||
properties.put(ContentModel.PROP_ENABLED, Boolean.valueOf(true));
|
||||
properties.put(ContentModel.PROP_CREDENTIALS_EXPIRE, Boolean.valueOf(false));
|
||||
properties.put(ContentModel.PROP_ENABLED, Boolean.valueOf(!emptyPassword));
|
||||
properties.put(ContentModel.PROP_ACCOUNT_LOCKED, Boolean.valueOf(false));
|
||||
nodeService.createNode(typesNode, ContentModel.ASSOC_CHILDREN, QName.createQName(ContentModel.USER_MODEL_URI,
|
||||
caseSensitiveUserName), ContentModel.TYPE_USER, properties);
|
||||
|
Reference in New Issue
Block a user