Search in sources :

Example 1 with PooledConnectionFactoryManager

use of org.ldaptive.pool.PooledConnectionFactoryManager in project pac4j by pac4j.

the class LdapAuthenticatorBuilder method tryBuildLdapAuthenticator.

public void tryBuildLdapAuthenticator(final Map<String, Authenticator> authenticators) {
    for (int i = 0; i <= MAX_NUM_AUTHENTICATORS; i++) {
        final String type = getProperty(LDAP_TYPE, i);
        if (isNotBlank(type)) {
            final LdapAuthenticationProperties ldapProp = buildLdapProperties(i);
            final org.ldaptive.auth.Authenticator ldaptiveAuthenticator = LdaptiveAuthenticatorBuilder.getAuthenticator(ldapProp);
            final LdapProfileService authenticator = new LdapProfileService(ldaptiveAuthenticator, getProperty(LDAP_ATTRIBUTES, i));
            final PooledConnectionFactoryManager pooledConnectionFactoryManager = (PooledConnectionFactoryManager) ldaptiveAuthenticator.getAuthenticationHandler();
            authenticator.setConnectionFactory(pooledConnectionFactoryManager.getConnectionFactory());
            authenticator.setUsersDn(getProperty(LDAP_USERS_DN, i));
            if (containsProperty(LDAP_PRINCIPAL_ATTRIBUTE_ID, i)) {
                authenticator.setUsernameAttribute(getProperty(LDAP_PRINCIPAL_ATTRIBUTE_ID, i));
            }
            if (containsProperty(LDAP_PRINCIPAL_ATTRIBUTE_PASSWORD, i)) {
                authenticator.setPasswordAttribute(getProperty(LDAP_PRINCIPAL_ATTRIBUTE_PASSWORD, i));
            }
            authenticators.put(concat("ldap", i), authenticator);
        }
    }
}
Also used : PooledConnectionFactoryManager(org.ldaptive.pool.PooledConnectionFactoryManager) LdapAuthenticationProperties(org.pac4j.config.ldaptive.LdapAuthenticationProperties) LdapProfileService(org.pac4j.ldap.profile.service.LdapProfileService)

Aggregations

PooledConnectionFactoryManager (org.ldaptive.pool.PooledConnectionFactoryManager)1 LdapAuthenticationProperties (org.pac4j.config.ldaptive.LdapAuthenticationProperties)1 LdapProfileService (org.pac4j.ldap.profile.service.LdapProfileService)1