Search in sources :

Example 1 with ExternalGroup

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

the class SyncMBeanImplTest method testInitialSyncExternalGroup.

@Test
public void testInitialSyncExternalGroup() throws Exception {
    ExternalGroup externalGroup = idp.getGroup("a");
    String[] externalId = new String[] { externalGroup.getExternalId().getString() };
    String[] result = syncMBean.syncExternalUsers(externalId);
    assertResultMessages(result, "a", "add");
    UserManager userManager = getUserManager();
    Group aGroup = userManager.getAuthorizable(externalGroup.getId(), Group.class);
    assertNotNull(aGroup);
    // membership of groups are not synced (unless imposed by user-sync with membership depth)
    for (ExternalIdentityRef groupRef : externalGroup.getDeclaredGroups()) {
        assertNull(userManager.getAuthorizable(groupRef.getId()));
    }
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) UserManager(org.apache.jackrabbit.api.security.user.UserManager) Test(org.junit.Test)

Example 2 with ExternalGroup

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

the class LdapProviderTest method testGetGroupByName.

@Test
public void testGetGroupByName() throws Exception {
    ExternalGroup group = idp.getGroup(TEST_GROUP1_NAME);
    assertNotNull("Group 1 must exist", group);
    assertEquals("Group Ref", TEST_GROUP1_DN, group.getExternalId().getId());
}
Also used : ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) Test(org.junit.Test)

Example 3 with ExternalGroup

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

the class LdapProviderTest method testGetGroupByRef.

@Test
public void testGetGroupByRef() throws Exception {
    ExternalIdentityRef ref = new ExternalIdentityRef(TEST_GROUP1_DN, IDP_NAME);
    ExternalIdentity id = idp.getIdentity(ref);
    assertTrue("Group instance", id instanceof ExternalGroup);
    assertEquals("Group Name", TEST_GROUP1_NAME, id.getId());
}
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 4 with ExternalGroup

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

the class DefaultSyncContextTest method testSyncExternalToForeignLocalGroup.

@Test
public void testSyncExternalToForeignLocalGroup() throws Exception {
    ExternalGroup external = idp.listGroups().next();
    syncCtx.sync(external);
    Group gr = userManager.getAuthorizable(external.getId(), Group.class);
    setExternalID(gr, "differentIDP");
    SyncResult result = syncCtx.sync(external);
    assertEquals(SyncResult.Status.FOREIGN, result.getStatus());
    SyncedIdentity si = result.getIdentity();
    assertNotNull(si);
    assertEquals(external.getExternalId(), si.getExternalIdRef());
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) 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)

Example 5 with ExternalGroup

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

the class DefaultSyncContextTest method testSyncExternalToExistingLocalGroup.

@Test
public void testSyncExternalToExistingLocalGroup() throws Exception {
    ExternalGroup external = idp.listGroups().next();
    syncCtx.sync(external);
    Group gr = userManager.getAuthorizable(external.getId(), Group.class);
    gr.removeProperty(ExternalIdentityConstants.REP_EXTERNAL_ID);
    SyncResult result = syncCtx.sync(external);
    assertEquals(SyncResult.Status.FOREIGN, result.getStatus());
    SyncedIdentity si = result.getIdentity();
    assertNotNull(si);
    assertEquals(external.getExternalId(), si.getExternalIdRef());
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) 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

ExternalGroup (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup)21 Test (org.junit.Test)17 AbstractExternalAuthTest (org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest)8 ExternalIdentityRef (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef)8 Group (org.apache.jackrabbit.api.security.user.Group)7 SyncResult (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult)6 ExternalIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity)5 Nonnull (javax.annotation.Nonnull)3 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 PrincipalImpl (org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)3 Principal (java.security.Principal)2 HashMap (java.util.HashMap)2 RepositoryException (javax.jcr.RepositoryException)2 GroupPrincipal (org.apache.jackrabbit.api.security.principal.GroupPrincipal)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