Search in sources :

Example 31 with SyncedIdentity

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

the class DefaultSyncHandlerTest method testFindIdentityWithRemovedExternalId.

@Test
public void testFindIdentityWithRemovedExternalId() throws Exception {
    sync(USER_ID, false);
    // NOTE: use system-root to remove the protected rep:externalId property (since Oak 1.5.8)
    Authorizable authorizable = userManager.getAuthorizable(USER_ID);
    Root systemRoot = getSystemRoot();
    systemRoot.getTree(authorizable.getPath()).removeProperty(DefaultSyncContext.REP_EXTERNAL_ID);
    systemRoot.commit();
    root.refresh();
    SyncedIdentity si = syncHandler.findIdentity(userManager, USER_ID);
    assertNotNull(si);
    assertNull(si.getExternalIdRef());
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) 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 32 with SyncedIdentity

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

the class DefaultSyncedIdentityTest method testGetId.

@Test
public void testGetId() {
    assertEquals(externalUser.getId(), si.getId());
    assertEquals(externalGroup.getId(), siGroup.getId());
    SyncedIdentity siOtherId = new DefaultSyncedIdentity("otherId", externalUser.getExternalId(), false, -1);
    assertEquals("otherId", siOtherId.getId());
}
Also used : SyncedIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity) Test(org.junit.Test)

Example 33 with SyncedIdentity

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

the class DefaultSyncContextTest method testSyncByForeignId2.

@Test
public void testSyncByForeignId2() throws Exception {
    User u = userManager.getAuthorizable(getTestUser().getID(), User.class);
    setExternalID(u, "differentIDP");
    SyncResult result = syncCtx.sync(u.getID());
    assertEquals(SyncResult.Status.FOREIGN, result.getStatus());
    SyncedIdentity si = result.getIdentity();
    assertNotNull(si);
    assertEquals(DefaultSyncContext.getIdentityRef(u), si.getExternalIdRef());
}
Also used : User(org.apache.jackrabbit.api.security.user.User) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) 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 34 with SyncedIdentity

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

the class DefaultSyncedIdentityTest method testLastSynced.

@Test
public void testLastSynced() {
    assertEquals(234, si.lastSynced());
    assertEquals(234, siGroup.lastSynced());
    SyncedIdentity siNeverSynced = new DefaultSyncedIdentity(TestIdentityProvider.ID_TEST_USER, externalUser.getExternalId(), false, -1);
    assertEquals(-1, siNeverSynced.lastSynced());
}
Also used : SyncedIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity) 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