/** * Add an authentication filter to the web application context if edison.ldap property is set to {@code enabled}'. * All routes starting with the value of the {@code edison.ldap.prefix} property will be secured by LDAP. If no * property is set this will default to all routes starting with '/internal'. * * @param ldapProperties the properties used to configure LDAP * @return FilterRegistrationBean */ @Bean @ConditionalOnMissingBean(LdapConnectionFactory.class) public LdapConnectionFactory ldapConnectionFactory(final LdapProperties ldapProperties) { if (ldapProperties.getEncryptionType() == EncryptionType.SSL) { return new SSLLdapConnectionFactory(ldapProperties); } return new StartTlsLdapConnectionFactory(ldapProperties); }
@Test public void shouldTryToBuildLdapConnection() { final LdapProperties properties = mock(LdapProperties.class); when(properties.getHost()).thenReturn("foo"); when(properties.getPort()).thenReturn(42); assertThrows(LDAPException.class, () -> { new SSLLdapConnectionFactory(properties).buildLdapConnection(); }); } }