ProcessLdapProperties { public DirContextAuthenticationStrategy getAuthenticationStrategy() throws ClassNotFoundException, NoSuchAlgorithmException, IllegalAccessException, InstantiationException, KeyManagementException { if (!hasText(tlsConfig)) { tlsConfig = LDAP_TLS_NONE; } AbstractTlsDirContextAuthenticationStrategy tlsStrategy; switch (tlsConfig) { case LDAP_TLS_NONE: return new SimpleDirContextAuthenticationStrategy(); case LDAP_TLS_SIMPLE: tlsStrategy = new DefaultTlsDirContextAuthenticationStrategy(); break; case LDAP_TLS_EXTERNAL: tlsStrategy = new ExternalTlsDirContextAuthenticationStrategy(); break; default: throw new IllegalArgumentException(tlsConfig); } tlsStrategy.setHostnameVerifier(new AllowAllHostnameVerifier()); tlsStrategy.setSslSocketFactory(getSSLSocketFactory()); return tlsStrategy; } ProcessLdapProperties(String baseUrl,
                                 boolean disableSslVerification,
                                 String tlsConfig); Map process(Map map); boolean isLdapsUrl(); boolean isDisableSslVerification(); SSLSocketFactory getSSLSocketFactory(); void setDisableSslVerification(boolean disableSslVerification); void setBaseUrl(String baseUrl); DirContextAuthenticationStrategy getAuthenticationStrategy(); static final String LDAP_SOCKET_FACTORY; static final String LDAP_SSL_SOCKET_FACTORY; static final String SKIP_SSL_VERIFICATION_SOCKET_FACTORY; static final String EXPIRY_CHECKING_SOCKET_FACTORY; }
@Test public void test_authentication_strategy() throws Exception { ProcessLdapProperties process = new ProcessLdapProperties("ldap: assertEquals(SimpleDirContextAuthenticationStrategy.class, process.getAuthenticationStrategy().getClass()); process = new ProcessLdapProperties("ldap: assertEquals(SimpleDirContextAuthenticationStrategy.class, process.getAuthenticationStrategy().getClass()); process = new ProcessLdapProperties("ldap: assertEquals(DefaultTlsDirContextAuthenticationStrategy.class, process.getAuthenticationStrategy().getClass()); process = new ProcessLdapProperties("ldap: assertEquals(ExternalTlsDirContextAuthenticationStrategy.class, process.getAuthenticationStrategy().getClass()); }
@Test(expected = IllegalArgumentException.class) public void invalid_authentication_strategy() throws Exception { ProcessLdapProperties process = new ProcessLdapProperties("ldap: process.getAuthenticationStrategy(); }