Search in sources :

Example 1 with EveryonePrincipal

use of org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal in project jackrabbit-oak by apache.

the class PrincipalProviderImplTest method testEveryoneMembers.

@Test
public void testEveryoneMembers() throws Exception {
    Principal everyone = principalProvider.getPrincipal(EveryonePrincipal.NAME);
    assertTrue(everyone instanceof EveryonePrincipal);
    Group everyoneGroup = null;
    try {
        UserManager userMgr = getUserManager(root);
        everyoneGroup = userMgr.createGroup(EveryonePrincipal.NAME);
        root.commit();
        Principal ep = principalProvider.getPrincipal(EveryonePrincipal.NAME);
        Set<? extends Principal> everyoneMembers = ImmutableSet.copyOf(Collections.list(((java.security.acl.Group) ep).members()));
        Iterator<? extends Principal> all = principalProvider.findPrincipals(PrincipalManager.SEARCH_TYPE_ALL);
        while (all.hasNext()) {
            Principal p = all.next();
            if (everyone.equals(p)) {
                assertFalse(everyoneMembers.contains(p));
            } else {
                assertTrue(everyoneMembers.contains(p));
            }
        }
    } finally {
        if (everyoneGroup != null) {
            everyoneGroup.remove();
            root.commit();
        }
    }
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) UserManager(org.apache.jackrabbit.api.security.user.UserManager) Principal(java.security.Principal) EveryonePrincipal(org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal) EveryonePrincipal(org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal) Test(org.junit.Test)

Example 2 with EveryonePrincipal

use of org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal in project jackrabbit-oak by apache.

the class EveryoneGroupTest method testGroupPrincipal.

@Test
public void testGroupPrincipal() throws Exception {
    Principal everyonePrincipal = everyone.getPrincipal();
    assertTrue(everyonePrincipal instanceof java.security.acl.Group);
    assertTrue(everyonePrincipal.equals(EveryonePrincipal.getInstance()));
    assertTrue(EveryonePrincipal.getInstance().equals(everyonePrincipal));
    java.security.acl.Group gr = (java.security.acl.Group) everyonePrincipal;
    assertFalse(gr.isMember(everyonePrincipal));
    assertTrue(gr.isMember(getTestUser(superuser).getPrincipal()));
    assertTrue(gr.isMember(new PrincipalImpl("test")));
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) Principal(java.security.Principal) EveryonePrincipal(org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) Test(org.junit.Test)

Example 3 with EveryonePrincipal

use of org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal in project jackrabbit-oak by apache.

the class AbstractPrincipalProviderTest method testEveryone.

@Test
public void testEveryone() throws Exception {
    Principal everyone = principalProvider.getPrincipal(EveryonePrincipal.NAME);
    assertTrue(everyone instanceof EveryonePrincipal);
    Group everyoneGroup = null;
    try {
        UserManager userMgr = getUserManager(root);
        everyoneGroup = userMgr.createGroup(EveryonePrincipal.NAME);
        root.commit();
        Principal ep = principalProvider.getPrincipal(EveryonePrincipal.NAME);
        assertFalse(ep instanceof EveryonePrincipal);
    } finally {
        if (everyoneGroup != null) {
            everyoneGroup.remove();
            root.commit();
        }
    }
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) UserManager(org.apache.jackrabbit.api.security.user.UserManager) AdminPrincipal(org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal) EveryonePrincipal(org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal) SystemUserPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal) Principal(java.security.Principal) EveryonePrincipal(org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 4 with EveryonePrincipal

use of org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal in project jackrabbit-oak by apache.

the class UserPrincipalProviderTest method testEveryoneMembers.

@Test
public void testEveryoneMembers() throws Exception {
    Principal everyone = principalProvider.getPrincipal(EveryonePrincipal.NAME);
    assertTrue(everyone instanceof EveryonePrincipal);
    Group everyoneGroup = null;
    try {
        UserManager userMgr = getUserManager(root);
        everyoneGroup = userMgr.createGroup(EveryonePrincipal.NAME);
        root.commit();
        Principal ep = principalProvider.getPrincipal(EveryonePrincipal.NAME);
        assertTrue(ep instanceof java.security.acl.Group);
        ((java.security.acl.Group) ep).members();
        ((java.security.acl.Group) ep).isMember(getTestUser().getPrincipal());
    } finally {
        if (everyoneGroup != null) {
            everyoneGroup.remove();
            root.commit();
        }
    }
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) UserManager(org.apache.jackrabbit.api.security.user.UserManager) AdminPrincipal(org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal) Principal(java.security.Principal) EveryonePrincipal(org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal) EveryonePrincipal(org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal) Test(org.junit.Test) AbstractPrincipalProviderTest(org.apache.jackrabbit.oak.security.principal.AbstractPrincipalProviderTest)

Aggregations

Principal (java.security.Principal)4 Group (org.apache.jackrabbit.api.security.user.Group)4 EveryonePrincipal (org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal)4 Test (org.junit.Test)4 UserManager (org.apache.jackrabbit.api.security.user.UserManager)3 AdminPrincipal (org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal)2 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)1 AbstractPrincipalProviderTest (org.apache.jackrabbit.oak.security.principal.AbstractPrincipalProviderTest)1 PrincipalImpl (org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)1 SystemUserPrincipal (org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal)1