public Principal nextElement() { return members.nextPrincipal(); } };
public Principal nextElement() { return members.nextPrincipal(); } };
/** * @return a Collection of principals that contains the current user * principal and all groups it is member of. */ protected Set<Principal> getPrincipals() { // use linked HashSet instead of HashSet in order to maintain the order // of principals (as in the Subject). Set<Principal> principals = new LinkedHashSet<Principal>(); principals.add(principal); PrincipalIterator groups = principalProvider.getGroupMembership(principal); while (groups.hasNext()) { principals.add(groups.nextPrincipal()); } return principals; }
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; }
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; }
private Principal[] getPrincipals(Credentials credentials) throws Exception { Set<Principal> principals = new HashSet<Principal>(); if (credentials instanceof SimpleCredentials) { Principal p = principalMgr.getPrincipal(((SimpleCredentials) credentials).getUserID()); if (p != null) { principals.add(p); PrincipalIterator principalIterator = principalMgr.getGroupMembership(p); while (principalIterator.hasNext()) { principals.add(principalIterator.nextPrincipal()); } } } return principals.toArray(new Principal[principals.size()]); }
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 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)); } }
@Override protected void setUp() throws Exception { super.setUp(); principalManager = ((JackrabbitSession) superuser).getPrincipalManager(); // NOTE: this method call doesn't make to much sense outside of a // simple test with a very limited number of principals (!!) PrincipalIterator principalIterator = principalManager.getPrincipals(PrincipalManager.SEARCH_TYPE_NOT_GROUP); if (principalIterator.hasNext()) { testPrincipalName = principalIterator.nextPrincipal().getName(); } if (testPrincipalName == null) { throw new NotExecutableException(); } }
public void testGroupMembers() { PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_ALL); while (it.hasNext()) { Principal p = it.nextPrincipal(); if (isGroup(p) && !p.equals(principalMgr.getEveryone())) { Enumeration<? extends Principal> en = ((GroupPrincipal) p).members(); while (en.hasMoreElements()) { Principal memb = en.nextElement(); assertTrue(principalMgr.hasPrincipal(memb.getName())); } } } }
@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 testGetPrincipals() { PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_NOT_GROUP); while (it.hasNext()) { Principal p = it.nextPrincipal(); assertFalse(isGroup(p)); } }
@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 testGetGroupPrincipals() { PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_GROUP); while (it.hasNext()) { Principal p = it.nextPrincipal(); assertTrue(isGroup(p)); } }
public void testEveryoneIsMemberofEveryone() throws RepositoryException { GroupPrincipal everyone = (GroupPrincipal) principalManager.getEveryone(); PrincipalIterator it = principalManager.getPrincipals(PrincipalManager.SEARCH_TYPE_ALL); // EXERCISE: discuss the dynamic nature of the everyone group principal while (it.hasNext()) { Principal principal = it.nextPrincipal(); if (everyone.equals(principal)) { assertFalse(everyone.isMember(principal)); } else { assertTrue(everyone.isMember(principal)); } } }
@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."); } } }
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()); }