Search in sources :

Example 1 with ExternalIdentity

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

the class DefaultSyncContextTest method testIsExpiredSyncedUser.

@Test
public void testIsExpiredSyncedUser() throws Exception {
    ExternalIdentity externalUser = idp.listUsers().next();
    sync(externalUser);
    Authorizable a = userManager.getAuthorizable(externalUser.getId());
    assertFalse(syncCtx.isExpired(a, syncConfig.user().getExpirationTime(), "any"));
    assertTrue(syncCtx.isExpired(a, -1, "any"));
    // create a ctx with a newer 'now'
    DefaultSyncContext ctx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory);
    long expTime = ctx.now - syncCtx.now - 1;
    assertTrue(ctx.isExpired(a, expTime, "any"));
    // remove last-sync property
    a.removeProperty(DefaultSyncContext.REP_LAST_SYNCED);
    assertTrue(syncCtx.isExpired(a, syncConfig.user().getExpirationTime(), "any"));
}
Also used : ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Example 2 with ExternalIdentity

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

the class DefaultSyncContextTest method testGetIdentityRefSyncUser.

@Test
public void testGetIdentityRefSyncUser() throws Exception {
    ExternalIdentity externalUser = idp.listUsers().next();
    sync(externalUser);
    ExternalIdentityRef ref = DefaultSyncContext.getIdentityRef(userManager.getAuthorizable(externalUser.getId()));
    assertNotNull(ref);
    assertEquals(externalUser.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 3 with ExternalIdentity

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

the class ExternalGroupPrincipalProviderTest method collectExpectedPrincipals.

private void collectExpectedPrincipals(Set<Principal> grPrincipals, @Nonnull Iterable<ExternalIdentityRef> declaredGroups, long depth) throws Exception {
    if (depth <= 0) {
        return;
    }
    for (ExternalIdentityRef ref : declaredGroups) {
        ExternalIdentity ei = idp.getIdentity(ref);
        grPrincipals.add(new PrincipalImpl(ei.getPrincipalName()));
        collectExpectedPrincipals(grPrincipals, ei.getDeclaredGroups(), depth - 1);
    }
}
Also used : ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)

Example 4 with ExternalIdentity

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

the class SyncMBeanImplTest method testSyncAllUsers.

@Test
public void testSyncAllUsers() throws Exception {
    // first sync external users into the repo
    syncMBean.syncAllExternalUsers();
    // verify effect of syncAllUsers
    String[] result = syncMBean.syncAllUsers(false);
    Map<String, String> expected = getExpectedUserResult("upd", true);
    assertResultMessages(result, expected);
    UserManager userManager = getUserManager();
    for (String id : expected.keySet()) {
        ExternalIdentity ei = idp.getUser(id);
        if (ei == null) {
            ei = idp.getGroup(id);
        }
        assertSync(ei, userManager);
    }
}
Also used : UserManager(org.apache.jackrabbit.api.security.user.UserManager) ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) Test(org.junit.Test)

Example 5 with ExternalIdentity

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

the class SyncMBeanImplTest method testSyncAllExternalUsersAgain.

@Test
public void testSyncAllExternalUsersAgain() throws Exception {
    syncMBean.syncAllExternalUsers();
    // sync again
    String[] result = syncMBean.syncAllExternalUsers();
    // verify result
    Map<String, String> expected = getExpectedUserResult("upd", false);
    assertResultMessages(result, expected);
    UserManager userManager = getUserManager();
    for (String id : expected.keySet()) {
        ExternalIdentity ei = idp.getUser(id);
        if (ei == null) {
            ei = idp.getGroup(id);
        }
        assertSync(ei, userManager);
    }
}
Also used : UserManager(org.apache.jackrabbit.api.security.user.UserManager) ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) 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 GroupPrincipal (org.apache.jackrabbit.api.security.principal.GroupPrincipal)1 User (org.apache.jackrabbit.api.security.user.User)1 Tree (org.apache.jackrabbit.oak.api.Tree)1