use of org.ldaptive.auth.PooledSearchDnResolver in project cas by apereo.
the class Beans method getAuthenticatedOrAnonSearchAuthenticator.
private static Authenticator getAuthenticatedOrAnonSearchAuthenticator(final AbstractLdapAuthenticationProperties l) {
if (StringUtils.isBlank(l.getBaseDn())) {
throw new IllegalArgumentException("Base dn cannot be empty/blank for authenticated/anonymous authentication");
}
if (StringUtils.isBlank(l.getUserFilter())) {
throw new IllegalArgumentException("User filter cannot be empty/blank for authenticated/anonymous authentication");
}
final PooledConnectionFactory connectionFactoryForSearch = Beans.newLdaptivePooledConnectionFactory(l);
final PooledSearchDnResolver resolver = new PooledSearchDnResolver();
resolver.setBaseDn(l.getBaseDn());
resolver.setSubtreeSearch(l.isSubtreeSearch());
resolver.setAllowMultipleDns(l.isAllowMultipleDns());
resolver.setConnectionFactory(connectionFactoryForSearch);
resolver.setUserFilter(l.getUserFilter());
final Authenticator auth;
if (StringUtils.isBlank(l.getPrincipalAttributePassword())) {
auth = new Authenticator(resolver, getPooledBindAuthenticationHandler(l, Beans.newLdaptivePooledConnectionFactory(l)));
} else {
auth = new Authenticator(resolver, getPooledCompareAuthenticationHandler(l, Beans.newLdaptivePooledConnectionFactory(l)));
}
if (l.isEnhanceWithEntryResolver()) {
auth.setEntryResolver(Beans.newLdaptiveSearchEntryResolver(l, Beans.newLdaptivePooledConnectionFactory(l)));
}
return auth;
}
use of org.ldaptive.auth.PooledSearchDnResolver in project cas by apereo.
the class Beans method getSaslAuthenticator.
private static Authenticator getSaslAuthenticator(final AbstractLdapAuthenticationProperties l) {
if (StringUtils.isBlank(l.getUserFilter())) {
throw new IllegalArgumentException("User filter cannot be empty/blank for sasl authentication");
}
final PooledConnectionFactory connectionFactoryForSearch = Beans.newLdaptivePooledConnectionFactory(l);
final PooledSearchDnResolver resolver = new PooledSearchDnResolver();
resolver.setBaseDn(l.getBaseDn());
resolver.setSubtreeSearch(l.isSubtreeSearch());
resolver.setAllowMultipleDns(l.isAllowMultipleDns());
resolver.setConnectionFactory(connectionFactoryForSearch);
resolver.setUserFilter(l.getUserFilter());
return new Authenticator(resolver, getPooledBindAuthenticationHandler(l, Beans.newLdaptivePooledConnectionFactory(l)));
}
Aggregations