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.security.permissions.impl.SimplePermissionReference;
|
||||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||||
import org.alfresco.service.cmr.security.AccessStatus;
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
|
import org.alfresco.service.cmr.security.AuthorityType;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
@@ -1945,7 +1946,7 @@ public class AclDaoComponentImpl extends HibernateDaoSupport implements AclDaoCo
|
|||||||
if (pattern.getAuthority() != null)
|
if (pattern.getAuthority() != null)
|
||||||
{
|
{
|
||||||
DbAuthority authority = (DbAuthority) result.get("authority");
|
DbAuthority authority = (DbAuthority) result.get("authority");
|
||||||
if (!pattern.getAuthority().equals(authority.getAuthority()))
|
if ((pattern.getAuthorityType() != AuthorityType.WILDCARD) && !pattern.getAuthority().equals(authority.getAuthority()))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -2488,6 +2488,20 @@ public class PermissionServiceTest extends AbstractPermissionTest
|
|||||||
assertTrue("Time was "+(end - start)/1000000000.0f, end == start);
|
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()
|
public void testGetAllSetPermissionsFromAllNodes()
|
||||||
{
|
{
|
||||||
runAs(AuthenticationUtil.getAdminUserName());
|
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>OWNER - the special authority that applies to the owner of a node
|
||||||
* <li>EVERYONE - the special authority that is interpreted as everyone
|
* <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>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>
|
* </ol>
|
||||||
*
|
*
|
||||||
* @author Andy Hind
|
* @author Andy Hind
|
||||||
@@ -225,6 +226,33 @@ public enum AuthorityType
|
|||||||
{
|
{
|
||||||
return 6;
|
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();
|
public abstract boolean isFixedString();
|
||||||
@@ -245,6 +273,13 @@ public enum AuthorityType
|
|||||||
public static AuthorityType getAuthorityType(String authority)
|
public static AuthorityType getAuthorityType(String authority)
|
||||||
{
|
{
|
||||||
AuthorityType authorityType;
|
AuthorityType authorityType;
|
||||||
|
|
||||||
|
if(null == authority)
|
||||||
|
{
|
||||||
|
authorityType = AuthorityType.WILDCARD;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (authority.equals(PermissionService.ADMINISTRATOR_AUTHORITY))
|
if (authority.equals(PermissionService.ADMINISTRATOR_AUTHORITY))
|
||||||
{
|
{
|
||||||
authorityType = AuthorityType.ADMIN;
|
authorityType = AuthorityType.ADMIN;
|
||||||
@@ -273,6 +308,8 @@ public enum AuthorityType
|
|||||||
{
|
{
|
||||||
authorityType = AuthorityType.USER;
|
authorityType = AuthorityType.USER;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return authorityType;
|
return authorityType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user