Search in sources :

Example 41 with ExternalIdentityRef

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

the class DynamicSyncContextTest method testSyncMembershipWithChangedExistingGroups.

@Test
public void testSyncMembershipWithChangedExistingGroups() throws Exception {
    long nesting = 1;
    syncConfig.user().setMembershipNestingDepth(nesting);
    ExternalUser externalUser = idp.getUser(USER_ID);
    DefaultSyncContext ctx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory);
    ctx.sync(externalUser);
    ctx.close();
    Authorizable a = userManager.getAuthorizable(externalUser.getId());
    assertSyncedMembership(userManager, a, externalUser);
    // sync user with modified membership => must be reflected
    // 1. empty set of declared groups
    ExternalUser mod = new TestUserWithGroupRefs(externalUser, ImmutableSet.<ExternalIdentityRef>of());
    syncContext.syncMembership(mod, a, nesting);
    assertSyncedMembership(userManager, a, mod);
    // 2. set with different groups that defined on IDP
    mod = new TestUserWithGroupRefs(externalUser, ImmutableSet.<ExternalIdentityRef>of(idp.getGroup("a").getExternalId(), idp.getGroup("aa").getExternalId(), idp.getGroup("secondGroup").getExternalId()));
    syncContext.syncMembership(mod, a, nesting);
    assertSyncedMembership(userManager, a, mod);
}
Also used : DefaultSyncContext(org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncContext) ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Example 42 with ExternalIdentityRef

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

the class ExternalGroupPrincipalProviderTest method testGetPrincipalInheritedGroups.

@Test
public void testGetPrincipalInheritedGroups() throws Exception {
    ImmutableSet<ExternalIdentityRef> declared = ImmutableSet.<ExternalIdentityRef>copyOf(idp.getUser(USER_ID).getDeclaredGroups());
    for (ExternalIdentityRef ref : declared) {
        for (ExternalIdentityRef inheritedGroupRef : idp.getIdentity(ref).getDeclaredGroups()) {
            if (declared.contains(inheritedGroupRef)) {
                continue;
            }
            String inheritedPrincName = idp.getIdentity(inheritedGroupRef).getPrincipalName();
            assertNull(principalProvider.getPrincipal(inheritedPrincName));
        }
    }
}
Also used : ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) Test(org.junit.Test)

Example 43 with ExternalIdentityRef

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

the class SyncMBeanImplTest method testSyncExternalLocal.

/**
     * @see <a href="https://issues.apache.org/jira/browse/OAK-4346">OAK-4346</a>
     */
@Test
public void testSyncExternalLocal() throws Exception {
    ExternalIdentityRef ref = new ExternalIdentityRef(UserConstants.DEFAULT_ANONYMOUS_ID, null);
    String[] result = syncMBean.syncExternalUsers(new String[] { ref.getString() });
    assertResultMessages(result, UserConstants.DEFAULT_ANONYMOUS_ID, "for");
}
Also used : ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) Test(org.junit.Test)

Example 44 with ExternalIdentityRef

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

the class SyncMBeanImplTest method testSyncExternalNonExisting.

@Test
public void testSyncExternalNonExisting() throws Exception {
    ExternalIdentityRef ref = new ExternalIdentityRef("nonExisting", idp.getName());
    String[] result = syncMBean.syncExternalUsers(new String[] { ref.getString() });
    assertResultMessages(result, "", "nsi");
}
Also used : ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) Test(org.junit.Test)

Example 45 with ExternalIdentityRef

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

the class SyncMBeanImplTest method testPurgeOrphanedUsersException.

@Test
public void testPurgeOrphanedUsersException() throws Exception {
    User u = getUserManager().createUser(TestIdentityProvider.ID_EXCEPTION, null);
    u.setProperty(DefaultSyncContext.REP_EXTERNAL_ID, getValueFactory().createValue(new ExternalIdentityRef(TestIdentityProvider.ID_EXCEPTION, idp.getName()).getString()));
    root.commit();
    String[] result = syncMBean.purgeOrphanedUsers();
    assertEquals(0, result.length);
}
Also used : User(org.apache.jackrabbit.api.security.user.User) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) Test(org.junit.Test)

Aggregations

ExternalIdentityRef (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef)64 Test (org.junit.Test)47 ExternalUser (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser)23 ExternalIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity)18 ExternalGroup (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup)15 AbstractExternalAuthTest (org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest)14 Group (org.apache.jackrabbit.api.security.user.Group)11 User (org.apache.jackrabbit.api.security.user.User)10 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)7 SyncedIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity)6 Nonnull (javax.annotation.Nonnull)5 DebugTimer (org.apache.jackrabbit.oak.commons.DebugTimer)5 ExternalIdentityException (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityException)5 SyncResult (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult)5 Principal (java.security.Principal)4 HashMap (java.util.HashMap)4 LdapInvalidAttributeValueException (org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException)4 UserManager (org.apache.jackrabbit.api.security.user.UserManager)4 Root (org.apache.jackrabbit.oak.api.Root)4 DefaultSyncedIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncedIdentity)4