Search in sources :

Example 21 with ExternalUser

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

the class LdapProviderTest method testAuthenticateValidateTrueTrue.

@Test
public void testAuthenticateValidateTrueTrue() throws Exception {
    providerConfig.getAdminPoolConfig().setMaxActive(2).setLookupOnValidate(true);
    providerConfig.getUserPoolConfig().setMaxActive(2).setLookupOnValidate(true);
    idp.close();
    idp = new LdapIdentityProvider(providerConfig);
    SimpleCredentials creds = new SimpleCredentials(TEST_USER1_UID, "pass".toCharArray());
    for (int i = 0; i < 8; i++) {
        ExternalUser user = idp.authenticate(creds);
        assertNotNull("User 1 must authenticate (i=" + i + ")", user);
        assertEquals("User Ref", TEST_USER1_DN, user.getExternalId().getId());
    }
}
Also used : LdapIdentityProvider(org.apache.jackrabbit.oak.security.authentication.ldap.impl.LdapIdentityProvider) SimpleCredentials(javax.jcr.SimpleCredentials) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) Test(org.junit.Test)

Example 22 with ExternalUser

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

the class LdapProviderTest method testGetGroups2.

@Test
public void testGetGroups2() throws Exception {
    ExternalIdentityRef ref = new ExternalIdentityRef(TEST_USER0_DN, IDP_NAME);
    ExternalIdentity id = idp.getIdentity(ref);
    assertTrue("User instance", id instanceof ExternalUser);
    assertIfEquals("Groups", TEST_USER0_GROUPS, id.getDeclaredGroups());
}
Also used : ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) Test(org.junit.Test)

Example 23 with ExternalUser

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

the class LdapProviderTest method testSplitDNIntermediatePath2.

@Test
public void testSplitDNIntermediatePath2() throws Exception {
    providerConfig.getUserConfig().setMakeDnPath(true);
    ExternalUser user = idp.getUser(TEST_USER5_UID);
    assertNotNull("User 5 must exist", user);
    assertEquals("Intermediate path must be the split dn", TEST_USER5_PATH, user.getIntermediatePath());
}
Also used : ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) Test(org.junit.Test)

Example 24 with ExternalUser

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

the class LdapProviderTest method testAuthenticateValidateFalseFalse.

@Test
public void testAuthenticateValidateFalseFalse() throws Exception {
    providerConfig.getAdminPoolConfig().setMaxActive(2).setLookupOnValidate(false);
    providerConfig.getUserPoolConfig().setMaxActive(2).setLookupOnValidate(false);
    idp.close();
    idp = new LdapIdentityProvider(providerConfig);
    SimpleCredentials creds = new SimpleCredentials(TEST_USER1_UID, "pass".toCharArray());
    for (int i = 0; i < 8; i++) {
        ExternalUser user = idp.authenticate(creds);
        assertNotNull("User 1 must authenticate", user);
        assertEquals("User Ref", TEST_USER1_DN, user.getExternalId().getId());
    }
}
Also used : LdapIdentityProvider(org.apache.jackrabbit.oak.security.authentication.ldap.impl.LdapIdentityProvider) SimpleCredentials(javax.jcr.SimpleCredentials) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) Test(org.junit.Test)

Example 25 with ExternalUser

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

the class LdapProviderTest method testListUsersWithMissingUid.

/**
     * Test case to reproduce OAK-3396 where an ldap user entry
     * without a uid caused a NullpointerException in LdapIdentityProvider.createUser
     */
@Test
public void testListUsersWithMissingUid() throws Exception {
    // the ERRONEOUS_LDIF contains an entry without uid
    InputStream erroneousDIF = LdapProviderTest.class.getResourceAsStream(ERRONEOUS_LDIF);
    LDAP_SERVER.loadLdif(erroneousDIF);
    Iterator<ExternalUser> users = idp.listUsers();
    // without the LdapInvalidAttributeValueException a NPE would result here:
    while (users.hasNext()) {
        ExternalUser user = users.next();
        // the 'Faulty Entry' of the ERRONEOUS_LDIF should be filtered out
        // (by LdapIdentityProvider.listUsers.getNext())
        assertTrue(!user.getPrincipalName().startsWith("cn=Faulty Entry"));
    }
}
Also used : InputStream(java.io.InputStream) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) 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