Search in sources :

Example 16 with SimpleAccessControlListProperties

use of org.alfresco.repo.security.permissions.SimpleAccessControlListProperties in project alfresco-repository by Alfresco.

the class AclDaoComponentTest method testCreateDefining.

public void testCreateDefining() {
    SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties();
    properties.setAclType(ACLType.DEFINING);
    properties.setVersioned(true);
    AccessControlListProperties aclProps = aclDaoComponent.createAccessControlList(properties);
    assertEquals(aclProps.getAclType(), ACLType.DEFINING);
    assertEquals(aclProps.getAclVersion(), Long.valueOf(1l));
    assertEquals(aclProps.getInherits(), Boolean.TRUE);
    assertEquals(aclDaoComponent.getAccessControlListProperties(aclProps.getId()), aclProps);
}
Also used : AccessControlListProperties(org.alfresco.repo.security.permissions.AccessControlListProperties) SimpleAccessControlListProperties(org.alfresco.repo.security.permissions.SimpleAccessControlListProperties) SimpleAccessControlListProperties(org.alfresco.repo.security.permissions.SimpleAccessControlListProperties)

Example 17 with SimpleAccessControlListProperties

use of org.alfresco.repo.security.permissions.SimpleAccessControlListProperties in project alfresco-repository by Alfresco.

the class AclDaoComponentTest method testSimpleCowHerd2.

public void testSimpleCowHerd2() throws Exception {
    SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties();
    properties.setAclType(ACLType.DEFINING);
    properties.setVersioned(true);
    Long i_1 = aclDaoComponent.createAccessControlList(properties).getId();
    Long s_1 = aclDaoComponent.getInheritedAccessControlList(i_1);
    Long i_1_2 = aclDaoComponent.createAccessControlList(properties).getId();
    Long s_1_2 = aclDaoComponent.getInheritedAccessControlList(i_1_2);
    aclDaoComponent.mergeInheritedAccessControlList(s_1, i_1_2);
    Long i_1_3 = aclDaoComponent.createAccessControlList(properties).getId();
    Long s_1_3 = aclDaoComponent.getInheritedAccessControlList(i_1_3);
    aclDaoComponent.mergeInheritedAccessControlList(s_1, i_1_3);
    Long i_1_2_4 = aclDaoComponent.createAccessControlList(properties).getId();
    Long s_1_2_4 = aclDaoComponent.getInheritedAccessControlList(i_1_2_4);
    aclDaoComponent.mergeInheritedAccessControlList(s_1_2, i_1_2_4);
    Long i_1_2_4_5 = aclDaoComponent.createAccessControlList(properties).getId();
    Long s_1_2_4_5 = aclDaoComponent.getInheritedAccessControlList(i_1_2_4_5);
    assertNotNull(s_1_2_4_5);
    aclDaoComponent.mergeInheritedAccessControlList(s_1_2_4, i_1_2_4_5);
    Long i_1_3_6 = aclDaoComponent.createAccessControlList(properties).getId();
    Long s_1_3_6 = aclDaoComponent.getInheritedAccessControlList(i_1_3_6);
    aclDaoComponent.mergeInheritedAccessControlList(s_1_3, i_1_3_6);
    Long i_1_3_6_7 = aclDaoComponent.createAccessControlList(properties).getId();
    Long s_1_3_6_7 = aclDaoComponent.getInheritedAccessControlList(i_1_3_6_7);
    aclDaoComponent.mergeInheritedAccessControlList(s_1_3_6, i_1_3_6_7);
    testTX.commit();
    testTX = transactionService.getUserTransaction();
    testTX.begin();
    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);
    List<AclChange> changes = aclDaoComponent.setAccessControlEntry(i_1_3, ace1);
    // All should have changed
    Set<Long> changed = new HashSet<Long>(changes.size());
    for (AclChange change : changes) {
        changed.add(change.getBefore());
        assertFalse(change.getBefore().equals(change.getAfter()));
    }
    assertTrue(changed.contains(i_1_3));
    assertTrue(changed.contains(s_1_3));
    assertTrue(changed.contains(i_1_3_6));
    assertTrue(changed.contains(s_1_3_6));
    assertTrue(changed.contains(i_1_3_6_7));
    assertTrue(changed.contains(s_1_3_6_7));
}
Also used : SimpleAccessControlListProperties(org.alfresco.repo.security.permissions.SimpleAccessControlListProperties) SimpleAccessControlEntry(org.alfresco.repo.security.permissions.SimpleAccessControlEntry) HashSet(java.util.HashSet)

