mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
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:
@@ -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)
|
||||||
{
|
{
|
||||||
|
@@ -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());
|
||||||
|
@@ -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");
|
||||||
|
Reference in New Issue
Block a user