Пример #1
0
  @Test
  public void testConvertToCmisAcl() {
    Ace ace = aceN.toCommonsAce();
    assertEquals(ANDREAS, ace.getPrincipalId());
    assertEquals(1, ace.getPermissions().size());
    assertEquals("", ace.getPermissions().get(0));

    ace = aceR.toCommonsAce();
    assertEquals(BERTA, ace.getPrincipalId());
    assertEquals(1, ace.getPermissions().size());
    assertEquals(EnumBasicPermissions.CMIS_READ.value(), ace.getPermissions().get(0));

    ace = aceW.toCommonsAce();
    assertEquals(CHRISTIAN, ace.getPrincipalId());
    assertEquals(1, ace.getPermissions().size());
    assertEquals(EnumBasicPermissions.CMIS_WRITE.value(), ace.getPermissions().get(0));

    ace = aceA.toCommonsAce();
    assertEquals(DOROTHEE, ace.getPrincipalId());
    assertEquals(1, ace.getPermissions().size());
    assertEquals(EnumBasicPermissions.CMIS_ALL.value(), ace.getPermissions().get(0));

    InMemoryAcl acl = createDefaultAcl();
    Acl commonsAcl = acl.toCommonsAcl();
    assertEquals(4, commonsAcl.getAces().size());
    assertTrue(hasCommonsAce(commonsAcl, ANDREAS, ""));
    assertFalse(hasCommonsAce(commonsAcl, ANDREAS, EnumBasicPermissions.CMIS_READ.value()));
    assertFalse(hasCommonsAce(commonsAcl, ANDREAS, EnumBasicPermissions.CMIS_WRITE.value()));
    assertFalse(hasCommonsAce(commonsAcl, ANDREAS, EnumBasicPermissions.CMIS_ALL.value()));
    assertTrue(hasCommonsAce(commonsAcl, BERTA, EnumBasicPermissions.CMIS_READ.value()));
    assertTrue(hasCommonsAce(commonsAcl, CHRISTIAN, EnumBasicPermissions.CMIS_WRITE.value()));
    assertTrue(hasCommonsAce(commonsAcl, DOROTHEE, EnumBasicPermissions.CMIS_ALL.value()));
  }
Пример #2
0
  @Test
  public void testConvertFomCmisAcl() {
    List<Ace> aces =
        Arrays.asList(
            new Ace[] {
              createAce(ANDREAS, EnumBasicPermissions.CMIS_READ.value()),
              createAce(DOROTHEE, EnumBasicPermissions.CMIS_WRITE.value())
            });
    AccessControlListImpl cAcl = new AccessControlListImpl(aces);
    InMemoryAcl acl = InMemoryAcl.createFromCommonsAcl(cAcl);
    assertEquals(2, acl.size());
    assertEquals(Permission.READ, acl.getPermission(ANDREAS));
    assertEquals(Permission.WRITE, acl.getPermission(DOROTHEE));

    try {
      List<Ace> aces2 =
          Arrays.asList(
              new Ace[] {
                new AccessControlEntryImpl(
                    null, Arrays.asList(new String[] {EnumBasicPermissions.CMIS_READ.value()}))
              });
      acl = InMemoryAcl.createFromCommonsAcl(new AccessControlListImpl(aces2));
      fail("create Ace will null principal should raise exception.");
    } catch (RuntimeException e) {
    }
    try {
      List<Ace> aces2 =
          Arrays.asList(
              new Ace[] {
                new AccessControlEntryImpl(new AccessControlPrincipalDataImpl(ANDREAS), null)
              });
      acl = InMemoryAcl.createFromCommonsAcl(new AccessControlListImpl(aces2));
      fail("create Ace will null permission should raise exception.");
    } catch (RuntimeException e) {
    }
  }