use of org.alfresco.repo.security.permissions.SimpleAccessControlListProperties in project alfresco-repository by Alfresco.
the class AclDAOImpl method getDefaultProperties.
/**
* {@inheritDoc}
*/
@Override
public AccessControlListProperties getDefaultProperties() {
SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties();
properties.setAclType(ACLType.DEFINING);
properties.setInherits(true);
properties.setVersioned(false);
return properties;
}
use of org.alfresco.repo.security.permissions.SimpleAccessControlListProperties in project alfresco-repository by Alfresco.
the class AclDAOImpl method createLayeredAcl.
/**
* {@inheritDoc}
*/
@Override
public Acl createLayeredAcl(Long indirectedAcl) {
SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties();
properties.setAclType(ACLType.LAYERED);
Acl acl = createAccessControlList(properties);
long id = acl.getId();
if (indirectedAcl != null) {
mergeInheritedAccessControlList(indirectedAcl, id);
}
return acl;
}
use of org.alfresco.repo.security.permissions.SimpleAccessControlListProperties in project alfresco-repository by Alfresco.
the class AbstractPermissionsDaoComponentImpl method getMutableAccessControlList.
private Acl getMutableAccessControlList(StoreRef storeRef) {
Acl acl = getACLDAO(storeRef).getAccessControlList(storeRef);
if (acl == null) {
SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties();
properties.setAclType(ACLType.DEFINING);
properties.setInherits(false);
properties.setVersioned(false);
acl = aclDaoComponent.createAccessControlList(properties);
getACLDAO(storeRef).setAccessControlList(storeRef, acl);
}
return acl;
}
use of org.alfresco.repo.security.permissions.SimpleAccessControlListProperties in project alfresco-repository by Alfresco.
the class AclDaoComponentTest method testSimpleInheritFromDefining.
public void testSimpleInheritFromDefining() {
SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties();
properties.setAclType(ACLType.DEFINING);
properties.setVersioned(true);
AccessControlListProperties aclProps = aclDaoComponent.createAccessControlList(properties);
long id = aclProps.getId();
assertEquals(aclProps.getAclType(), ACLType.DEFINING);
assertEquals(aclProps.getAclVersion(), Long.valueOf(1l));
assertEquals(aclProps.getInherits(), Boolean.TRUE);
assertEquals(aclDaoComponent.getAccessControlListProperties(id), aclProps);
SimpleAccessControlEntry ace1 = new SimpleAccessControlEntry();
ace1.setAccessStatus(AccessStatus.ALLOWED);
ace1.setAceType(ACEType.ALL);
ace1.setAuthority("andy");
ace1.setPermission(new SimplePermissionReference(QName.createQName("uri", "local"), "Read"));
ace1.setPosition(null);
aclDaoComponent.setAccessControlEntry(id, ace1);
AccessControlList defined = aclDaoComponent.getAccessControlList(id);
assertEquals(defined.getProperties().getAclType(), ACLType.DEFINING);
assertEquals(defined.getProperties().getAclVersion(), Long.valueOf(1l));
assertEquals(defined.getProperties().getInherits(), Boolean.TRUE);
assertEquals(defined.getEntries().size(), 1);
assertTrue(hasAce(defined.getEntries(), ace1, 0));
Long sharedId = aclDaoComponent.getInheritedAccessControlList(id);
AccessControlListProperties sharedProps = aclDaoComponent.getAccessControlListProperties(sharedId);
assertEquals(sharedProps.getAclType(), ACLType.SHARED);
assertEquals(sharedProps.getAclVersion(), Long.valueOf(1l));
assertEquals(sharedProps.getInherits(), Boolean.TRUE);
assertEquals(aclDaoComponent.getInheritedAccessControlList(id), sharedId);
AccessControlList shared = aclDaoComponent.getAccessControlList(sharedId);
assertEquals(shared.getProperties().getAclType(), ACLType.SHARED);
assertEquals(shared.getProperties().getAclVersion(), Long.valueOf(1l));
assertEquals(shared.getProperties().getInherits(), Boolean.TRUE);
assertEquals(shared.getEntries().size(), 1);
assertTrue(hasAce(shared.getEntries(), ace1, 1));
SimpleAccessControlEntry ace2 = new SimpleAccessControlEntry();
ace2.setAccessStatus(AccessStatus.ALLOWED);
ace2.setAceType(ACEType.ALL);
ace2.setAuthority("paul");
ace2.setPermission(new SimplePermissionReference(QName.createQName("uri", "local"), "Write"));
ace2.setPosition(null);
aclDaoComponent.setAccessControlEntry(id, ace2);
defined = aclDaoComponent.getAccessControlList(id);
assertEquals(defined.getProperties().getAclType(), ACLType.DEFINING);
assertEquals(defined.getProperties().getAclVersion(), Long.valueOf(1l));
assertEquals(defined.getProperties().getInherits(), Boolean.TRUE);
assertEquals(defined.getEntries().size(), 2);
assertTrue(hasAce(defined.getEntries(), ace1, 0));
assertTrue(hasAce(defined.getEntries(), ace2, 0));
sharedId = aclDaoComponent.getInheritedAccessControlList(id);
shared = aclDaoComponent.getAccessControlList(sharedId);
assertEquals(shared.getProperties().getAclType(), ACLType.SHARED);
assertEquals(shared.getProperties().getAclVersion(), Long.valueOf(1l));
assertEquals(shared.getProperties().getInherits(), Boolean.TRUE);
assertEquals(shared.getEntries().size(), 2);
assertTrue(hasAce(shared.getEntries(), ace1, 1));
assertTrue(hasAce(shared.getEntries(), ace2, 1));
}
use of org.alfresco.repo.security.permissions.SimpleAccessControlListProperties in project alfresco-repository by Alfresco.
the class AclDaoComponentTest method testDeleteAuthority.
public void testDeleteAuthority() {
SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties();
properties.setAclType(ACLType.DEFINING);
properties.setVersioned(true);
Long defined = aclDaoComponent.createAccessControlList(properties).getId();
SimpleAccessControlEntry ace1 = new SimpleAccessControlEntry();
ace1.setAccessStatus(AccessStatus.ALLOWED);
ace1.setAceType(ACEType.ALL);
ace1.setAuthority("offski");
ace1.setPermission(new SimplePermissionReference(QName.createQName("uri", "local"), "P1"));
ace1.setPosition(null);
SimpleAccessControlEntry ace2 = new SimpleAccessControlEntry();
ace2.setAccessStatus(AccessStatus.ALLOWED);
ace2.setAceType(ACEType.ALL);
ace2.setAuthority("offski");
ace2.setPermission(new SimplePermissionReference(QName.createQName("uri", "local"), "P2"));
ace2.setPosition(null);
SimpleAccessControlEntry ace3 = new SimpleAccessControlEntry();
ace3.setAccessStatus(AccessStatus.ALLOWED);
ace3.setAceType(ACEType.ALL);
ace3.setAuthority("keepski");
ace3.setPermission(new SimplePermissionReference(QName.createQName("uri", "local"), "P3"));
ace3.setPosition(null);
Long shared = aclDaoComponent.getInheritedAccessControlList(defined);
properties = new SimpleAccessControlListProperties();
properties.setAclType(ACLType.FIXED);
properties.setVersioned(true);
Long fixed = aclDaoComponent.createAccessControlList(properties).getId();
properties = new SimpleAccessControlListProperties();
properties.setAclType(ACLType.GLOBAL);
properties.setVersioned(true);
Long global = aclDaoComponent.createAccessControlList(properties).getId();
properties = new SimpleAccessControlListProperties();
properties.setAclType(ACLType.OLD);
properties.setVersioned(false);
Long old = aclDaoComponent.createAccessControlList(properties).getId();
aclDaoComponent.setAccessControlEntry(defined, ace1);
aclDaoComponent.setAccessControlEntry(defined, ace2);
aclDaoComponent.setAccessControlEntry(defined, ace3);
aclDaoComponent.setAccessControlEntry(fixed, ace1);
aclDaoComponent.setAccessControlEntry(fixed, ace2);
aclDaoComponent.setAccessControlEntry(fixed, ace3);
aclDaoComponent.setAccessControlEntry(global, ace1);
aclDaoComponent.setAccessControlEntry(global, ace2);
aclDaoComponent.setAccessControlEntry(global, ace3);
aclDaoComponent.setAccessControlEntry(old, ace1);
aclDaoComponent.setAccessControlEntry(old, ace2);
aclDaoComponent.setAccessControlEntry(old, ace3);
assertEquals(aclDaoComponent.getAccessControlList(defined).getEntries().size(), 3);
assertEquals(aclDaoComponent.getAccessControlList(shared).getEntries().size(), 3);
assertEquals(aclDaoComponent.getAccessControlList(fixed).getEntries().size(), 3);
assertEquals(aclDaoComponent.getAccessControlList(global).getEntries().size(), 3);
assertEquals(aclDaoComponent.getAccessControlList(old).getEntries().size(), 3);
aclDaoComponent.deleteAccessControlEntries("offski");
assertEquals(aclDaoComponent.getAccessControlList(defined).getEntries().size(), 1);
assertEquals(aclDaoComponent.getAccessControlList(shared).getEntries().size(), 1);
assertEquals(aclDaoComponent.getAccessControlList(fixed).getEntries().size(), 1);
assertEquals(aclDaoComponent.getAccessControlList(global).getEntries().size(), 1);
assertEquals(aclDaoComponent.getAccessControlList(old).getEntries().size(), 1);
}
Aggregations