Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)

124492 aleahu: Merged 5.0.N (5.0.4) to 5.1.N (5.1.2)
      124466 aleahu: Merged V4.2-BUG-FIX (4.2.7) to 5.0.N (5.0.4)
         124434 aleahu: Merged V4.2.6 (4.2.6) to V4.2-BUG-FIX (4.2.7)
            124387 amorarasu: MNT-15888: The ImapServiceImplTest fails intermittently on MySQL and MariaDB
               - The re-authentication is done in a retrying transaction. 


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@124520 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Raluca Munteanu
2016-03-28 08:02:11 +00:00
parent b2188fa39a
commit 88dee4b596

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2014 Alfresco Software Limited. * Copyright (C) 2005-2016 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -60,6 +60,7 @@ import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory;
import org.alfresco.repo.node.integrity.IntegrityChecker; import org.alfresco.repo.node.integrity.IntegrityChecker;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileFolderUtil; import org.alfresco.service.cmr.model.FileFolderUtil;
@@ -237,6 +238,7 @@ public class ImapServiceImplTest extends TestCase
{ {
e.printStackTrace(); e.printStackTrace();
} }
AuthenticationUtil.clearCurrentSecurityContext();
} }
private void importInternal(String acpName, NodeRef space) private void importInternal(String acpName, NodeRef space)
@@ -276,11 +278,18 @@ public class ImapServiceImplTest extends TestCase
return present; return present;
} }
private void reauthenticate(String name, String password) private void reauthenticate(final String name, final String password)
{
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute()
{ {
authenticationService.invalidateTicket(authenticationService.getCurrentTicket()); authenticationService.invalidateTicket(authenticationService.getCurrentTicket());
authenticationService.clearCurrentSecurityContext(); authenticationService.clearCurrentSecurityContext();
authenticationService.authenticate(name, password.toCharArray()); authenticationService.authenticate(name, password.toCharArray());
return null;
}
});
} }
public void testGetFolder() throws Exception public void testGetFolder() throws Exception