Merged V3.2 to HEAD

17475: ETHREEOH-3295: Fix to AuthorityMigrationPatch
      - Forces transaction retry if worker thread reaches child authority before a parent authority
      - Tested on Kev's 3.1.1 repository with ~20,000 bulk loaded users and ~2,000 Share sites
      - Now completes in 5 minutes as opposed to 45
   17461: ETHREEOH-3268: Added MutableAuthenticationService.isAuthenticationCreationAllowed () to allow conditional display of external user invitation UI
   17450: ETHREEOH-2762: Correction to previous fix. Do not generate new name when working copy copied back on check in.
   17440: ETHREEOH-3295: Fixed logging in FixNameCrcValuesPatch
   17439: ETHREEOH-2762: Improved behaviour when a working copy is copied
      - Working copy aspect already removed the working copy aspect on copy
      - Now derives a new name from the node checked out from and a UUID, preserving the extension
   17438: ETHREEOH-2690: Fix sequencing of jgroups system property setting
      - declared dependency between internalEHCacheManager and jgroupsPropertySetter
   17436: ETHREEOH-3295: Further performance improvements to AuthorityMigrationPatch
      - authority created at same time as all its parent associations to save lots of reindexing, as per LDAP sync
      - multi-threaded BatchProcessor (as used by LDAP sync, FixNameCrcValuesPatch) used to process work in 2 threads in batches of 20, report progress every 100 entries and handle transaction retries
      - BatchProcessor now promoted to its own package
   17394: Fix for license issue in local enterprise builds.
      - Replace Community with Enterprise in version.properties during enterprise war building
   17365: ETHREEOH-3229: Visited and fixed all SearchService result set leaks
   17362: ETHREEOH-3254: Eliminate needless ping to LDAP server in LDAPAuthenticationComponentImpl.implementationAllowsGuestLogin()
   17348: ETHREEOH-3003: Fix NPE in Hyperic when LicenseDescriptor has null fields
   17316: Merged V3.1 to V3.2
      17315: ETHREEOH-3092: PersonService won't let you create duplicate persons anymore.
      17314: ETHREEOH-3158: Fix RepoServerMgmt to work with external authentication methods
         - AuthenticationService.getCurrentTicket / getNewTicket now call pre authentication check before issuing a new ticket, thus still allowing ticket enforcement when external authentication is in use.
      17312: ETHREEOH-3219: Enable resolution of JMX server password file path on JBoss 5
      17299: Merged V3.2 to V3.1 (Record only)
         17297: ETHREEOH-1593: Changed name of username cookie and fixed login.jsp to decode it properly
         17248: ETHREEOH-1593: alfUser cookie value should be base 64 encoded to allow for non-ASCII characters
   17297: ETHREEOH-1593: Changed name of username cookie and fixed login.jsp to decode it properly
      - thanks Kev!
   17292: ETHREEOH-1842: Ticket association with HttpSession IDs tracked so that we don't invalidate a ticket in use by multiple sessions prematurely
      - AuthenticationService validate, getCurrentTicket, etc. methods now take optional sessionId arguments
   17269: Fix failing unit test
      - reinstate original behaviour of AbstractChainingAuthenticationService.getAuthenticationEnabled()
   17268: Fix InvitationService
      - Runs as system to do privileged AuthenticationService actions


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18105 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2010-01-18 17:41:59 +00:00
parent b96d174e1f
commit 1c1a35e500
55 changed files with 1153 additions and 711 deletions

View File

