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);
}
}
}
Aggregations