Search in sources :

Example 46 with ExternalIdentityRef

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

the class LdapProviderTest method testGetMembers.

@Test
public void testGetMembers() throws Exception {
    ExternalIdentityRef ref = new ExternalIdentityRef(TEST_GROUP1_DN, IDP_NAME);
    ExternalIdentity id = idp.getIdentity(ref);
    assertTrue("Group instance", id instanceof ExternalGroup);
    ExternalGroup grp = (ExternalGroup) id;
    assertIfEquals("Group members", TEST_GROUP1_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 47 with ExternalIdentityRef

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

the class DefaultSyncHandlerTest method testListIdentitiesIgnoresLocal.

@Test
public void testListIdentitiesIgnoresLocal() throws Exception {
    sync(USER_ID, false);
    Iterator<SyncedIdentity> identities = syncHandler.listIdentities(userManager);
    while (identities.hasNext()) {
        SyncedIdentity si = identities.next();
        ExternalIdentityRef ref = si.getExternalIdRef();
        assertNotNull(ref);
        assertNotNull(ref.getProviderName());
    }
}
Also used : ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) DefaultSyncedIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncedIdentity) SyncedIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity) Test(org.junit.Test)

Example 48 with ExternalIdentityRef

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

the class DynamicSyncContextTest method assertSyncedMembership.

private static void assertSyncedMembership(@Nonnull UserManager userManager, @Nonnull Authorizable a, @Nonnull ExternalIdentity externalIdentity) throws Exception {
    for (ExternalIdentityRef ref : externalIdentity.getDeclaredGroups()) {
        Group gr = userManager.getAuthorizable(ref.getId(), Group.class);
        assertNotNull(gr);
        assertTrue(gr.isMember(a));
    }
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef)

Example 49 with ExternalIdentityRef

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

the class DefaultSyncContextTest method testGetIdentityRefSyncGroup.

@Test
public void testGetIdentityRefSyncGroup() throws Exception {
    ExternalIdentity externalGroup = idp.listGroups().next();
    sync(externalGroup);
    ExternalIdentityRef ref = DefaultSyncContext.getIdentityRef(userManager.getAuthorizable(externalGroup.getId()));
    assertNotNull(ref);
    assertEquals(externalGroup.getExternalId(), ref);
}
Also used : ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Example 50 with ExternalIdentityRef

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

the class DefaultSyncContextTest method testSyncForeignExternalGroup.

@Test
public void testSyncForeignExternalGroup() throws Exception {
    ExternalIdentity foreign = new TestIdentityProvider.ForeignExternalGroup();
    SyncResult res = syncCtx.sync(foreign);
    assertNotNull(res);
    assertSame(SyncResult.Status.FOREIGN, res.getStatus());
    // expect {@code SyncedIdentity} in accordance with {@code sync(String userId)},
    // where the authorizable is found to be linked to a different IDP.
    SyncedIdentity si = res.getIdentity();
    assertNotNull(si);
    assertEquals(foreign.getId(), si.getId());
    ExternalIdentityRef ref = si.getExternalIdRef();
    assertNotNull(ref);
    assertEquals(foreign.getExternalId(), ref);
    assertTrue(si.isGroup());
    assertEquals(-1, si.lastSynced());
    assertFalse(root.hasPendingChanges());
}
Also used : ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) SyncedIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity) SyncResult(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Aggregations

ExternalIdentityRef (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef)64 Test (org.junit.Test)47 ExternalUser (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser)23 ExternalIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity)18 ExternalGroup (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup)15 AbstractExternalAuthTest (org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest)14 Group (org.apache.jackrabbit.api.security.user.Group)11 User (org.apache.jackrabbit.api.security.user.User)10 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)7 SyncedIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity)6 Nonnull (javax.annotation.Nonnull)5 DebugTimer (org.apache.jackrabbit.oak.commons.DebugTimer)5 ExternalIdentityException (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityException)5 SyncResult (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult)5 Principal (java.security.Principal)4 HashMap (java.util.HashMap)4 LdapInvalidAttributeValueException (org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException)4 UserManager (org.apache.jackrabbit.api.security.user.UserManager)4 Root (org.apache.jackrabbit.oak.api.Root)4 DefaultSyncedIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncedIdentity)4