Fix for ALF-11104: add authenticated user to authorisations list in PermissionService + fix inconsistency in AuthorityService

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31751 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Steven Glover
2011-11-04 16:20:09 +00:00
parent f54aacb177
commit 74ba308cf9
3 changed files with 21 additions and 5 deletions

View File

@@ -212,15 +212,17 @@ public class AuthorityServiceImpl implements AuthorityService, InitializingBean
*/ */
private boolean hasAuthority(String authority, String parentAuthority) private boolean hasAuthority(String authority, String parentAuthority)
{ {
if (parentAuthority.equals(authority))
{
return true;
}
// Even users are matched case sensitively in ACLs // Even users are matched case sensitively in ACLs
if (AuthorityType.getAuthorityType(parentAuthority) == AuthorityType.USER) if (AuthorityType.getAuthorityType(parentAuthority) == AuthorityType.USER)
{ {
return false; return false;
} }
if (parentAuthority.equals(authority))
{
return true;
}
NodeRef nodeRef = authorityDAO.getAuthorityNodeRefOrNull(parentAuthority); NodeRef nodeRef = authorityDAO.getAuthorityNodeRefOrNull(parentAuthority);
if (nodeRef == null) if (nodeRef == null)
{ {

View File

@@ -768,6 +768,8 @@ public class PermissionServiceImpl extends AbstractLifecycleBean implements Perm
String username = user.getUsername(); String username = user.getUsername();
Set<String> auths = authorityService.getAuthoritiesForUser(username); Set<String> auths = authorityService.getAuthoritiesForUser(username);
auths.add(username);
for (GrantedAuthority grantedAuthority : auth.getAuthorities()) for (GrantedAuthority grantedAuthority : auth.getAuthorities())
{ {
auths.add(grantedAuthority.getAuthority()); auths.add(grantedAuthority.getAuthority());

View File

@@ -63,6 +63,18 @@ public class PermissionServiceTest extends AbstractPermissionTest
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
/*
* Tests that the current user is contained in the current authorisations set
*/
public void testCurrentUserAuthority()
{
runAs("andy");
assertEquals("andy", authenticationComponent.getCurrentUserName());
Set<String> authorisations = permissionService.getAuthorisations();
assertTrue("", authorisations.contains("andy"));
}
public void testMove() public void testMove()
{ {
runAs("admin"); runAs("admin");