* @return corresponding LDAP authentication provider
*/
private LdapAuthenticationProvider loadLdapAuthenticationProvider() {
if (reloadLdapServerProperties()) {
log.info("LDAP Properties changed - rebuilding Context");
DefaultSpringSecurityContextSource springSecurityContextSource =
new DefaultSpringSecurityContextSource(ldapServerProperties.get().getLdapUrls(), ldapServerProperties.get().getBaseDN());
if (!ldapServerProperties.get().isAnonymousBind()) {
springSecurityContextSource.setUserDn(ldapServerProperties.get().getManagerDn());
springSecurityContextSource.setPassword(ldapServerProperties.get().getManagerPassword());
}
try {
springSecurityContextSource.afterPropertiesSet();
} catch (Exception e) {
log.error("LDAP Context Source not loaded ", e);
throw new UsernameNotFoundException("LDAP Context Source not loaded", e);
}