use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit by apache.
the class DefaultPrincipalProviderTest method testInheritedMemberShip.
public void testInheritedMemberShip() throws RepositoryException, NotExecutableException {
Principal up = getTestPrincipal();
User u = null;
Group gr1 = null;
Group gr2 = null;
try {
u = userMgr.createUser(up.getName(), buildPassword(up));
gr1 = userMgr.createGroup(getTestPrincipal());
gr2 = userMgr.createGroup(getTestPrincipal());
save(superuser);
gr1.addMember(gr2);
gr2.addMember(u);
save(superuser);
PrincipalIterator it = principalProvider.getGroupMembership(u.getPrincipal());
while (it.hasNext()) {
Principal p = it.nextPrincipal();
if (p.equals(gr1.getPrincipal())) {
// success return
return;
}
}
fail("User principal " + up.getName() + " must have inherited group membership for " + gr1.getPrincipal().getName());
} finally {
if (gr2 != null && u != null)
gr2.removeMember(u);
if (gr1 != null && gr2 != null)
gr1.removeMember(gr2);
if (gr1 != null)
gr1.remove();
if (gr2 != null)
gr2.remove();
if (u != null)
u.remove();
save(superuser);
}
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit-oak by apache.
the class GetGroupPrincipalsTest method runTest.
@Override
public void runTest() throws Exception {
PrincipalManager principalManager = ((JackrabbitSession) session).getPrincipalManager();
for (int i = 0; i < 1000; i++) {
Principal p = principalManager.getPrincipal(principalName);
PrincipalIterator principals = principalManager.getGroupMembership(p);
// while (principals.hasNext()) {
// Principal groupPrincipal = principals.nextPrincipal();
// }
}
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit-oak by apache.
the class ImpersonationImplTest method testGetImpersonatorsImpersonatorRemoved.
@Test
public void testGetImpersonatorsImpersonatorRemoved() throws Exception {
Principal p = impersonator.getPrincipal();
impersonator.remove();
PrincipalIterator it = impersonation.getImpersonators();
assertTrue(it.hasNext());
assertTrue(Iterators.contains(it, p));
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit-oak by apache.
the class PrincipalManagerImplTest method assertMembership.
private static void assertMembership(@Nonnull PrincipalManager mgr, int searchType) {
PrincipalIterator it = mgr.getPrincipals(searchType);
while (it.hasNext()) {
Principal p = it.nextPrincipal();
if (p.equals(EveryonePrincipal.getInstance())) {
continue;
}
boolean atleastEveryone = false;
for (PrincipalIterator membership = mgr.getGroupMembership(p); membership.hasNext(); ) {
Principal gr = membership.nextPrincipal();
assertTrue(isGroup(gr));
if (gr.equals(EveryonePrincipal.getInstance())) {
atleastEveryone = true;
}
}
assertTrue("All principals (except everyone) must be member of the everyone group.", atleastEveryone);
}
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit-oak by apache.
the class PrincipalManagerImplTest method testFindPrincipalByTypeAll.
@Test
public void testFindPrincipalByTypeAll() {
for (Principal pcpl : testPrincipals) {
PrincipalIterator it = principalMgr.findPrincipals(pcpl.getName(), PrincipalManager.SEARCH_TYPE_ALL);
assertTrue("findPrincipals does not find principal with filter '" + pcpl.getName() + '\'', Iterators.contains(it, pcpl));
}
}
Aggregations