@@ -274,11 +274,11 @@ public class AuthenticationTest extends TestCase
//userTransaction = transactionService.getUserTransaction();
//userTransaction.begin();
pubAuthenticationService.validate(ticket);
pubAuthenticationService.validate(ticket, null);
userName = pubAuthenticationService.getCurrentUserName();
assertEquals("andy", userName);
pubAuthenticationService.validate(newticket);
pubAuthenticationService.validate(newticket, null);
userName = pubAuthenticationService.getCurrentUserName();
assertEquals("andy", userName);
@@ -629,14 +629,14 @@ public class AuthenticationTest extends TestCase
Authentication result = authenticationManager.authenticate(token);
result.setAuthenticated(true);
String ticket = ticketComponent.getNewTicket(getUserName(result));
String user = ticketComponent.validateTicket(ticket);
assertEquals(ticketComponent.getCurrentTicket("Andy"), ticket);
String ticket = ticketComponent.getNewTicket(getUserName(result), null);
String user = ticketComponent.validateTicket(ticket, null);
assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket);
user = null;
try
{
user = ticketComponent.validateTicket("INVALID");
user = ticketComponent.validateTicket("INVALID", null);
assertNotNull(null);
}
catch (AuthenticationException e)
@@ -644,11 +644,11 @@ public class AuthenticationTest extends TestCase
assertNull(user);
}
ticketComponent.invalidateTicketById(ticket);
ticketComponent.invalidateTicketById(ticket, null);
try
{
user = ticketComponent.validateTicket(ticket);
assertEquals(ticketComponent.getCurrentTicket("Andy"), ticket);
user = ticketComponent.validateTicket(ticket, null);
assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket);
assertNotNull(null);
}
catch (AuthenticationException e)
@@ -677,11 +677,11 @@ public class AuthenticationTest extends TestCase
Authentication result = authenticationManager.authenticate(token);
result.setAuthenticated(true);
String ticket = tc.getNewTicket(getUserName(result));
tc.validateTicket(ticket);
assertEquals(ticketComponent.getCurrentTicket("Andy"), ticket);
tc.validateTicket(ticket);
assertEquals(ticketComponent.getCurrentTicket("Andy"), ticket);
String ticket = tc.getNewTicket(getUserName(result), null);
tc.validateTicket(ticket, null);
assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket);
tc.validateTicket(ticket, null);
assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket);
dao.deleteUser("Andy");
// assertNull(dao.getUserOrNull("Andy"));
@@ -703,12 +703,12 @@ public class AuthenticationTest extends TestCase
Authentication result = authenticationManager.authenticate(token);
result.setAuthenticated(true);
String ticket = tc.getNewTicket(getUserName(result));
tc.validateTicket(ticket);
assertTrue(!ticketComponent.getCurrentTicket("Andy").equals(ticket));
String ticket = tc.getNewTicket(getUserName(result), null);
tc.validateTicket(ticket, null);
assertTrue(!ticketComponent.getCurrentTicket("Andy", null, true).equals(ticket));
try
{
tc.validateTicket(ticket);
tc.validateTicket(ticket, null);
assertNotNull(null);
}
catch (AuthenticationException e)
@@ -737,13 +737,13 @@ public class AuthenticationTest extends TestCase
Authentication result = authenticationManager.authenticate(token);
result.setAuthenticated(true);
String ticket = tc.getNewTicket(getUserName(result));
tc.validateTicket(ticket);
assertEquals(ticketComponent.getCurrentTicket("Andy"), ticket);
tc.validateTicket(ticket);
assertEquals(ticketComponent.getCurrentTicket("Andy"), ticket);
tc.validateTicket(ticket);
assertEquals(ticketComponent.getCurrentTicket("Andy"), ticket);
String ticket = tc.getNewTicket(getUserName(result), null);
tc.validateTicket(ticket, null);
assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket);
tc.validateTicket(ticket, null);
assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket);
tc.validateTicket(ticket, null);
assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket);
synchronized (this)
{
@@ -759,7 +759,7 @@ public class AuthenticationTest extends TestCase
}
try
{
tc.validateTicket(ticket);
tc.validateTicket(ticket, null);
assertNotNull(null);
}
catch (AuthenticationException e)
@@ -769,7 +769,7 @@ public class AuthenticationTest extends TestCase
try
{
tc.validateTicket(ticket);
tc.validateTicket(ticket, null);
assertNotNull(null);
}
catch (AuthenticationException e)
@@ -779,7 +779,7 @@ public class AuthenticationTest extends TestCase
try
{
tc.validateTicket(ticket);
tc.validateTicket(ticket, null);
assertNotNull(null);
}
catch (AuthenticationException e)
@@ -802,7 +802,7 @@ public class AuthenticationTest extends TestCase
try
{
tc.validateTicket(ticket);
tc.validateTicket(ticket, null);
assertNotNull(null);
}
catch (AuthenticationException e)
@@ -811,7 +811,7 @@ public class AuthenticationTest extends TestCase
}
tc.setExpiryMode(ExpiryMode.AFTER_INACTIVITY.toString());
ticket = tc.getNewTicket(getUserName(result));
ticket = tc.getNewTicket(getUserName(result), null);
for (int i = 0; i < 50; i++)
{
@@ -828,7 +828,7 @@ public class AuthenticationTest extends TestCase
e.printStackTrace();
}
tc.validateTicket(ticket);
tc.validateTicket(ticket, null);
}
}
@@ -848,7 +848,7 @@ public class AuthenticationTest extends TestCase
try
{
tc.validateTicket(ticket);
tc.validateTicket(ticket, null);
assertNotNull(null);
}
catch (AuthenticationException e)
@@ -877,13 +877,13 @@ public class AuthenticationTest extends TestCase
Authentication result = authenticationManager.authenticate(token);
result.setAuthenticated(true);
String ticket = tc.getNewTicket(getUserName(result));
tc.validateTicket(ticket);
assertEquals(ticketComponent.getCurrentTicket("Andy"), ticket);
tc.validateTicket(ticket);
assertEquals(ticketComponent.getCurrentTicket("Andy"), ticket);
tc.validateTicket(ticket);
assertEquals(ticketComponent.getCurrentTicket("Andy"), ticket);
String ticket = tc.getNewTicket(getUserName(result), null);
tc.validateTicket(ticket, null);
assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket);
tc.validateTicket(ticket, null);
assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket);
tc.validateTicket(ticket, null);
assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket);
synchronized (this)
{
@@ -899,7 +899,7 @@ public class AuthenticationTest extends TestCase
}
try
{
tc.validateTicket(ticket);
tc.validateTicket(ticket, null);
assertNotNull(null);
}
catch (AuthenticationException e)
@@ -909,7 +909,7 @@ public class AuthenticationTest extends TestCase
try
{
tc.validateTicket(ticket);
tc.validateTicket(ticket, null);
assertNotNull(null);
}
catch (AuthenticationException e)
@@ -919,7 +919,7 @@ public class AuthenticationTest extends TestCase
try
{
tc.validateTicket(ticket);
tc.validateTicket(ticket, null);
assertNotNull(null);
}
catch (AuthenticationException e)
@@ -942,7 +942,7 @@ public class AuthenticationTest extends TestCase
try
{
tc.validateTicket(ticket);
tc.validateTicket(ticket, null);
assertNotNull(null);
}
catch (AuthenticationException e)
@@ -970,13 +970,13 @@ public class AuthenticationTest extends TestCase
Authentication result = authenticationManager.authenticate(token);
result.setAuthenticated(true);
String ticket = tc.getNewTicket(getUserName(result));
tc.validateTicket(ticket);
assertEquals(ticketComponent.getCurrentTicket("Andy"), ticket);
tc.validateTicket(ticket);
assertEquals(ticketComponent.getCurrentTicket("Andy"), ticket);
tc.validateTicket(ticket);
assertEquals(ticketComponent.getCurrentTicket("Andy"), ticket);
String ticket = tc.getNewTicket(getUserName(result), null);
tc.validateTicket(ticket, null);
assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket);
tc.validateTicket(ticket, null);
assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket);
tc.validateTicket(ticket, null);
assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket);
synchronized (this)
{
try
@@ -990,8 +990,8 @@ public class AuthenticationTest extends TestCase
}
}
tc.validateTicket(ticket);
assertEquals(ticketComponent.getCurrentTicket("Andy"), ticket);
tc.validateTicket(ticket, null);
assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket);
dao.deleteUser("Andy");
// assertNull(dao.getUserOrNull("Andy"));
@@ -1126,14 +1126,14 @@ public class AuthenticationTest extends TestCase
// instance
String ticket = authenticationService.getCurrentTicket();
// validate our ticket is still valid
authenticationService.validate(ticket);
authenticationService.validate(ticket, null);
assertEquals(ticket, authenticationService.getCurrentTicket());
// destroy the ticket instance
authenticationService.invalidateTicket(ticket);
authenticationService.invalidateTicket(ticket, null);
try
{
authenticationService.validate(ticket);
authenticationService.validate(ticket, null);
fail("Invalid taicket should have been rejected");
}
catch (AuthenticationException e)
@@ -1175,11 +1175,11 @@ public class AuthenticationTest extends TestCase
// validate our ticket is still valid
authenticationService.clearCurrentSecurityContext();
authenticationService.validate(ticket);
authenticationService.validate(ticket, null);
assertEquals(ticket, authenticationService.getCurrentTicket());
// destroy the ticket instance
authenticationService.invalidateTicket(ticket);
authenticationService.invalidateTicket(ticket, null);
Authentication current = authenticationComponent.getCurrentAuthentication();
if (current != null)
@@ -1190,7 +1190,7 @@ public class AuthenticationTest extends TestCase
try
{
authenticationService.validate(ticket);
authenticationService.validate(ticket, null);
fail("Invalid ticket should have been rejected");
}
catch (AuthenticationException e)
@@ -1234,11 +1234,11 @@ public class AuthenticationTest extends TestCase
// instance
String ticket = authenticationService.getCurrentTicket();
// validate our ticket is still valid
authenticationService.validate(ticket);
authenticationService.validate(ticket, null);
assertEquals(ticket, authenticationService.getCurrentTicket());
// destroy the ticket instance
authenticationService.invalidateTicket(ticket);
authenticationService.invalidateTicket(ticket, null);
Authentication current = authenticationComponent.getCurrentAuthentication();
if (current != null)
@@ -1294,11 +1294,11 @@ public class AuthenticationTest extends TestCase
// instance
String ticket = authenticationService.getCurrentTicket();
// validate our ticket is still valid
authenticationService.validate(ticket);
authenticationService.validate(ticket, null);
assertEquals(ticket, authenticationService.getCurrentTicket());
// destroy the ticket instance
authenticationService.invalidateTicket(ticket);
authenticationService.invalidateTicket(ticket, null);
Authentication current = authenticationComponent.getCurrentAuthentication();
if (current != null)
@@ -1316,6 +1316,48 @@ public class AuthenticationTest extends TestCase
// assertNull(dao.getUserOrNull("Andy"));
}
public void testAuthenticationServiceSessionIds()
{
// create an authentication object e.g. the user
authenticationService.createAuthentication("Andy", "auth1".toCharArray());
// authenticate with this user details
authenticationService.authenticate("Andy", "auth1".toCharArray());
// assert the user is authenticated
assertEquals("Andy", authenticationService.getCurrentUserName());
// Get the user's ticket and associate it with "AndySessionId"
String andyTicket = authenticationService.getCurrentTicket("AndySessionId");
// Now validate the ticket in another session
authenticationService.validate(andyTicket, "DaveSessionId");
assertEquals(andyTicket, authenticationService.getCurrentTicket());
// Invalidate it in that session
authenticationService.invalidateTicket(andyTicket, "DaveSessionId");
// Make sure we don't get that ticket again in the same session
assertNotSame(andyTicket, authenticationService.getCurrentTicket("DaveSessionId"));
// The ticket should still validate in the other session
authenticationService.validate(andyTicket, "AndySessionId");
// When we invalidate it in the other session, the ticket should be invalidated globally
authenticationService.invalidateTicket(andyTicket, "AndySessionId");
try
{
authenticationService.validate(andyTicket, null);
fail("Invalid ticket should have been rejected");
}
catch (AuthenticationException e)
{
// Expected
}
}
public void testPubAuthenticationService1()
{
authenticationComponent.setSystemUserAsCurrentUser();
@@ -1456,14 +1498,14 @@ public class AuthenticationTest extends TestCase
assertNull(authenticationComponent.getCurrentAuthentication());
// validate our ticket is still valid
pubAuthenticationService.validate(ticket);
pubAuthenticationService.validate(ticket, null);
assertEquals(ticket, authenticationService.getCurrentTicket());
// destroy the ticket instance
pubAuthenticationService.invalidateTicket(ticket);
pubAuthenticationService.invalidateTicket(ticket, null);
try
{
pubAuthenticationService.validate(ticket);
pubAuthenticationService.validate(ticket, null);
fail("Ticket should not validate");
}
catch (AuthenticationException e)
@@ -1525,11 +1567,11 @@ public class AuthenticationTest extends TestCase
// instance
String ticket = pubAuthenticationService.getCurrentTicket();
// validate our ticket is still valid
pubAuthenticationService.validate(ticket);
pubAuthenticationService.validate(ticket, null);
assertEquals(ticket, authenticationService.getCurrentTicket());
// destroy the ticket instance
pubAuthenticationService.invalidateTicket(ticket);
pubAuthenticationService.invalidateTicket(ticket, null);
}
@@ -1586,11 +1628,11 @@ public class AuthenticationTest extends TestCase
// instance
String ticket = pubAuthenticationService.getCurrentTicket();
// validate our ticket is still valid
pubAuthenticationService.validate(ticket);
pubAuthenticationService.validate(ticket, null);
assertEquals(ticket, authenticationService.getCurrentTicket());
// destroy the ticket instance
pubAuthenticationService.invalidateTicket(ticket);
pubAuthenticationService.invalidateTicket(ticket, null);
authenticationComponent.clearCurrentSecurityContext();