Search in sources :

Example 6 with ExternalIdentity

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

the class DefaultSyncHandlerTest method sync.

private void sync(@Nonnull String id, boolean isGroup) throws Exception {
    SyncContext ctx = syncHandler.createContext(idp, userManager, getValueFactory());
    ExternalIdentity exIdentity = (isGroup) ? idp.getGroup(id) : idp.getUser(id);
    assertNotNull(exIdentity);
    SyncResult res = ctx.sync(exIdentity);
    assertSame(SyncResult.Status.ADD, res.getStatus());
    root.commit();
}
Also used : ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) SyncContext(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncContext) DefaultSyncContext(org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncContext) SyncResult(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult)

Example 7 with ExternalIdentity

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

the class DefaultSyncContextTest method testSyncUserById.

@Test
public void testSyncUserById() throws Exception {
    ExternalIdentity externalId = idp.listUsers().next();
    // no initial sync -> sync-by-id doesn't succeed
    SyncResult result = syncCtx.sync(externalId.getId());
    assertEquals(SyncResult.Status.NO_SUCH_AUTHORIZABLE, result.getStatus());
    // force sync
    syncCtx.sync(externalId);
    // try again
    syncCtx.setForceUserSync(true);
    result = syncCtx.sync(externalId.getId());
    assertEquals(SyncResult.Status.UPDATE, result.getStatus());
}
Also used : ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) 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 8 with ExternalIdentity

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

the class DefaultSyncContextTest method testGetAuthorizableUserWrongType.

@Test(expected = SyncException.class)
public void testGetAuthorizableUserWrongType() throws Exception {
    ExternalIdentity extUser = idp.listUsers().next();
    sync(extUser);
    syncCtx.getAuthorizable(extUser, Group.class);
}
Also used : 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 9 with ExternalIdentity

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

the class DefaultSyncContextTest method testGetAuthorizableUser.

@Test
public void testGetAuthorizableUser() throws Exception {
    ExternalIdentity extUser = idp.listUsers().next();
    User user = syncCtx.getAuthorizable(extUser, User.class);
    assertNull(user);
    sync(extUser);
    user = syncCtx.getAuthorizable(extUser, User.class);
    assertNotNull(user);
}
Also used : User(org.apache.jackrabbit.api.security.user.User) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) 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 10 with ExternalIdentity

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

the class DefaultSyncContextTest method testIsSameIDPSyncedGroup.

@Test
public void testIsSameIDPSyncedGroup() throws Exception {
    ExternalIdentity externalGroup = idp.listGroups().next();
    sync(externalGroup);
    assertTrue(syncCtx.isSameIDP(userManager.getAuthorizable(externalGroup.getId())));
}
Also used : ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Aggregations

ExternalIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity)40 Test (org.junit.Test)34 AbstractExternalAuthTest (org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest)20 ExternalIdentityRef (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef)18 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)9 ExternalGroup (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup)7 ExternalUser (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser)7 SyncResult (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult)7 UserManager (org.apache.jackrabbit.api.security.user.UserManager)5 SyncedIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity)4 Group (org.apache.jackrabbit.api.security.user.Group)3 HashMap (java.util.HashMap)2 ExternalIdentityException (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityException)2 PrincipalImpl (org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)2 Principal (java.security.Principal)1 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 User (org.apache.jackrabbit.api.security.user.User)1 Tree (org.apache.jackrabbit.oak.api.Tree)1 DebugTimer (org.apache.jackrabbit.oak.commons.DebugTimer)1