protected LdapNetworkConnection openLdapConnection(LdapSettings ldapSettings) throws LdapException { final LdapConnectionConfig config = new LdapConnectionConfig(); config.setLdapHost(ldapSettings.getUri().getHost()); config.setLdapPort(ldapSettings.getUri().getPort()); config.setUseSsl(ldapSettings.getUri().getScheme().startsWith("ldaps")); config.setUseTls(ldapSettings.isUseStartTls()); if (ldapSettings.isTrustAllCertificates()) { config.setTrustManagers(new TrustAllX509TrustManager()); } config.setName(ldapSettings.getSystemUserName()); config.setCredentials(ldapSettings.getSystemPassword()); return ldapConnector.connect(config); }
config.setLdapHost(ldapUri.getHost()); config.setLdapPort(ldapUri.getPort()); config.setUseSsl(ldapUri.getScheme().startsWith("ldaps"));
final LdapConnectionConfig config = new LdapConnectionConfig(); final URI ldapUri = request.ldapUri(); config.setLdapHost(ldapUri.getHost()); config.setLdapPort(ldapUri.getPort()); config.setUseSsl(ldapUri.getScheme().startsWith("ldaps"));
public LdapConnectionConfig getLdapConnectionConfig() { if (ldapConfiguration == null) { ldapConfiguration = new LdapConnectionConfig(); ldapConfiguration.setLdapHost(ldapConnectionConfig.get("ldapHost")); ldapConfiguration.setLdapPort(Integer.parseInt(ldapConnectionConfig.get("ldapPort"))); ldapConfiguration.setName(ldapConnectionConfig.get("name")); ldapConfiguration.setCredentials(ldapConnectionConfig.get("credentials")); } return ldapConfiguration; }
/** * Create a new instance of a LdapConnection on a given * server, and a give port. We set the SSL flag accordingly * to the last parameter. * * @param server The server we want to be connected to * @param port The port the server is listening to * @param useSsl A flag to tell if it's a SSL connection or not. */ public LdapConnection( String server, int port, boolean useSsl ) { config.setUseSsl( useSsl ); config.setLdapPort( port ); config.setLdapHost( server ); messageId = new AtomicInteger(); }
/** * Create a new instance of a LdapConnection on a given * server, using the default port (389). * * @param server The server we want to be connected to */ public LdapConnection( String server ) { config.setUseSsl( false ); config.setLdapPort( config.getDefaultLdapPort() ); config.setLdapHost( server ); messageId = new AtomicInteger( 0 ); }
/** * Create a new instance of a LdapConnection on localhost, * port 389. */ public LdapConnection() { config.setUseSsl( false ); config.setLdapPort( config.getDefaultLdapPort() ); config.setLdapHost( config.getDefaultLdapHost() ); messageId = new AtomicInteger( 0 ); }
private static LdapConnectionPool createConnectionPool(LDAPConfiguration configuration) throws IOException { final LdapConnectionConfig config = new LdapConnectionConfig(); config.setLdapHost(configuration.getHostname()); config.setLdapPort(configuration.getPort()); config.setName(configuration.getBindDn()); config.setCredentials(configuration.getBindPassword()); final DefaultPoolableLdapConnectionFactory factory = new DefaultPoolableLdapConnectionFactory(config); final LdapConnectionPool pool = new LdapConnectionPool(factory); pool.setTestOnBorrow(configuration.isPoolTestOnBorrow()); pool.setTestOnReturn(configuration.isPoolTestOnReturn()); pool.setTestWhileIdle(configuration.isPoolTestWhileIdle()); pool.setMaxActive(configuration.getPoolMaxActive()); pool.setMaxIdle(configuration.getPoolMaxIdle()); pool.setMinIdle(configuration.getPoolMinIdle()); pool.setMaxWait(configuration.getPoolMaxWait()); switch (configuration.getPoolWhenExhaustedAction()) { case BLOCK: pool.setWhenExhaustedAction(LdapConnectionPool.WHEN_EXHAUSTED_BLOCK); break; case FAIL: pool.setWhenExhaustedAction(LdapConnectionPool.WHEN_EXHAUSTED_FAIL); break; case GROW: pool.setWhenExhaustedAction(LdapConnectionPool.WHEN_EXHAUSTED_GROW); break; default: pool.setWhenExhaustedAction(LdapConnectionPool.DEFAULT_WHEN_EXHAUSTED_ACTION); } return pool; }
/** * Create a new instance of a LdapConnection on a given * server, using the default port (389) if the SSL flag * is off, or 636 otherwise. * * @param server The server we want to be connected to * @param useSsl A flag to tell if it's a SSL connection or not. */ public LdapConnection( String server, boolean useSsl ) { config.setUseSsl( useSsl ); config.setLdapPort( useSsl ? config.getDefaultLdapsPort() : config.getDefaultLdapPort() ); config.setLdapHost( server ); messageId = new AtomicInteger( 0 ); }
/** * Create a new instance of a LdapConnection on localhost, * port 389 if the SSL flag is off, or 636 otherwise. * * @param useSsl A flag to tell if it's a SSL connection or not. */ public LdapConnection( boolean useSsl ) { config.setUseSsl( useSsl ); config.setLdapPort( useSsl ? config.getDefaultLdapsPort() : config.getDefaultLdapPort() ); config.setLdapHost( config.getDefaultLdapHost() ); messageId = new AtomicInteger( 0 ); }
/** * Gets the admin pool. * * @param ldapServer the ldap server * @return the admin pool */ private static LdapConnectionPool getAdminPool( LdapServer ldapServer ) { int port = ldapServer.getPort(); if ( !POOLS.containsKey( port ) ) { LdapConnectionConfig config = new LdapConnectionConfig(); config.setLdapHost( Network.LOOPBACK_HOSTNAME ); config.setLdapPort( port ); config.setName( DEFAULT_ADMIN ); config.setCredentials( DEFAULT_PASSWORD ); DefaultPoolableLdapConnectionFactory factory = new DefaultPoolableLdapConnectionFactory( config ); LdapConnectionPool pool = new LdapConnectionPool( factory ); pool.setTestOnBorrow( true ); POOLS.put( port, pool ); } return POOLS.get( port ); }
protected LdapNetworkConnection openLdapConnection(LdapSettings ldapSettings) throws LdapException { final LdapConnectionConfig config = new LdapConnectionConfig(); config.setLdapHost(ldapSettings.getUri().getHost()); config.setLdapPort(ldapSettings.getUri().getPort()); config.setUseSsl(ldapSettings.getUri().getScheme().startsWith("ldaps")); config.setUseTls(ldapSettings.isUseStartTls()); if (ldapSettings.isTrustAllCertificates()) { config.setTrustManagers(new TrustAllX509TrustManager()); } config.setName(ldapSettings.getSystemUserName()); config.setCredentials(ldapSettings.getSystemPassword()); return ldapConnector.connect(config); }
config.setLdapHost( Network.LOOPBACK_HOSTNAME ); config.setLdapHost( server );
config.setLdapHost( Network.LOOPBACK_HOSTNAME ); config.setLdapHost( server );
config.setLdapHost( Network.LOOPBACK_HOSTNAME ); config.setLdapHost( server );
@Override public void load() { config = new LdapConnectionConfig(); if (host != null) config.setLdapHost(host); if (port != null) config.setLdapPort(port); if (username != null) config.setName(username); if (password != null) config.setCredentials(password); if (usePool != null && usePool) { ValidatingPoolableLdapConnectionFactory factory = new ValidatingPoolableLdapConnectionFactory(config); connectionPool = new LdapConnectionPool(factory); connectionPool.setTestOnBorrow(true); } else connectionPool = null; }
config.setLdapHost(u.getHost()); config.setLdapPort(u.getPort() > 0 ? u.getPort() : 389); if (endpoint.hasProperty("loginDN")) {
/** * Creates a new connection config based on the config. * @return the connection config. */ @NotNull private LdapConnectionConfig createConnectionConfig() { LdapConnectionConfig cc = new LdapConnectionConfig(); cc.setLdapHost(config.getHostname()); cc.setLdapPort(config.getPort()); cc.setUseSsl(config.useSSL()); cc.setUseTls(config.useTLS()); // todo: implement better trustmanager/keystore management (via sling/felix) if (config.noCertCheck()) { cc.setTrustManagers(new NoVerificationTrustManager()); } if (enabledSSLProtocols != null) { cc.setEnabledProtocols(enabledSSLProtocols); } return cc; }
ldapConnectionConfig.setLdapHost(ldapUrl.getLastEntry().getHostname()); ldapConnectionConfig.setLdapPort(ldapUrl.getLastEntry().getPort());
private static LdapConnectionPool createConnectionPool(LDAPConfiguration configuration) throws IOException { final LdapConnectionConfig config = new LdapConnectionConfig(); config.setLdapHost(configuration.getHostname()); config.setLdapPort(configuration.getPort()); config.setName(configuration.getBindDn()); config.setCredentials(configuration.getBindPassword()); final DefaultPoolableLdapConnectionFactory factory = new DefaultPoolableLdapConnectionFactory(config); final LdapConnectionPool pool = new LdapConnectionPool(factory); pool.setTestOnBorrow(configuration.isPoolTestOnBorrow()); pool.setTestOnReturn(configuration.isPoolTestOnReturn()); pool.setTestWhileIdle(configuration.isPoolTestWhileIdle()); pool.setMaxActive(configuration.getPoolMaxActive()); pool.setMaxIdle(configuration.getPoolMaxIdle()); pool.setMinIdle(configuration.getPoolMinIdle()); pool.setMaxWait(configuration.getPoolMaxWait()); switch (configuration.getPoolWhenExhaustedAction()) { case BLOCK: pool.setWhenExhaustedAction(LdapConnectionPool.WHEN_EXHAUSTED_BLOCK); break; case FAIL: pool.setWhenExhaustedAction(LdapConnectionPool.WHEN_EXHAUSTED_FAIL); break; case GROW: pool.setWhenExhaustedAction(LdapConnectionPool.WHEN_EXHAUSTED_GROW); break; default: pool.setWhenExhaustedAction(LdapConnectionPool.DEFAULT_WHEN_EXHAUSTED_ACTION); } return pool; }