Merged 5.1-MC1 (5.1.0) to HEAD (5.1)

119057 adavis: Merged 5.1.N (5.1.1) to 5.1-MC1 (5.1.0)
      117339 adavis: Merged 5.0.2-CLOUD42 (Cloud ) to 5.1.N (5.1.1)
         117247 adavis: Merged 5.0.2-CLOUD (Cloud ) to 5.0.2-CLOUD42 (Cloud )
            114516 adavis: Merged BCRYPT to 5.0.2-CLOUD
               114004 gjames: Added a hashUserPassword method, and working on UpgradePasswordHashTest MNT-14892


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@119896 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jean-Pierre Huynh
2015-12-10 09:59:53 +00:00
parent 05375c63fc
commit 1670fcce1e
6 changed files with 158 additions and 20 deletions

View File

@@ -41,7 +41,8 @@ import org.springframework.dao.DataAccessException;
* getMD4HashedPassword(String userName)
* loadUserByUsername(String arg0)
* getSalt(UserDetails user)
*
* hashUserPassword(String userName)
*
* @author Andy Hind
*/
public class DefaultMutableAuthenticationDao implements MutableAuthenticationDao
@@ -385,7 +386,15 @@ public class DefaultMutableAuthenticationDao implements MutableAuthenticationDao
throw new AlfrescoRuntimeException("Not implemented");
}
/**
* @throws AlfrescoRuntimeException always
*/
@Override
public void hashUserPassword(String userName) throws AuthenticationException
{
throw new AlfrescoRuntimeException("Not implemented");
}
// -------- //
// Bean IOC //
// -------- //

View File

@@ -51,6 +51,11 @@ public interface MutableAuthenticationDao extends AuthenticationDao, SaltSource
*/
public boolean userExists(String userName);
/**
* Hashes the user password to the preferred encoding.
*/
public void hashUserPassword(String userName) throws AuthenticationException;
/**
* Enable/disable a user.
*/

View File

@@ -468,7 +468,23 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao, In
{
return (getUserOrNull(userName) != null);
}
@Override
public void hashUserPassword(String userName) throws AuthenticationException
{
NodeRef userRef = getUserOrNull(userName);
if (userRef == null)
{
throw new AuthenticationException("User name does not exist: " + userName);
}
Map<QName, Serializable> properties = nodeService.getProperties(userRef);
if (rehashedPassword(properties))
{
nodeService.setProperties(userRef, properties);
}
}
/**
* @return Returns the user properties or <tt>null</tt> if there are none
*/

View File

@@ -42,6 +42,7 @@ import org.alfresco.repo.lock.LockAcquisitionException;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.site.SiteModel;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
@@ -277,7 +278,19 @@ public class UpgradePasswordHashWorker implements ApplicationContextAware, Initi
BatchProcessWorker<Long> worker = new UpgradePasswordHashBatch(progress);
RetryingTransactionHelper retryingTransactionHelper = transactionService.getRetryingTransactionHelper();
retryingTransactionHelper.setForceWritable(true);
//Create the QNames if they don't exist
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
qnameDAO.getOrCreateQName(ContentModel.PROP_PASSWORD_HASH);
qnameDAO.getOrCreateQName(ContentModel.PROP_HASH_INDICATOR);
return null;
}
}, false, true);
BatchProcessor<Long> batchProcessor = new BatchProcessor<Long>(
"UpgradePasswordHashWorker",
retryingTransactionHelper,
@@ -398,16 +411,13 @@ public class UpgradePasswordHashWorker implements ApplicationContextAware, Initi
// We do not want any behaviours associated with our transactions
behaviourFilter.disableBehaviour();
// call hashedPassword on the RepositoryAuthenticationDao object
// ((RepositoryAuthenticationDao)authenticationDao).rehashedPassword(userProps);
if (logger.isDebugEnabled())
{
logger.debug("Upgrading password hash for user: " + username);
}
authenticationDao.hashUserPassword(username);
}
else if (logger.isTraceEnabled())
{

View File

@@ -237,6 +237,15 @@ public class NullMutableAuthenticationDao implements MutableAuthenticationDao
throw new AlfrescoRuntimeException("Not implemented");
}
/**
* @throws AlfrescoRuntimeException always
*/
@Override
public void hashUserPassword(String userName) throws AuthenticationException
{
throw new AlfrescoRuntimeException("Not implemented");
}
/**
* @throws AlfrescoRuntimeException Not implemented
*/