use of org.apache.jackrabbit.api.security.principal.GroupPrincipal 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 = ((GroupPrincipal) 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.GroupPrincipal 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 = ((GroupPrincipal) p).members();
while (en.hasMoreElements()) {
Principal memb = en.nextElement();
assertTrue(principalMgr.hasPrincipal(memb.getName()));
}
}
}
}
use of org.apache.jackrabbit.api.security.principal.GroupPrincipal in project jackrabbit-oak by apache.
the class ExternalGroupPrincipalProviderTest method testGetPrincipalDynamicGroup.
@Test
public void testGetPrincipalDynamicGroup() throws Exception {
for (ExternalIdentityRef ref : idp.getUser(USER_ID).getDeclaredGroups()) {
String princName = idp.getIdentity(ref).getPrincipalName();
Principal principal = principalProvider.getPrincipal(princName);
assertNotNull(principal);
assertTrue(principal instanceof GroupPrincipal);
}
}
use of org.apache.jackrabbit.api.security.principal.GroupPrincipal in project jackrabbit-oak by apache.
the class ExternalGroupPrincipalTest method testIsMember.
@Test
public void testIsMember() throws Exception {
ExternalUser externalUser = idp.getUser(USER_ID);
GroupPrincipal principal = getGroupPrincipal(externalUser.getDeclaredGroups().iterator().next());
assertTrue(principal.isMember(new PrincipalImpl(externalUser.getPrincipalName())));
assertTrue(principal.isMember(getUserManager(root).getAuthorizable(USER_ID).getPrincipal()));
}
use of org.apache.jackrabbit.api.security.principal.GroupPrincipal in project jackrabbit-oak by apache.
the class ExternalGroupPrincipalTest method testIsMemberLocalGroup.
@Test
public void testIsMemberLocalGroup() throws Exception {
Group gr = createTestGroup();
GroupPrincipal principal = getGroupPrincipal();
assertFalse(principal.isMember(gr.getPrincipal()));
assertFalse(principal.isMember(new PrincipalImpl(gr.getPrincipal().getName())));
}
Aggregations