Fixes for "AuthenticationService" to allow log in as guset.

Fixdes for guset in all group in the open world

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2174 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind 2006-01-23 15:32:50 +00:00
parent 9d432121bc
commit 7832a14c40
3 changed files with 57 additions and 3 deletions

View File

@ -603,7 +603,6 @@
org.alfresco.service.cmr.security.AuthenticationService.deleteAuthentication=ACL_METHOD.ROLE_ADMINISTRATOR org.alfresco.service.cmr.security.AuthenticationService.deleteAuthentication=ACL_METHOD.ROLE_ADMINISTRATOR
org.alfresco.service.cmr.security.AuthenticationService.setAuthenticationEnabled=ACL_METHOD.ROLE_ADMINISTRATOR org.alfresco.service.cmr.security.AuthenticationService.setAuthenticationEnabled=ACL_METHOD.ROLE_ADMINISTRATOR
org.alfresco.service.cmr.security.AuthenticationService.getAuthenticationEnabled=ACL_METHOD.ROLE_ADMINISTRATOR org.alfresco.service.cmr.security.AuthenticationService.getAuthenticationEnabled=ACL_METHOD.ROLE_ADMINISTRATOR
org.alfresco.service.cmr.security.AuthenticationService.authenticateAsGuest=ACL_ALLOW
org.alfresco.service.cmr.security.AuthenticationService.getCurrentUserName=ACL_ALLOW org.alfresco.service.cmr.security.AuthenticationService.getCurrentUserName=ACL_ALLOW
org.alfresco.service.cmr.security.AuthenticationService.invalidateUserSession=ACL_METHOD.ROLE_ADMINISTRATOR org.alfresco.service.cmr.security.AuthenticationService.invalidateUserSession=ACL_METHOD.ROLE_ADMINISTRATOR
org.alfresco.service.cmr.security.AuthenticationService.invalidateTicket=ACL_ALLOW org.alfresco.service.cmr.security.AuthenticationService.invalidateTicket=ACL_ALLOW

View File

@ -145,6 +145,7 @@ public class AuthenticationTest extends TestCase
assertNotNull(personAndyNodeRef); assertNotNull(personAndyNodeRef);
deleteAndy(); deleteAndy();
authenticationComponent.clearCurrentSecurityContext();
} }
@ -178,6 +179,36 @@ public class AuthenticationTest extends TestCase
return properties; return properties;
} }
public void xtestScalability()
{
long create = 0;
long count = 0;
long start;
long end;
authenticationComponent.authenticate("admin", "admin".toCharArray());
for(int i = 0; i < 10000; i++)
{
String id = "TestUser-"+i;
start = System.nanoTime();
authenticationService.createAuthentication(id, id.toCharArray());
end = System.nanoTime();
create += (end - start);
if((i > 0) && (i % 100 == 0))
{
System.out.println("Count = "+i);
System.out.println("Average create : "+(create/i/1000000.0f));
start = System.nanoTime();
dao.userExists(id);
end = System.nanoTime();
System.out.println("Exists : "+((end-start)/1000000.0f));
}
}
authenticationComponent.clearCurrentSecurityContext();
}
public void testCreateAndyUserAndOtherCRUD() throws NoSuchAlgorithmException, UnsupportedEncodingException public void testCreateAndyUserAndOtherCRUD() throws NoSuchAlgorithmException, UnsupportedEncodingException
{ {
RepositoryAuthenticationDao dao = new RepositoryAuthenticationDao(); RepositoryAuthenticationDao dao = new RepositoryAuthenticationDao();
@ -907,6 +938,8 @@ public class AuthenticationTest extends TestCase
} }
} }
public void testPubAuthenticationService3() public void testPubAuthenticationService3()
{ {
@ -941,6 +974,7 @@ public class AuthenticationTest extends TestCase
// change the password // change the password
pubAuthenticationService.setAuthentication("Andy", "auth3".toCharArray()); pubAuthenticationService.setAuthentication("Andy", "auth3".toCharArray());
authenticationComponent.clearCurrentSecurityContext(); authenticationComponent.clearCurrentSecurityContext();
assertNull(authenticationComponent.getCurrentAuthentication());
// authenticate again to assert password changed // authenticate again to assert password changed
pubAuthenticationService.authenticate("Andy", "auth3".toCharArray()); pubAuthenticationService.authenticate("Andy", "auth3".toCharArray());
@ -949,6 +983,9 @@ public class AuthenticationTest extends TestCase
// get the ticket that represents the current user authentication // get the ticket that represents the current user authentication
// instance // instance
String ticket = pubAuthenticationService.getCurrentTicket(); String ticket = pubAuthenticationService.getCurrentTicket();
authenticationComponent.clearCurrentSecurityContext();
assertNull(authenticationComponent.getCurrentAuthentication());
// validate our ticket is still valid // validate our ticket is still valid
pubAuthenticationService.validate(ticket); pubAuthenticationService.validate(ticket);
@ -967,11 +1004,26 @@ public class AuthenticationTest extends TestCase
public void testPubAuthenticationService() public void testPubAuthenticationService()
{ {
//pubAuthenticationService.authenticateAsGuest();
//authenticationComponent.clearCurrentSecurityContext();
assertNull(authenticationComponent.getCurrentAuthentication());
authenticationComponent.setSystemUserAsCurrentUser(); authenticationComponent.setSystemUserAsCurrentUser();
pubAuthenticationService.createAuthentication("GUEST", "".toCharArray()); pubAuthenticationService.createAuthentication("GUEST", "".toCharArray());
authenticationComponent.clearCurrentSecurityContext(); authenticationComponent.clearCurrentSecurityContext();
assertNull(authenticationComponent.getCurrentAuthentication());
pubAuthenticationService.authenticate("GUEST", "".toCharArray()); pubAuthenticationService.authenticate("GUEST", "".toCharArray());
pubAuthenticationService.authenticate("GUEST", "".toCharArray());
authenticationComponent.clearCurrentSecurityContext();
assertNull(authenticationComponent.getCurrentAuthentication());
pubAuthenticationService.authenticateAsGuest();
authenticationComponent.clearCurrentSecurityContext();
assertNull(authenticationComponent.getCurrentAuthentication());
// create an authentication object e.g. the user // create an authentication object e.g. the user

View File

@ -87,7 +87,7 @@ public class SimpleAuthorityServiceImpl implements AuthorityService
{ {
this.adminUsers = adminUsers; this.adminUsers = adminUsers;
} }
public Set<String> getAuthorities() public Set<String> getAuthorities()
{ {
Set<String> authorities = new HashSet<String>(); Set<String> authorities = new HashSet<String>();
@ -96,7 +96,10 @@ public class SimpleAuthorityServiceImpl implements AuthorityService
{ {
authorities.addAll(adminSet); authorities.addAll(adminSet);
} }
authorities.addAll(allSet); if(AuthorityType.getAuthorityType(currentUserName) != AuthorityType.GUEST)
{
authorities.addAll(allSet);
}
return authorities; return authorities;
} }