Search in sources :

Example 11 with AccessControlList

use of javax.jcr.security.AccessControlList in project jackrabbit-oak by apache.

the class ImportIgnoreTest method testImportUnknownPrincipal.

@Test
public void testImportUnknownPrincipal() throws Exception {
    try {
        runImport();
        AccessControlManager acMgr = adminSession.getAccessControlManager();
        AccessControlPolicy[] policies = acMgr.getPolicies(target.getPath());
        assertEquals(1, policies.length);
        assertEquals(0, ((AccessControlList) policies[0]).getAccessControlEntries().length);
    } finally {
        adminSession.refresh(false);
    }
}
Also used : AccessControlManager(javax.jcr.security.AccessControlManager) AccessControlList(javax.jcr.security.AccessControlList) AccessControlPolicy(javax.jcr.security.AccessControlPolicy) Test(org.junit.Test)

Example 12 with AccessControlList

use of javax.jcr.security.AccessControlList in project jackrabbit-oak by apache.

the class AuthorizationContextTest method createAcl.

private void createAcl(@Nullable String path, String... privilegeNames) throws RepositoryException {
    AccessControlManager acMgr = getAccessControlManager(root);
    AccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, path);
    assertNotNull(acl);
    acl.addAccessControlEntry(EveryonePrincipal.getInstance(), privilegesFromNames(privilegeNames));
    acMgr.setPolicy(path, acl);
}
Also used : AccessControlManager(javax.jcr.security.AccessControlManager) AccessControlList(javax.jcr.security.AccessControlList)

Example 13 with AccessControlList

use of javax.jcr.security.AccessControlList in project jackrabbit-oak by apache.

the class CugContextTest method before.

@Before
@Override
public void before() throws Exception {
    super.before();
    // add more child nodes
    NodeUtil n = new NodeUtil(root.getTree(SUPPORTED_PATH));
    n.addChild("a", NT_OAK_UNSTRUCTURED).addChild("b", NT_OAK_UNSTRUCTURED).addChild("c", NT_OAK_UNSTRUCTURED);
    n.addChild("aa", NT_OAK_UNSTRUCTURED).addChild("bb", NT_OAK_UNSTRUCTURED).addChild("cc", NT_OAK_UNSTRUCTURED);
    // create cugs
    createCug("/content/a", getTestUser().getPrincipal());
    // setup regular acl at /content
    AccessControlManager acMgr = getAccessControlManager(root);
    AccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, "/content");
    acl.addAccessControlEntry(getTestUser().getPrincipal(), privilegesFromNames(PrivilegeConstants.JCR_READ));
    acMgr.setPolicy("/content", acl);
    root.commit();
}
Also used : AccessControlManager(javax.jcr.security.AccessControlManager) AccessControlList(javax.jcr.security.AccessControlList) NodeUtil(org.apache.jackrabbit.oak.util.NodeUtil) Before(org.junit.Before)

Example 14 with AccessControlList

use of javax.jcr.security.AccessControlList in project jackrabbit-oak by apache.

the class L9_RemoveAuthorizableTest method testAccessControlEntry.

public void testAccessControlEntry() throws RepositoryException, NotExecutableException {
    // remove test user
    removeTestUser();
    boolean found = false;
    AccessControlList acl = AccessControlUtils.getAccessControlList(superuser, testRoot);
    if (acl != null) {
        for (AccessControlEntry ace : acl.getAccessControlEntries()) {
            if (testUser.getPrincipal().getName().equals(ace.getPrincipal().getName())) {
                found = true;
            }
        }
    }
    // EXERCISE: do you expect the ACE for test-principal to be still present? explain why and fix the test if necessary.
    assertTrue(found);
}
Also used : AccessControlList(javax.jcr.security.AccessControlList) AccessControlEntry(javax.jcr.security.AccessControlEntry)

Example 15 with AccessControlList

use of javax.jcr.security.AccessControlList in project jackrabbit-oak by apache.

the class AccessControlActionTest method assertAcAction.

private void assertAcAction(Authorizable a, String expectedPrivName) throws Exception {
    AccessControlManager acMgr = getAccessControlManager(root);
    AccessControlPolicy[] policies = acMgr.getPolicies(a.getPath());
    assertEquals(1, policies.length);
    assertTrue(policies[0] instanceof AccessControlList);
    AccessControlList acl = (AccessControlList) policies[0];
    assertEquals(1, acl.getAccessControlEntries().length);
    assertArrayEquals(new Privilege[] { getPrivilegeManager(root).getPrivilege(expectedPrivName) }, acl.getAccessControlEntries()[0].getPrivileges());
}
Also used : AccessControlManager(javax.jcr.security.AccessControlManager) AccessControlList(javax.jcr.security.AccessControlList) AccessControlPolicy(javax.jcr.security.AccessControlPolicy)

Aggregations

AccessControlList (javax.jcr.security.AccessControlList)97 AccessControlEntry (javax.jcr.security.AccessControlEntry)49 AccessControlManager (javax.jcr.security.AccessControlManager)49 AccessControlPolicy (javax.jcr.security.AccessControlPolicy)39 Privilege (javax.jcr.security.Privilege)25 Node (javax.jcr.Node)17 RepositoryException (javax.jcr.RepositoryException)17 JackrabbitAccessControlList (org.apache.jackrabbit.api.security.JackrabbitAccessControlList)17 AccessControlPolicyIterator (javax.jcr.security.AccessControlPolicyIterator)15 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)15 Test (org.junit.Test)13 Principal (java.security.Principal)12 AccessDeniedException (javax.jcr.AccessDeniedException)12 ArrayList (java.util.ArrayList)9 HashSet (java.util.HashSet)6 AccessControlException (javax.jcr.security.AccessControlException)6 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)6 NodeImpl (org.apache.jackrabbit.core.NodeImpl)6 MetadataRepositoryException (com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException)5 AccessControlException (java.security.AccessControlException)5