public boolean hasMoreElements() { return members.hasNext(); } public Principal nextElement() {
private Set<Principal> getAuthorizablesToCheck(Authorizable authorizable, Context context) throws RepositoryException { Set<Principal> principals = new HashSet<>(); Principal principal = authorizable.getPrincipal(); principals.add(principal); for (PrincipalIterator it = (context.getSession()).getPrincipalManager() .getGroupMembership(principal); it.hasNext(); ) { principals.add(it.nextPrincipal()); } return principals; }
@Test public void testFindUnknownByTypeNotGroup() { String unknownHint = TestPrincipalProvider.UNKNOWN.getName().substring(0, 4); assertFalse(principalMgr.findPrincipals(unknownHint, PrincipalManager.SEARCH_TYPE_NOT_GROUP).hasNext()); } }
@Test public void testFindUnknownByTypeAll() { String unknownHint = TestPrincipalProvider.UNKNOWN.getName().substring(0, 4); assertFalse(principalMgr.findPrincipals(unknownHint, PrincipalManager.SEARCH_TYPE_ALL).hasNext()); }
@Test public void testFindUnknownByTypeGroup() { String unknownHint = TestPrincipalProvider.UNKNOWN.getName().substring(0, 4); assertFalse(principalMgr.findPrincipals(unknownHint, PrincipalManager.SEARCH_TYPE_GROUP).hasNext()); }
public void testFindPrincipal() { Principal[] pcpls = getPrincipals(superuser); for (Principal pcpl : pcpls) { if (pcpl.equals(everyone)) { continue; } 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()); } }
@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()); } }
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); } }
public void testUnknownUserMemberShip() throws RepositoryException { Principal userPrincipal = getTestPrincipal(); PrincipalIterator pit = principalProvider.getGroupMembership(userPrincipal); // unknown user must be in 'everyone' group but nothing else assertTrue(pit.hasNext()); assertEquals(EveryonePrincipal.getInstance(), pit.nextPrincipal()); assertFalse(pit.hasNext()); }
public void testGetGroupPrincipals() { PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_GROUP); while (it.hasNext()) { Principal p = it.nextPrincipal(); assertTrue(isGroup(p)); } }
@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); } }
public void testGetPrincipals() { PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_NOT_GROUP); while (it.hasNext()) { Principal p = it.nextPrincipal(); assertFalse(isGroup(p)); } }
@Test public void testGetPrincipalsNonGroupContainsNoGroups() { PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_NOT_GROUP); while (it.hasNext()) { Principal p = it.nextPrincipal(); assertFalse(isGroup(p)); } }
private Principal getValidPrincipal() throws NotExecutableException, RepositoryException { if (!(superuser instanceof JackrabbitSession)) { throw new NotExecutableException(); } PrincipalManager pMgr = ((JackrabbitSession) superuser).getPrincipalManager(); PrincipalIterator it = pMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_NOT_GROUP); if (it.hasNext()) { return it.nextPrincipal(); } else { throw new NotExecutableException(); } }
@Test public void testGetPrincipalsGroupContainsGroups() { PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_GROUP); while (it.hasNext()) { Principal p = it.nextPrincipal(); assertTrue(isGroup(p)); } }
@Test public void testGetPrincipals() { PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_NOT_GROUP); while (it.hasNext()) { Principal p = it.nextPrincipal(); assertFalse(isGroup(p)); } }
@Test public void testGetGroupPrincipals() { PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_GROUP); while (it.hasNext()) { Principal p = it.nextPrincipal(); assertTrue(isGroup(p)); } }
@Test public void testGetImpersonators() throws Exception { PrincipalIterator it = impersonation.getImpersonators(); assertTrue(it.hasNext()); assertTrue(Iterators.contains(it, impersonator.getPrincipal())); }
@Test public void testGetImpersonatorsImpersonatorRemoved() throws Exception { Principal p = impersonator.getPrincipal(); impersonator.remove(); PrincipalIterator it = impersonation.getImpersonators(); assertTrue(it.hasNext()); assertTrue(Iterators.contains(it, p)); }
@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."); } } }