Search in sources :

Example 31 with SimpleCredentials

use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.

the class LdapProviderTest method testAuthenticateValidateTrueFalse.

@Test
public void testAuthenticateValidateTrueFalse() throws Exception {
    providerConfig.getAdminPoolConfig().setMaxActive(2).setLookupOnValidate(true);
    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 (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 32 with SimpleCredentials

use of javax.jcr.SimpleCredentials 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 33 with SimpleCredentials

use of javax.jcr.SimpleCredentials 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 34 with SimpleCredentials

use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.

the class LdapProviderTest method testAuthenticateMissing.

@Test
public void testAuthenticateMissing() throws Exception {
    SimpleCredentials creds = new SimpleCredentials("foobar" + TEST_USER1_UID, "pass".toCharArray());
    ExternalUser user = idp.authenticate(creds);
    assertNull("Authenticate must return NULL for unknown user", user);
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) Test(org.junit.Test)

Example 35 with SimpleCredentials

use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.

the class LdapLoginTestBase method testSyncCreateUser.

@Test
public void testSyncCreateUser() throws Exception {
    ContentSession cs = null;
    try {
        cs = login(new SimpleCredentials(USER_ID, USER_PWD.toCharArray()));
        root.refresh();
        Authorizable user = userManager.getAuthorizable(USER_ID);
        assertNotNull(user);
        assertTrue(user.hasProperty(USER_PROP));
        Tree userTree = cs.getLatestRoot().getTree(user.getPath());
        assertFalse(userTree.hasProperty(UserConstants.REP_PASSWORD));
        assertNull(userManager.getAuthorizable(GROUP_DN));
    } finally {
        if (cs != null) {
            cs.close();
        }
        options.clear();
    }
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) ContentSession(org.apache.jackrabbit.oak.api.ContentSession) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) Tree(org.apache.jackrabbit.oak.api.Tree) Test(org.junit.Test)

Aggregations

SimpleCredentials (javax.jcr.SimpleCredentials)289 Test (org.junit.Test)142 Session (javax.jcr.Session)83 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)60 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)53 User (org.apache.jackrabbit.api.security.user.User)41 Credentials (javax.jcr.Credentials)39 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)35 UserManager (org.apache.jackrabbit.api.security.user.UserManager)34 LoginException (javax.security.auth.login.LoginException)30 Node (javax.jcr.Node)28 RepositoryException (javax.jcr.RepositoryException)25 Principal (java.security.Principal)22 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)21 GuestCredentials (javax.jcr.GuestCredentials)20 LoginException (javax.jcr.LoginException)19 TokenCredentials (org.apache.jackrabbit.api.security.authentication.token.TokenCredentials)19 AuthInfo (org.apache.jackrabbit.oak.api.AuthInfo)18 Before (org.junit.Before)18 ImpersonationCredentials (org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials)17