Example 18 with SimpleAccessControlListProperties

use of org.alfresco.repo.security.permissions.SimpleAccessControlListProperties in project alfresco-repository by Alfresco.

the class AclDaoComponentTest method testGlobal.

public void testGlobal() {
    SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties();
    properties.setAclType(ACLType.GLOBAL);
    properties.setVersioned(false);
    AccessControlListProperties aclProps = aclDaoComponent.createAccessControlList(properties);
    Long id = aclProps.getId();
    assertEquals(aclProps.getAclType(), ACLType.GLOBAL);
    assertEquals(aclProps.getAclVersion(), Long.valueOf(1l));
    assertEquals(aclProps.getInherits(), Boolean.TRUE);
    assertEquals(aclDaoComponent.getAccessControlListProperties(aclProps.getId()), aclProps);
    assertEquals(aclDaoComponent.getInheritedAccessControlList(id), id);
}
Also used : AccessControlListProperties(org.alfresco.repo.security.permissions.AccessControlListProperties) SimpleAccessControlListProperties(org.alfresco.repo.security.permissions.SimpleAccessControlListProperties) SimpleAccessControlListProperties(org.alfresco.repo.security.permissions.SimpleAccessControlListProperties)

Example 19 with SimpleAccessControlListProperties

use of org.alfresco.repo.security.permissions.SimpleAccessControlListProperties in project alfresco-repository by Alfresco.

the class AclDaoComponentTest method testAddSimilar.

public void testAddSimilar() {
    SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties();
    properties.setAclType(ACLType.DEFINING);
    properties.setVersioned(false);
    Long id1 = aclDaoComponent.createAccessControlList(properties).getId();
    Long shared1 = aclDaoComponent.getInheritedAccessControlList(id1);
    Long id2 = aclDaoComponent.createAccessControlList(properties).getId();
    Long shared2 = aclDaoComponent.getInheritedAccessControlList(id2);
    aclDaoComponent.mergeInheritedAccessControlList(shared1, id2);
    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);
    SimpleAccessControlEntry ace2 = new SimpleAccessControlEntry();
    ace2.setAccessStatus(AccessStatus.ALLOWED);
    ace2.setAceType(ACEType.ALL);
    ace2.setAuthority("andy");
    ace2.setPermission(new SimplePermissionReference(QName.createQName("uri", "local"), "Read"));
    ace2.setPosition(null);
    aclDaoComponent.setAccessControlEntry(id1, ace1);
    aclDaoComponent.setAccessControlEntry(id2, ace1);
    assertEquals(aclDaoComponent.getAccessControlList(id1).getEntries().size(), 1);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(id1).getEntries(), ace1, 0));
    assertEquals(aclDaoComponent.getAccessControlList(shared1).getEntries().size(), 1);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(shared1).getEntries(), ace1, 1));
    assertEquals(aclDaoComponent.getAccessControlList(id2).getEntries().size(), 2);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(id2).getEntries(), ace1, 0));
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(id2).getEntries(), ace1, 2));
    assertEquals(aclDaoComponent.getAccessControlList(shared2).getEntries().size(), 2);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(shared2).getEntries(), ace1, 1));
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(shared2).getEntries(), ace1, 3));
    aclDaoComponent.setAccessControlEntry(id1, ace2);
    assertEquals(aclDaoComponent.getAccessControlList(id1).getEntries().size(), 1);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(id1).getEntries(), ace2, 0));
    assertEquals(aclDaoComponent.getAccessControlList(shared1).getEntries().size(), 1);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(shared1).getEntries(), ace2, 1));
    assertEquals(aclDaoComponent.getAccessControlList(id2).getEntries().size(), 2);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(id2).getEntries(), ace2, 0));
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(id2).getEntries(), ace1, 2));
    assertEquals(aclDaoComponent.getAccessControlList(shared2).getEntries().size(), 2);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(shared2).getEntries(), ace2, 1));
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(shared2).getEntries(), ace1, 3));
    aclDaoComponent.setAccessControlEntry(id1, ace1);
    aclDaoComponent.setAccessControlEntry(id2, ace2);
    assertEquals(aclDaoComponent.getAccessControlList(id1).getEntries().size(), 1);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(id1).getEntries(), ace1, 0));
    assertEquals(aclDaoComponent.getAccessControlList(shared1).getEntries().size(), 1);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(shared1).getEntries(), ace1, 1));
    assertEquals(aclDaoComponent.getAccessControlList(id2).getEntries().size(), 2);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(id2).getEntries(), ace1, 0));
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(id2).getEntries(), ace2, 2));
    assertEquals(aclDaoComponent.getAccessControlList(shared2).getEntries().size(), 2);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(shared2).getEntries(), ace1, 1));
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(shared2).getEntries(), ace2, 3));
    aclDaoComponent.setAccessControlEntry(id1, ace2);
    assertEquals(aclDaoComponent.getAccessControlList(id1).getEntries().size(), 1);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(id1).getEntries(), ace2, 0));
    assertEquals(aclDaoComponent.getAccessControlList(shared1).getEntries().size(), 1);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(shared1).getEntries(), ace2, 1));
    assertEquals(aclDaoComponent.getAccessControlList(id2).getEntries().size(), 2);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(id2).getEntries(), ace2, 0));
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(id2).getEntries(), ace2, 2));
    assertEquals(aclDaoComponent.getAccessControlList(shared2).getEntries().size(), 2);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(shared2).getEntries(), ace2, 1));
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(shared2).getEntries(), ace2, 3));
    aclDaoComponent.setAccessControlEntry(id1, ace1);
    aclDaoComponent.setAccessControlEntry(id2, ace1);
    assertEquals(aclDaoComponent.getAccessControlList(id1).getEntries().size(), 1);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(id1).getEntries(), ace1, 0));
    assertEquals(aclDaoComponent.getAccessControlList(shared1).getEntries().size(), 1);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(shared1).getEntries(), ace1, 1));
    assertEquals(aclDaoComponent.getAccessControlList(id2).getEntries().size(), 2);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(id2).getEntries(), ace1, 0));
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(id2).getEntries(), ace1, 2));
    assertEquals(aclDaoComponent.getAccessControlList(shared2).getEntries().size(), 2);
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(shared2).getEntries(), ace1, 1));
    assertTrue(hasAce(aclDaoComponent.getAccessControlList(shared2).getEntries(), ace1, 3));
}
Also used : SimpleAccessControlListProperties(org.alfresco.repo.security.permissions.SimpleAccessControlListProperties) SimpleAccessControlEntry(org.alfresco.repo.security.permissions.SimpleAccessControlEntry)

