mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/V3.2 to HEAD:
19286: Fix for https://issues.alfresco.com/jira/browse/ALF-626 "Using 'null' as an authority argument in clearPermissions() cause a java.lang.NullPointerException" git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19367 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -58,6 +58,7 @@ import org.alfresco.repo.security.permissions.impl.AclDaoComponent;
|
||||
import org.alfresco.repo.security.permissions.impl.SimplePermissionReference;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.AuthorityType;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -1945,7 +1946,7 @@ public class AclDaoComponentImpl extends HibernateDaoSupport implements AclDaoCo
|
||||
if (pattern.getAuthority() != null)
|
||||
{
|
||||
DbAuthority authority = (DbAuthority) result.get("authority");
|
||||
if (!pattern.getAuthority().equals(authority.getAuthority()))
|
||||
if ((pattern.getAuthorityType() != AuthorityType.WILDCARD) && !pattern.getAuthority().equals(authority.getAuthority()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@@ -2488,6 +2488,20 @@ public class PermissionServiceTest extends AbstractPermissionTest
|
||||
assertTrue("Time was "+(end - start)/1000000000.0f, end == start);
|
||||
}
|
||||
|
||||
public void testClearPermissionNullAuthority()
|
||||
{
|
||||
assertEquals(0, permissionService.getAllSetPermissions(rootNodeRef).size());
|
||||
permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ), "andy", AccessStatus.ALLOWED));
|
||||
permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ_CHILDREN), "andy", AccessStatus.ALLOWED));
|
||||
assertEquals(2, permissionService.getAllSetPermissions(rootNodeRef).size());
|
||||
permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ), "lemur", AccessStatus.ALLOWED));
|
||||
permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ_CHILDREN), "lemur", AccessStatus.ALLOWED));
|
||||
assertEquals(4, permissionService.getAllSetPermissions(rootNodeRef).size());
|
||||
|
||||
permissionService.clearPermission(rootNodeRef, null);
|
||||
assertEquals(0, permissionService.getAllSetPermissions(rootNodeRef).size());
|
||||
}
|
||||
|
||||
public void testGetAllSetPermissionsFromAllNodes()
|
||||
{
|
||||
runAs(AuthenticationUtil.getAdminUserName());
|
||||
|
@@ -29,6 +29,7 @@ package org.alfresco.service.cmr.security;
|
||||
* <li>OWNER - the special authority that applies to the owner of a node
|
||||
* <li>EVERYONE - the special authority that is interpreted as everyone
|
||||
* <li>GUEST - the special authority that applies to a GUEST (An unknown, unauthenticated user)
|
||||
* <li>WILDCARD - the set of all authorities (including the guest user)
|
||||
* </ol>
|
||||
*
|
||||
* @author Andy Hind
|
||||
@@ -225,6 +226,33 @@ public enum AuthorityType
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
},
|
||||
WILDCARD
|
||||
{
|
||||
public boolean isFixedString()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getFixedString()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public boolean isPrefixed()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getPrefixString()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public int getOrderPosition()
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
};
|
||||
|
||||
public abstract boolean isFixedString();
|
||||
@@ -245,34 +273,43 @@ public enum AuthorityType
|
||||
public static AuthorityType getAuthorityType(String authority)
|
||||
{
|
||||
AuthorityType authorityType;
|
||||
if (authority.equals(PermissionService.ADMINISTRATOR_AUTHORITY))
|
||||
|
||||
if(null == authority)
|
||||
{
|
||||
authorityType = AuthorityType.ADMIN;
|
||||
}
|
||||
if (authority.equals(PermissionService.ALL_AUTHORITIES))
|
||||
{
|
||||
authorityType = AuthorityType.EVERYONE;
|
||||
}
|
||||
else if (authority.equals(PermissionService.OWNER_AUTHORITY))
|
||||
{
|
||||
authorityType = AuthorityType.OWNER;
|
||||
}
|
||||
else if (authority.equalsIgnoreCase(PermissionService.GUEST_AUTHORITY))
|
||||
{
|
||||
authorityType = AuthorityType.GUEST;
|
||||
}
|
||||
else if (authority.startsWith(PermissionService.GROUP_PREFIX))
|
||||
{
|
||||
authorityType = AuthorityType.GROUP;
|
||||
}
|
||||
else if (authority.startsWith(PermissionService.ROLE_PREFIX))
|
||||
{
|
||||
authorityType = AuthorityType.ROLE;
|
||||
authorityType = AuthorityType.WILDCARD;
|
||||
}
|
||||
else
|
||||
{
|
||||
authorityType = AuthorityType.USER;
|
||||
if (authority.equals(PermissionService.ADMINISTRATOR_AUTHORITY))
|
||||
{
|
||||
authorityType = AuthorityType.ADMIN;
|
||||
}
|
||||
if (authority.equals(PermissionService.ALL_AUTHORITIES))
|
||||
{
|
||||
authorityType = AuthorityType.EVERYONE;
|
||||
}
|
||||
else if (authority.equals(PermissionService.OWNER_AUTHORITY))
|
||||
{
|
||||
authorityType = AuthorityType.OWNER;
|
||||
}
|
||||
else if (authority.equalsIgnoreCase(PermissionService.GUEST_AUTHORITY))
|
||||
{
|
||||
authorityType = AuthorityType.GUEST;
|
||||
}
|
||||
else if (authority.startsWith(PermissionService.GROUP_PREFIX))
|
||||
{
|
||||
authorityType = AuthorityType.GROUP;
|
||||
}
|
||||
else if (authority.startsWith(PermissionService.ROLE_PREFIX))
|
||||
{
|
||||
authorityType = AuthorityType.ROLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
authorityType = AuthorityType.USER;
|
||||
}
|
||||
}
|
||||
|
||||
return authorityType;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user