Search in sources :

Example 6 with ExternalUser

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

the class DefaultSyncContextTest method testSyncDoesNotEnableUsers.

@Test
public void testSyncDoesNotEnableUsers() throws Exception {
    // configure to remove missing users, check that sync does not mess with disabled status
    syncConfig.user().setDisableMissing(false);
    // test sync with 'keepmissing' = false
    syncCtx.setKeepMissing(false);
    ExternalUser user = idp.listUsers().next();
    assertNotNull(user);
    SyncResult result = syncCtx.sync(user);
    assertEquals(SyncResult.Status.ADD, result.getStatus());
    Authorizable authorizable = userManager.getAuthorizable(user.getId());
    assertTrue(authorizable instanceof User);
    User u = (User) authorizable;
    // disable user
    u.disable("disabled locally");
    root.commit();
    // sync
    syncCtx.setForceUserSync(true);
    result = syncCtx.sync(user.getId());
    assertEquals(SyncResult.Status.UPDATE, result.getStatus());
    authorizable = userManager.getAuthorizable(user.getId());
    assertNotNull(authorizable);
    assertTrue(authorizable instanceof User);
    assertTrue(((User) authorizable).isDisabled());
}
Also used : User(org.apache.jackrabbit.api.security.user.User) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) 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 7 with ExternalUser

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

the class DefaultSyncContextTest method testSyncPropertiesEmptyMapExistingProps.

@Test
public void testSyncPropertiesEmptyMapExistingProps() throws Exception {
    ExternalUser externalUser = idp.getUser(TestIdentityProvider.ID_SECOND_USER);
    Authorizable a = syncCtx.createUser(externalUser);
    Value anyValue = valueFactory.createValue("any");
    Map<String, ?> extProps = externalUser.getProperties();
    for (String propName : extProps.keySet()) {
        a.setProperty(propName, anyValue);
    }
    syncCtx.syncProperties(externalUser, a, ImmutableMap.<String, String>of());
    for (String propName : extProps.keySet()) {
        assertTrue(a.hasProperty(propName));
        assertEquals(anyValue, a.getProperty(propName)[0]);
    }
}
Also used : ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) Value(javax.jcr.Value) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Example 8 with ExternalUser

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

the class DynamicSyncContextTest method testSyncExternalUserDepth0.

@Test
public void testSyncExternalUserDepth0() throws Exception {
    syncConfig.user().setMembershipNestingDepth(0);
    ExternalUser externalUser = idp.getUser(USER_ID);
    sync(externalUser, SyncResult.Status.ADD);
    Tree tree = r.getTree(userManager.getAuthorizable(USER_ID).getPath());
    PropertyState extPrincipalNames = tree.getProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES);
    assertNotNull(extPrincipalNames);
    assertEquals(0, extPrincipalNames.count());
}
Also used : ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) Tree(org.apache.jackrabbit.oak.api.Tree) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Example 9 with ExternalUser

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

the class DynamicSyncContextTest method testSyncExternalUser.

@Test
public void testSyncExternalUser() throws Exception {
    ExternalUser externalUser = idp.getUser(USER_ID);
    sync(externalUser, SyncResult.Status.ADD);
    assertNotNull(userManager.getAuthorizable(USER_ID));
}
Also used : ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Example 10 with ExternalUser

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

the class ExternalGroupPrincipalProviderTest method testFindPrincipalsContainingUnderscore.

@Test
public void testFindPrincipalsContainingUnderscore() throws Exception {
    ExternalUser externalUser = idp.getUser(TestIdentityProvider.ID_WILDCARD_USER);
    sync(externalUser);
    Set<? extends Principal> expected = ImmutableSet.of(new PrincipalImpl("_gr_u_"));
    Set<? extends Principal> res = ImmutableSet.copyOf(principalProvider.findPrincipals("_", PrincipalManager.SEARCH_TYPE_ALL));
    assertEquals(expected, res);
}
Also used : ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) Test(org.junit.Test)

Aggregations

ExternalUser (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser)63 Test (org.junit.Test)56 AbstractExternalAuthTest (org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest)28 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)23 ExternalIdentityRef (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef)19 User (org.apache.jackrabbit.api.security.user.User)12 SimpleCredentials (javax.jcr.SimpleCredentials)10 Group (org.apache.jackrabbit.api.security.user.Group)8 ExternalGroup (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup)8 HashMap (java.util.HashMap)7 ExternalIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity)6 SyncResult (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult)6 PrincipalImpl (org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)6 Tree (org.apache.jackrabbit.oak.api.Tree)5 Principal (java.security.Principal)4 Nonnull (javax.annotation.Nonnull)4 Value (javax.jcr.Value)4 UserManager (org.apache.jackrabbit.api.security.user.UserManager)4 LdapIdentityProvider (org.apache.jackrabbit.oak.security.authentication.ldap.impl.LdapIdentityProvider)4 Collection (java.util.Collection)3