diff --git a/source/java/org/alfresco/repo/security/authentication/AuthenticationComponentImpl.java b/source/java/org/alfresco/repo/security/authentication/AuthenticationComponentImpl.java index e4a7e9939c..eabd161f59 100644 --- a/source/java/org/alfresco/repo/security/authentication/AuthenticationComponentImpl.java +++ b/source/java/org/alfresco/repo/security/authentication/AuthenticationComponentImpl.java @@ -103,12 +103,13 @@ public class AuthenticationComponentImpl extends AbstractAuthenticationComponent public String doWork() throws Exception { String normalized = getPersonService().getUserIdentifier(userName); + String finalUserName = normalized == null ? userName : normalized; UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken( - normalized == null ? userName : normalized, new String(password)); + finalUserName, new String(password)); authenticationManager.authenticate(authentication); // check whether the user's password requires re-hashing - UserDetails userDetails = authenticationDao.loadUserByUsername(userName); + UserDetails userDetails = authenticationDao.loadUserByUsername(finalUserName); if (userDetails instanceof RepositoryAuthenticatedUser) { List hashIndicator = ((RepositoryAuthenticatedUser)userDetails).getHashIndicator(); diff --git a/source/java/org/alfresco/repo/security/authentication/HashPasswordTransactionListener.java b/source/java/org/alfresco/repo/security/authentication/HashPasswordTransactionListener.java index a06c65542e..7055c379d7 100644 --- a/source/java/org/alfresco/repo/security/authentication/HashPasswordTransactionListener.java +++ b/source/java/org/alfresco/repo/security/authentication/HashPasswordTransactionListener.java @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2005-2015 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ package org.alfresco.repo.security.authentication; import org.alfresco.repo.transaction.RetryingTransactionHelper; @@ -7,6 +25,12 @@ import org.alfresco.service.transaction.TransactionService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +/** + * Transaction listener that re-generates the hash of a users password in + * the afterCommit callback. + * + * @author Gavin Cornwell + */ public class HashPasswordTransactionListener implements TransactionListener { private static Log logger = LogFactory.getLog(HashPasswordTransactionListener.class);