use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit-oak by apache.
the class PrincipalManagerTest method testGetAllPrincipals.
@Test
public void testGetAllPrincipals() {
PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_ALL);
while (it.hasNext()) {
Principal p = it.nextPrincipal();
assertTrue(principalMgr.hasPrincipal(p.getName()));
assertEquals(principalMgr.getPrincipal(p.getName()), p);
}
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit-oak by apache.
the class PrincipalManagerTest method testMembers.
@Test
public void testMembers() {
PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_ALL);
while (it.hasNext()) {
Principal p = it.nextPrincipal();
if (p.equals(principalMgr.getEveryone())) {
continue;
}
if (isGroup(p)) {
Enumeration<? extends Principal> en = ((java.security.acl.Group) p).members();
while (en.hasMoreElements()) {
Principal memb = en.nextElement();
assertTrue(principalMgr.hasPrincipal(memb.getName()));
}
}
}
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit-oak by apache.
the class PrincipalManagerTest method testEveryoneGroupMembership.
@Test
public void testEveryoneGroupMembership() {
Principal everyone = EveryonePrincipal.getInstance();
for (PrincipalIterator membership = principalMgr.getGroupMembership(everyone); membership.hasNext(); ) {
Principal gr = membership.nextPrincipal();
assertTrue(isGroup(gr));
if (gr.equals(everyone)) {
fail("Everyone must never be a member of the EveryOne group.");
}
}
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit-oak by apache.
the class PrincipalManagerTest method testGetMembersConsistentWithMembership.
@Test
public void testGetMembersConsistentWithMembership() {
Principal everyone = principalMgr.getEveryone();
PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_GROUP);
while (it.hasNext()) {
Principal p = it.nextPrincipal();
if (p.equals(everyone)) {
continue;
}
assertTrue(isGroup(p));
Enumeration<? extends Principal> members = ((java.security.acl.Group) p).members();
while (members.hasMoreElements()) {
Principal memb = members.nextElement();
Principal group = null;
PrincipalIterator mship = principalMgr.getGroupMembership(memb);
while (mship.hasNext() && group == null) {
Principal gr = mship.nextPrincipal();
if (p.equals(gr)) {
group = gr;
}
}
assertNotNull("Group member " + memb.getName() + "does not reveal group upon getGroupMembership", p.getName());
}
}
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit-oak by apache.
the class PrincipalManagerTest method testFindPrincipal.
@Test
public void testFindPrincipal() {
for (Principal pcpl : adminPrincipals) {
if (pcpl.equals(everyone)) {
continue;
}
assertTrue(principalMgr.hasPrincipal(pcpl.getName()));
PrincipalIterator it = principalMgr.findPrincipals(pcpl.getName());
// search must find at least a single principal
assertTrue("findPrincipals does not find principal with filter '" + pcpl.getName() + '\'', it.hasNext());
}
}
Aggregations