Search in sources :

Example 21 with ExternalGroup

use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup in project jackrabbit-oak by apache.

the class SyncMBeanImplTest method testSyncAllGroups.

@Test
public void testSyncAllGroups() throws Exception {
    // first sync external users into the repo
    Map<String, String> expected = new HashMap<>();
    Iterator<ExternalGroup> grIt = idp.listGroups();
    while (grIt.hasNext()) {
        ExternalGroup eg = grIt.next();
        sync(idp, eg.getId(), true);
        expected.put(eg.getId(), "upd");
    }
    // verify effect of syncAllUsers (which in this case are groups)
    String[] result = syncMBean.syncAllUsers(false);
    assertResultMessages(result, expected);
    UserManager userManager = getUserManager();
    for (String id : expected.keySet()) {
        ExternalIdentity ei = idp.getGroup(id);
        assertSync(ei, userManager);
    }
}
Also used : HashMap(java.util.HashMap) ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) UserManager(org.apache.jackrabbit.api.security.user.UserManager) ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) Test(org.junit.Test)

Example 22 with ExternalGroup

use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup in project jackrabbit-oak by apache.

the class ExternalGroupPrincipalProviderTest method testFindPrincipalsFiltersDuplicates.

@Test
public void testFindPrincipalsFiltersDuplicates() throws Exception {
    ExternalGroup gr = idp.getGroup("a");
    ExternalUser otherUser = new TestUser("anotherUser", ImmutableSet.of(gr.getExternalId()));
    sync(otherUser);
    Set<Principal> expected = new HashSet<>();
    expected.add(new PrincipalImpl(gr.getPrincipalName()));
    long depth = syncConfig.user().getMembershipNestingDepth();
    if (depth > 1) {
        collectExpectedPrincipals(expected, gr.getDeclaredGroups(), --depth);
    }
    Iterator<? extends Principal> res = principalProvider.findPrincipals("a", PrincipalManager.SEARCH_TYPE_ALL);
    assertTrue(res.hasNext());
    assertEquals(expected, ImmutableSet.copyOf(res));
    Iterator<? extends Principal> res2 = principalProvider.findPrincipals("a", false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1);
    assertTrue(res2.hasNext());
    assertEquals(expected, ImmutableSet.copyOf(res2));
}
Also used : ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) ItemBasedPrincipal(org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal) Principal(java.security.Principal) GroupPrincipal(org.apache.jackrabbit.api.security.principal.GroupPrincipal) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 23 with ExternalGroup

use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup in project jackrabbit-oak by apache.

the class LargeLdapProviderTest method testGetMembers.

@Test
public void testGetMembers() throws Exception {
    ExternalIdentityRef ref = new ExternalIdentityRef(GROUP_DN, IDP_NAME);
    ExternalIdentity id = idp.getIdentity(ref);
    assertTrue("Group instance", id instanceof ExternalGroup);
    ExternalGroup grp = (ExternalGroup) id;
    assertIfEquals("Group members", TEST_MEMBERS, grp.getDeclaredMembers());
}
Also used : ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) Test(org.junit.Test)

Example 24 with ExternalGroup

use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup in project jackrabbit-oak by apache.

the class LdapIdentityProviderTest method testGetDeclaredMembers.

@Test
public void testGetDeclaredMembers() throws Exception {
    ExternalGroup gr = idp.getGroup(TEST_GROUP1_NAME);
    Iterable<ExternalIdentityRef> memberrefs = gr.getDeclaredMembers();
    Iterable<String> memberIds = Iterables.transform(memberrefs, externalIdentityRef -> externalIdentityRef.getId());
    Set<String> expected = ImmutableSet.copyOf(TEST_GROUP1_MEMBERS);
    assertEquals(expected, ImmutableSet.copyOf(memberIds));
}
Also used : ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) Test(org.junit.Test)

Example 25 with ExternalGroup

use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup in project jackrabbit-oak by apache.

the class LdapIdentityProviderTest method testGetGroupByUnknownName.

@Test
public void testGetGroupByUnknownName() throws Exception {
    ExternalGroup group = idp.getGroup("unknown");
    assertNull(group);
}
Also used : ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) Test(org.junit.Test)

Aggregations

ExternalGroup (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup)28 Test (org.junit.Test)24 ExternalIdentityRef (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef)13 AbstractExternalAuthTest (org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest)8 ExternalIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity)8 Group (org.apache.jackrabbit.api.security.user.Group)7 SyncResult (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult)6 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)3 DebugTimer (org.apache.jackrabbit.oak.commons.DebugTimer)3 ExternalUser (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser)3 SyncedIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity)3 NotNull (org.jetbrains.annotations.NotNull)3 Principal (java.security.Principal)2 HashMap (java.util.HashMap)2 RepositoryException (javax.jcr.RepositoryException)2 User (org.apache.jackrabbit.api.security.user.User)2 UserManager (org.apache.jackrabbit.api.security.user.UserManager)2 ExternalIdentityException (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityException)2 SyncContext (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncContext)2 SyncException (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncException)2