use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit-oak by apache.
the class PrincipalManagerImplTest method testGetPrincipalsNonGroup.
@Test
public void testGetPrincipalsNonGroup() {
Iterator<? extends Principal> expected = provider.findPrincipals(PrincipalManager.SEARCH_TYPE_NOT_GROUP);
PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_NOT_GROUP);
assertIterator(expected, it);
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit-oak by apache.
the class PrincipalManagerImplTest method testFindPrincipal.
@Test
public void testFindPrincipal() {
for (Principal pcpl : testPrincipals) {
PrincipalIterator it = principalMgr.findPrincipals(pcpl.getName());
assertTrue("findPrincipals does not find principal with filter '" + pcpl.getName() + '\'', Iterators.contains(it, pcpl));
}
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit-oak by apache.
the class PrincipalManagerImplTest method testFindPrincipalByTypeGroup.
@Test
public void testFindPrincipalByTypeGroup() {
for (Principal pcpl : testPrincipals) {
if (isGroup(pcpl)) {
PrincipalIterator it = principalMgr.findPrincipals(pcpl.getName(), PrincipalManager.SEARCH_TYPE_GROUP);
assertTrue("findPrincipals does not find principal with filter '" + pcpl.getName() + '\'', Iterators.contains(it, pcpl));
} else {
PrincipalIterator it = principalMgr.findPrincipals(pcpl.getName(), PrincipalManager.SEARCH_TYPE_NOT_GROUP);
assertTrue("findPrincipals does not find principal with filter '" + pcpl.getName() + '\'', Iterators.contains(it, pcpl));
}
}
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit-oak by apache.
the class PrincipalManagerImplTest method testFindEveryone.
@Test
public void testFindEveryone() {
// untyped search -> everyone must be part of the result set
PrincipalIterator it = principalMgr.findPrincipals(EveryonePrincipal.NAME);
assertTrue("findPrincipals does not find principal with filter '" + EveryonePrincipal.NAME + '\'', Iterators.contains(it, EveryonePrincipal.getInstance()));
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit-oak by apache.
the class FindAuthorizablesTest method testFindAuthorizable.
@Test
public void testFindAuthorizable() throws RepositoryException, NotExecutableException {
Set<Principal> principals = new HashSet<Principal>();
PrincipalManager pMgr = ((JackrabbitSession) superuser).getPrincipalManager();
Principal p = pMgr.getPrincipal(superuser.getUserID());
if (p != null) {
principals.add(p);
PrincipalIterator principalIterator = pMgr.getGroupMembership(p);
while (principalIterator.hasNext()) {
principals.add(principalIterator.nextPrincipal());
}
}
Authorizable auth;
for (Principal principal : principals) {
auth = userMgr.getAuthorizable(principal);
if (auth != null) {
if (!auth.isGroup() && auth.hasProperty(UserConstants.REP_PRINCIPAL_NAME)) {
String val = auth.getProperty(UserConstants.REP_PRINCIPAL_NAME)[0].getString();
Iterator<Authorizable> users = userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, val);
// the result must contain 1 authorizable
assertTrue(users.hasNext());
Authorizable first = users.next();
assertEquals(first.getID(), val);
// since id is unique -> there should be no more users in
// the iterator left
assertFalse(users.hasNext());
}
}
}
}
Aggregations