/** * Returns a jndi connection factory using the properties found in the supplied connection config. If the supplied env * is null, the environment is retrieved from {@link #getDefaultEnvironment(ConnectionConfig, String)}. * * @param cc connection config * @param env context environment or null to use the default * * @return jndi connection factory */ protected JndiConnectionFactory getJndiConnectionFactory(final ConnectionConfig cc, final Map<String, Object> env) { SSLSocketFactory factory = config.getSslSocketFactory(); if (factory == null && (cc.getUseSSL() || cc.getLdapUrl().toLowerCase().contains("ldaps://"))) { // LDAPS hostname verification does not occur by default // set a default hostname verifier final LdapURL ldapUrl = new LdapURL(cc.getLdapUrl()); factory = ThreadLocalTLSSocketFactory.getHostnameVerifierFactory(cc.getSslConfig(), ldapUrl.getHostnames()); } return new JndiConnectionFactory( cc.getLdapUrl(), config, env != null ? env : getDefaultEnvironment(cc, factory != null ? factory.getClass().getName() : null)); }
env.put(PROTOCOL, "ssl"); if (factory != null && (cc.getUseSSL() || cc.getLdapUrl().toLowerCase().contains("ldaps://"))) { env.put(JndiProvider.SOCKET_FACTORY, factory);
env.put(PROTOCOL, "ssl"); if (factory != null && (cc.getUseSSL() || cc.getLdapUrl().toLowerCase().contains("ldaps://"))) { env.put(JndiProvider.SOCKET_FACTORY, factory);
env.put(PROTOCOL, "ssl"); if (factory != null && (cc.getUseSSL() || cc.getLdapUrl().toLowerCase().contains("ldaps://"))) { env.put(JndiProvider.SOCKET_FACTORY, factory);
if (factory == null && (cc.getUseSSL() || cc.getLdapUrl().toLowerCase().contains("ldaps://"))) { final LdapURL ldapUrl = new LdapURL(cc.getLdapUrl()); factory = ThreadLocalTLSSocketFactory.getHostnameVerifierFactory(cc.getSslConfig(), ldapUrl.getHostnames()); threadLocal = true; return new JndiConnectionFactory( cc.getLdapUrl(), cc.getConnectionStrategy(), config,
if (factory == null && (cc.getUseSSL() || cc.getLdapUrl().toLowerCase().contains("ldaps://"))) { final LdapURL ldapUrl = new LdapURL(cc.getLdapUrl()); factory = ThreadLocalTLSSocketFactory.getHostnameVerifierFactory(cc.getSslConfig(), ldapUrl.getHostnames()); threadLocal = true; return new JndiConnectionFactory( cc.getLdapUrl(), cc.getConnectionStrategy(), config,
@Override public ProviderConnectionFactory<ApacheLdapProviderConfig> getConnectionFactory(final ConnectionConfig cc) { LdapConnectionConfig lcc = config.getLdapConnectionConfig(); if (lcc == null) { lcc = getDefaultLdapConnectionConfig(cc); } return new ApacheLdapConnectionFactory( cc.getLdapUrl(), cc.getConnectionStrategy(), config, lcc, cc.getUseStartTLS(), cc.getResponseTimeout()); }
if (cc.getUseStartTLS() || cc.getUseSSL() || cc.getLdapUrl().toLowerCase().contains("ldaps://")) { final SSLContextInitializer contextInit = getHostnameVerifierSSLContextInitializer(cc); final TrustManager[] trustManagers; lcc.setUseSsl(cc.getUseSSL() || cc.getLdapUrl().toLowerCase().contains("ldaps://")); lcc.setTrustManagers(trustManagers); lcc.setKeyManagers(keyManagers);
cc.getLdapUrl(), config, env != null ? env : getDefaultEnvironment(cc, null),
if (connConfig.getUseStartTLS() || connConfig.getUseSSL() || connConfig.getLdapUrl().toLowerCase().contains("ldaps://")) { final SslConfig sslConfig = connConfig.getSslConfig(); if (sslConfig != null) {
/** * Returns a connection config initialized with the supplied config. * * @param config connection config to read properties from * * @return connection config */ public static ConnectionConfig newConnectionConfig(final ConnectionConfig config) { final ConnectionConfig cc = new ConnectionConfig(); cc.setLdapUrl(config.getLdapUrl()); cc.setConnectTimeout(config.getConnectTimeout()); cc.setResponseTimeout(config.getResponseTimeout()); cc.setSslConfig(config.getSslConfig()); cc.setUseSSL(config.getUseSSL()); cc.setUseStartTLS(config.getUseStartTLS()); cc.setConnectionInitializer(config.getConnectionInitializer()); return cc; }
/** * Returns a connection config initialized with the supplied config. * * @param config connection config to read properties from * * @return connection config */ public static ConnectionConfig newConnectionConfig(final ConnectionConfig config) { final ConnectionConfig cc = new ConnectionConfig(); cc.setLdapUrl(config.getLdapUrl()); cc.setConnectTimeout(config.getConnectTimeout()); cc.setResponseTimeout(config.getResponseTimeout()); cc.setSslConfig(config.getSslConfig()); cc.setUseSSL(config.getUseSSL()); cc.setUseStartTLS(config.getUseStartTLS()); cc.setConnectionInitializer(config.getConnectionInitializer()); cc.setConnectionStrategy(config.getConnectionStrategy()); return cc; }
try { handler.info("ldap", "Obtaining a LDAP Connection for '" + this.pool.getConnectionFactory().getConnectionConfig().getLdapUrl() + "'"); connection = this.pooledConnectionFactory.getConnection();
/** * Returns a connection config initialized with the supplied config. * * @param config connection config to read properties from * * @return connection config */ public static ConnectionConfig newConnectionConfig(final ConnectionConfig config) { final ConnectionConfig cc = new ConnectionConfig(); cc.setLdapUrl(config.getLdapUrl()); cc.setConnectTimeout(config.getConnectTimeout()); cc.setResponseTimeout(config.getResponseTimeout()); cc.setSslConfig(config.getSslConfig()); cc.setUseSSL(config.getUseSSL()); cc.setUseStartTLS(config.getUseStartTLS()); cc.setConnectionInitializer(config.getConnectionInitializer()); cc.setConnectionStrategy(config.getConnectionStrategy()); return cc; }
cc.getLdapUrl(), cc.getConnectionStrategy(), config,
cc.getLdapUrl(), cc.getConnectionStrategy(), config,
final LdapURL ldapUrl = new LdapURL(cc.getLdapUrl()); final SSLContextInitializer contextInit; if (cc.getSslConfig() != null && !cc.getSslConfig().isEmpty()) {