ProcessLdapProperties { public Map process(Map map) { Map result = new LinkedHashMap(map); if (isDisableSslVerification()) { result.put(LDAP_SSL_SOCKET_FACTORY, SKIP_SSL_VERIFICATION_SOCKET_FACTORY); } else { result.put(LDAP_SSL_SOCKET_FACTORY, EXPIRY_CHECKING_SOCKET_FACTORY); } if (isLdapsUrl()) { result.put(LDAP_SOCKET_FACTORY, result.get(LDAP_SSL_SOCKET_FACTORY)); } return result; } 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 testProcess() throws Exception { Map<String,String> properties = new HashMap<>(); ProcessLdapProperties process = new ProcessLdapProperties("ldap: assertNull(process.process(properties).get(LDAP_SOCKET_FACTORY)); assertEquals(ProcessLdapProperties.EXPIRY_CHECKING_SOCKET_FACTORY, process.process(properties).get(LDAP_SSL_SOCKET_FACTORY)); assertEquals(ProcessLdapProperties.EXPIRY_CHECKING_SOCKET_FACTORY, process.getSSLSocketFactory().getClass().getName()); process.setDisableSslVerification(true); assertNull(process.process(properties).get(LDAP_SOCKET_FACTORY)); process.setBaseUrl("ldaps: assertEquals(ProcessLdapProperties.SKIP_SSL_VERIFICATION_SOCKET_FACTORY, process.process(properties).get(LDAP_SOCKET_FACTORY)); assertEquals(ProcessLdapProperties.SKIP_SSL_VERIFICATION_SOCKET_FACTORY, process.process(properties).get(LDAP_SSL_SOCKET_FACTORY)); assertEquals(ProcessLdapProperties.SKIP_SSL_VERIFICATION_SOCKET_FACTORY, process.getSSLSocketFactory().getClass().getName()); }