Search in sources :

Example 26 with SyncedIdentity

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

the class DefaultSyncHandlerTest method testRequiresSyncAfterCreate.

@Test
public void testRequiresSyncAfterCreate() throws Exception {
    login(new SimpleCredentials(USER_ID, new char[0])).close();
    root.refresh();
    SyncedIdentity id = syncHandler.findIdentity(userManager, USER_ID);
    assertNotNull("Known authorizable should exist", id);
    assertFalse("Freshly synced id should not require sync", syncHandler.requiresSync(id));
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) 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 27 with SyncedIdentity

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

the class DefaultSyncContextTest method testSyncByForeignGroupId.

@Test
public void testSyncByForeignGroupId() throws Exception {
    SyncResult result = syncCtx.sync(createTestGroup().getID());
    assertEquals(SyncResult.Status.FOREIGN, result.getStatus());
    SyncedIdentity si = result.getIdentity();
    assertNotNull(si);
    assertNull(si.getExternalIdRef());
    assertTrue(si.isGroup());
}
Also used : 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 28 with SyncedIdentity

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

the class DefaultSyncHandlerTest method testRequiresSyncGroup.

@Test
public void testRequiresSyncGroup() throws Exception {
    sync("c", true);
    SyncedIdentity si = syncHandler.findIdentity(userManager, "c");
    assertNotNull(si);
    assertTrue(si.isGroup());
    assertFalse(syncHandler.requiresSync(si));
}
Also used : 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 29 with SyncedIdentity

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

the class DefaultSyncHandlerTest method testFindExternalIdentity.

@Test
public void testFindExternalIdentity() throws Exception {
    login(new SimpleCredentials(USER_ID, new char[0])).close();
    root.refresh();
    SyncedIdentity id = syncHandler.findIdentity(userManager, USER_ID);
    assertNotNull("known authorizable should exist", id);
    ExternalIdentityRef ref = id.getExternalIdRef();
    assertNotNull(ref);
    assertEquals("external user should have correct external ref.idp", idp.getName(), ref.getProviderName());
    assertEquals("external user should have correct external ref.id", USER_ID, id.getExternalIdRef().getId());
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) 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 30 with SyncedIdentity

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

the class DefaultSyncContextTest method testCreateSyncedIdentityLocalGroup.

@Test
public void testCreateSyncedIdentityLocalGroup() throws Exception {
    Group gr = createTestGroup();
    SyncedIdentity si = DefaultSyncContext.createSyncedIdentity(gr);
    assertNotNull(si);
    assertEquals(gr.getID(), si.getId());
    assertNull(si.getExternalIdRef());
    assertTrue(si.isGroup());
    assertEquals(-1, si.lastSynced());
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) SyncedIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Aggregations

SyncedIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity)34 Test (org.junit.Test)30 AbstractExternalAuthTest (org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest)15 DefaultSyncedIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncedIdentity)13 SyncResult (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult)11 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)6 ExternalIdentityRef (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef)6 ExternalGroup (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup)5 Group (org.apache.jackrabbit.api.security.user.Group)4 User (org.apache.jackrabbit.api.security.user.User)4 ExternalIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity)4 ExternalUser (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser)4 SimpleCredentials (javax.jcr.SimpleCredentials)3 RepositoryException (javax.jcr.RepositoryException)2 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Nonnull (javax.annotation.Nonnull)1 Value (javax.jcr.Value)1 LoginException (javax.security.auth.login.LoginException)1 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)1