Merged V3.2 to HEAD

15828: ETHREEOH-2601: Users dialog won't delete users who have no authentication information
      - Moved the AuthenticationService.deleteAuthentication() call inside PersonService.deletePerson() and protected with try - catch so that if there is no authentication information (for an upgraded/moved user) the person can still be deleted
      - Removed a bunch of redundant deleteAuthentication() calls


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@15829 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2009-08-20 11:01:19 +00:00
parent 9974e627e8
commit e2dff77bc6
6 changed files with 27 additions and 34 deletions

View File

@@ -304,6 +304,9 @@
<property name="authorityService"> <property name="authorityService">
<ref bean="authorityService" /> <ref bean="authorityService" />
</property> </property>
<property name="authenticationService">
<ref bean="authenticationService" />
</property>
<property name="dictionaryService"> <property name="dictionaryService">
<ref bean="dictionaryService" /> <ref bean="dictionaryService" />
</property> </property>

View File

@@ -541,11 +541,7 @@ public class SiteActivityTest extends TestCase
protected void deleteUser(String userName) protected void deleteUser(String userName)
{ {
if (authenticationService.authenticationExists(userName) == true) personService.deletePerson(userName);
{
personService.deletePerson(userName);
authenticationService.deleteAuthentication(userName);
}
} }
private void login(String username, String password) private void login(String username, String password)

View File