Example 20 with SimpleAccessControlListProperties

use of org.alfresco.repo.security.permissions.SimpleAccessControlListProperties in project alfresco-repository by Alfresco.

the class AclDaoComponentTest method testCreateOld.

public void testCreateOld() {
    SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties();
    properties.setAclType(ACLType.OLD);
    properties.setVersioned(false);
    AccessControlListProperties aclProps = aclDaoComponent.createAccessControlList(properties);
    assertEquals(aclProps.getAclType(), ACLType.OLD);
    assertEquals(aclProps.getAclVersion(), Long.valueOf(1l));
    assertEquals(aclProps.getInherits(), Boolean.TRUE);
    assertEquals(aclDaoComponent.getAccessControlListProperties(aclProps.getId()), aclProps);
    assertEquals(aclDaoComponent.getInheritedAccessControlList(aclProps.getId()), null);
}
Also used : AccessControlListProperties(org.alfresco.repo.security.permissions.AccessControlListProperties) SimpleAccessControlListProperties(org.alfresco.repo.security.permissions.SimpleAccessControlListProperties) SimpleAccessControlListProperties(org.alfresco.repo.security.permissions.SimpleAccessControlListProperties)

Aggregations

SimpleAccessControlListProperties (org.alfresco.repo.security.permissions.SimpleAccessControlListProperties)21 AccessControlListProperties (org.alfresco.repo.security.permissions.AccessControlListProperties)9 SimpleAccessControlEntry (org.alfresco.repo.security.permissions.SimpleAccessControlEntry)9 AclChange (org.alfresco.repo.security.permissions.impl.AclChange)4 ArrayList (java.util.ArrayList)3 AccessControlList (org.alfresco.repo.security.permissions.AccessControlList)3 HashSet (java.util.HashSet)2 NodeIdAndAclId (org.alfresco.repo.domain.node.NodeIdAndAclId)1 AccessControlEntry (org.alfresco.repo.security.permissions.AccessControlEntry)1 SimpleAccessControlList (org.alfresco.repo.security.permissions.SimpleAccessControlList)1