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();
}
}
}
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")));
}
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();
}
}
}
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();
}
}
}
Aggregations