@@ -29,12 +29,10 @@ import java.util.List;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.repo.site.SiteModel; import org.alfresco.repo.site.SiteModel;
import org.alfresco.service.cmr.invitation.InvitationExceptionUserError; import org.alfresco.service.cmr.invitation.Invitation;
import org.alfresco.service.cmr.invitation.InvitationSearchCriteria; import org.alfresco.service.cmr.invitation.InvitationSearchCriteria;
import org.alfresco.service.cmr.invitation.InvitationService; import org.alfresco.service.cmr.invitation.InvitationService;
import org.alfresco.service.cmr.invitation.Invitation;
import org.alfresco.service.cmr.invitation.ModeratedInvitation; import org.alfresco.service.cmr.invitation.ModeratedInvitation;
import org.alfresco.service.cmr.invitation.NominatedInvitation; import org.alfresco.service.cmr.invitation.NominatedInvitation;
import org.alfresco.service.cmr.invitation.Invitation.ResourceType; import org.alfresco.service.cmr.invitation.Invitation.ResourceType;
@@ -56,7 +54,6 @@ public class InvitationServiceImplTest extends BaseAlfrescoSpringTest
private AuthenticationComponent authenticationComponent; private AuthenticationComponent authenticationComponent;
private PersonService personService; private PersonService personService;
private InvitationService invitationService; private InvitationService invitationService;
private MutableAuthenticationDao mutableAuthenticationDao;
private final String SITE_SHORT_NAME_INVITE = "InvitationTest"; private final String SITE_SHORT_NAME_INVITE = "InvitationTest";
private final String SITE_SHORT_NAME_RED = "InvitationTestRed"; private final String SITE_SHORT_NAME_RED = "InvitationTestRed";
@@ -85,7 +82,6 @@ public class InvitationServiceImplTest extends BaseAlfrescoSpringTest
this.siteService = (SiteService)this.applicationContext.getBean("SiteService"); this.siteService = (SiteService)this.applicationContext.getBean("SiteService");
this.personService = (PersonService)this.applicationContext.getBean("PersonService"); this.personService = (PersonService)this.applicationContext.getBean("PersonService");
this.authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent"); this.authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent");
this.mutableAuthenticationDao = (MutableAuthenticationDao)this.applicationContext.getBean("authenticationDao");
createPerson(USER_MANAGER, USER_MANAGER + "@alfrescotesting.com", PERSON_FIRSTNAME, PERSON_LASTNAME); createPerson(USER_MANAGER, USER_MANAGER + "@alfrescotesting.com", PERSON_FIRSTNAME, PERSON_LASTNAME);
createPerson(USER_ONE, USER_ONE_EMAIL,USER_ONE_FIRSTNAME, USER_ONE_LASTNAME); createPerson(USER_ONE, USER_ONE_EMAIL,USER_ONE_FIRSTNAME, USER_ONE_LASTNAME);
@@ -365,8 +361,6 @@ public class InvitationServiceImplTest extends BaseAlfrescoSpringTest
*/ */
public void testNominatedInvitationNewUserSameEmails() throws Exception public void testNominatedInvitationNewUserSameEmails() throws Exception
{ {
Date startDate = new java.util.Date();
String inviteeAFirstName = "John"; String inviteeAFirstName = "John";
String inviteeALastName = "Smith"; String inviteeALastName = "Smith";
@@ -868,9 +862,6 @@ public class InvitationServiceImplTest extends BaseAlfrescoSpringTest
Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE; Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE;
String inviteeRole = SiteModel.SITE_COLLABORATOR; String inviteeRole = SiteModel.SITE_COLLABORATOR;
String comments = "please sir, let me in!"; String comments = "please sir, let me in!";
String inviteeFirstName = PERSON_FIRSTNAME;
String inviteeLastName = PERSON_LASTNAME;
String inviteeEmail = "123";
String serverPath = "wibble"; String serverPath = "wibble";
String acceptUrl = "froob"; String acceptUrl = "froob";
String rejectUrl = "marshmallow"; String rejectUrl = "marshmallow";
@@ -1006,18 +997,6 @@ public class InvitationServiceImplTest extends BaseAlfrescoSpringTest
private void deletePersonByUserName(String userName) private void deletePersonByUserName(String userName)
{ {
// delete authentication if authentication exists for given user name
if (this.authenticationService.authenticationExists(userName))
{
this.authenticationService.deleteAuthentication(userName);
}
// delete user account
if (this.mutableAuthenticationDao.userExists(userName))
{
this.mutableAuthenticationDao.deleteUser(userName);
}
// delete person node associated with given user name // delete person node associated with given user name
// if one exists // if one exists
if (this.personService.personExists(userName)) if (this.personService.personExists(userName))

View File

@@ -41,6 +41,7 @@ import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.security.authentication.AuthenticationException;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.permissions.PermissionServiceSPI; import org.alfresco.repo.security.permissions.PermissionServiceSPI;
import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.tenant.TenantService;
@@ -58,6 +59,7 @@ import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.ResultSetRow; import org.alfresco.service.cmr.search.ResultSetRow;
import org.alfresco.service.cmr.search.SearchParameters; import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.AuthorityService; import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.AuthorityType; import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.service.cmr.security.NoSuchPersonException; import org.alfresco.service.cmr.security.NoSuchPersonException;
@@ -100,6 +102,8 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
private AuthorityService authorityService; private AuthorityService authorityService;
private AuthenticationService authenticationService;
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
private PermissionServiceSPI permissionServiceSPI; private PermissionServiceSPI permissionServiceSPI;
@@ -168,6 +172,7 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
PropertyCheck.mandatory(this, "searchService", searchService); PropertyCheck.mandatory(this, "searchService", searchService);
PropertyCheck.mandatory(this, "permissionServiceSPI", permissionServiceSPI); PropertyCheck.mandatory(this, "permissionServiceSPI", permissionServiceSPI);
PropertyCheck.mandatory(this, "authorityService", authorityService); PropertyCheck.mandatory(this, "authorityService", authorityService);
PropertyCheck.mandatory(this, "authenticationService", authenticationService);
PropertyCheck.mandatory(this, "namespacePrefixResolver", namespacePrefixResolver); PropertyCheck.mandatory(this, "namespacePrefixResolver", namespacePrefixResolver);
PropertyCheck.mandatory(this, "policyComponent", policyComponent); PropertyCheck.mandatory(this, "policyComponent", policyComponent);
PropertyCheck.mandatory(this, "personCache", personCache); PropertyCheck.mandatory(this, "personCache", personCache);
@@ -648,6 +653,16 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
return; return;
} }
// Remove internally-stored password information, if any
try
{
authenticationService.deleteAuthentication(userName);
}
catch (AuthenticationException e)
{
// Ignore this - externally authenticated user
}
// remove user from any containing authorities // remove user from any containing authorities
Set<String> containerAuthorities = authorityService.getContainingAuthorities(null, userName, true); Set<String> containerAuthorities = authorityService.getContainingAuthorities(null, userName, true);
for (String containerAuthority : containerAuthorities) for (String containerAuthority : containerAuthorities)
@@ -761,6 +776,11 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
this.authorityService = authorityService; this.authorityService = authorityService;
} }
public void setAuthenticationService(AuthenticationService authenticationService)
{
this.authenticationService = authenticationService;
}
public void setDictionaryService(DictionaryService dictionaryService) public void setDictionaryService(DictionaryService dictionaryService)
{ {
this.dictionaryService = dictionaryService; this.dictionaryService = dictionaryService;

View File

@@ -333,7 +333,6 @@ public class UserUsageTrackingComponentTest extends TestCase
NodeRef homeFolder = getHomeSpaceFolderNode(userName); NodeRef homeFolder = getHomeSpaceFolderNode(userName);
nodeService.deleteNode(homeFolder); nodeService.deleteNode(homeFolder);
authenticationService.deleteAuthentication(userName);
personService.deletePerson(userName); personService.deletePerson(userName);
deleteCount++; deleteCount++;
} }

View File

@@ -169,10 +169,6 @@ public class AbstractWCMServiceImplTest extends TestCase
protected void deleteUser(String userName) protected void deleteUser(String userName)
{ {
if (authenticationService.authenticationExists(userName) == true) personService.deletePerson(userName);
{
personService.deletePerson(userName);
authenticationService.deleteAuthentication(userName);
}
} }
} }