@Override public synchronized Response<Void> reopen() throws LdapException { try { if (providerConnection != null) { providerConnection.close(null); } } catch (LdapException e) { logger.warn("Error closing connection with the LDAP", e); } finally { providerConnection = null; } providerConnection = providerConnectionFactory.create(); if (config.getConnectionInitializer() != null) { return config.getConnectionInitializer().initialize(this); } else { return new Response<>(null, null); } }
@Override public synchronized Response<Void> reopen() throws LdapException { try { if (providerConnection != null) { providerConnection.close(null); } } catch (LdapException e) { logger.warn("Error closing connection with the LDAP", e); } finally { providerConnection = null; } providerConnection = providerConnectionFactory.create(); if (config.getConnectionInitializer() != null) { return config.getConnectionInitializer().initialize(this); } else { return new Response<>(null, null); } }
@Override public synchronized Response<Void> reopen() throws LdapException { try { if (providerConnection != null) { providerConnection.close(null); } } catch (LdapException e) { logger.warn("Error closing connection with the LDAP", e); } finally { providerConnection = null; } providerConnection = providerConnectionFactory.create(); if (config.getConnectionInitializer() != null) { return config.getConnectionInitializer().initialize(this); } else { return new Response<>(null, null); } }
/** * This will establish a connection if one does not already exist. This connection should be closed using {@link * #close()}. * * @return response associated with the {@link ConnectionInitializer} or an empty response if no connection * initializer was configured * * @throws IllegalStateException if the connection is already open * @throws LdapException if the LDAP cannot be reached */ @Override public synchronized Response<Void> open() throws LdapException { if (isOpen()) { throw new IllegalStateException("Connection already open"); } providerConnection = providerConnectionFactory.create(); if (config.getConnectionInitializer() != null) { return config.getConnectionInitializer().initialize(this); } else { return new Response<>(null, null); } }
/** * This will establish a connection if one does not already exist. This connection should be closed using {@link * #close()}. * * @return response associated with the {@link ConnectionInitializer} or an empty response if no connection * initializer was configured * * @throws IllegalStateException if the connection is already open * @throws LdapException if the LDAP cannot be reached */ @Override public synchronized Response<Void> open() throws LdapException { if (isOpen()) { throw new IllegalStateException("Connection already open"); } providerConnection = providerConnectionFactory.create(); if (config.getConnectionInitializer() != null) { return config.getConnectionInitializer().initialize(this); } else { return new Response<>(null, null); } }
/** * This will establish a connection if one does not already exist. This connection should be closed using {@link * #close()}. * * @return response associated with the {@link ConnectionInitializer} or an empty response if no connection * initializer was configured * * @throws IllegalStateException if the connection is already open * @throws LdapException if the LDAP cannot be reached */ @Override public synchronized Response<Void> open() throws LdapException { if (isOpen()) { throw new IllegalStateException("Connection already open"); } providerConnection = providerConnectionFactory.create(); if (config.getConnectionInitializer() != null) { return config.getConnectionInitializer().initialize(this); } else { return new Response<>(null, null); } }
/** * Initialize a connection factory with command line options. * * @param line parsed command line arguments * * @return connection factory that has been initialized */ protected ConnectionFactory initConnectionFactory(final CommandLine line) { final DefaultConnectionFactory factory = new DefaultConnectionFactory(); final DefaultConnectionFactoryPropertySource cfSource = new DefaultConnectionFactoryPropertySource( factory, getPropertiesFromOptions(PropertyDomain.LDAP.value(), line)); cfSource.initialize(); final ConnectionInitializer ci = factory.getConnectionConfig().getConnectionInitializer(); if (ci instanceof BindConnectionInitializer) { final BindConnectionInitializer bci = (BindConnectionInitializer) ci; if (bci.getBindDn() != null && bci.getBindCredential() == null) { // prompt the user to enter a password final char[] pass = System.console().readPassword("[Enter password for %s]: ", bci.getBindDn()); bci.setBindCredential(new Credential(pass)); } } return factory; }
/** * Initialize a connection factory with command line options. * * @param line parsed command line arguments * * @return connection factory that has been initialized */ protected ConnectionFactory initConnectionFactory(final CommandLine line) { final DefaultConnectionFactory factory = new DefaultConnectionFactory(); final DefaultConnectionFactoryPropertySource cfSource = new DefaultConnectionFactoryPropertySource( factory, getPropertiesFromOptions(PropertyDomain.LDAP.value(), line)); cfSource.initialize(); final ConnectionInitializer ci = factory.getConnectionConfig().getConnectionInitializer(); if (ci instanceof BindConnectionInitializer) { final BindConnectionInitializer bci = (BindConnectionInitializer) ci; if (bci.getBindDn() != null && bci.getBindCredential() == null) { // prompt the user to enter a password final char[] pass = System.console().readPassword("[Enter password for %s]: ", bci.getBindDn()); bci.setBindCredential(new Credential(pass)); } } return factory; }
/** * Initialize a connection factory with command line options. * * @param line parsed command line arguments * * @return connection factory that has been initialized */ protected ConnectionFactory initConnectionFactory(final CommandLine line) { final DefaultConnectionFactory factory = new DefaultConnectionFactory(); final DefaultConnectionFactoryPropertySource cfSource = new DefaultConnectionFactoryPropertySource( factory, getPropertiesFromOptions(PropertyDomain.LDAP.value(), line)); cfSource.initialize(); final ConnectionInitializer ci = factory.getConnectionConfig().getConnectionInitializer(); if (ci instanceof BindConnectionInitializer) { final BindConnectionInitializer bci = (BindConnectionInitializer) ci; if (bci.getBindDn() != null && bci.getBindCredential() == null) { // prompt the user to enter a password final char[] pass = System.console().readPassword("[Enter password for %s]: ", bci.getBindDn()); bci.setBindCredential(new Credential(pass)); } } return factory; }
/** * 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; }
/** * 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; }
final ConnectionInitializer ci = object.getConnectionInitializer();
final ConnectionInitializer ci = object.getConnectionInitializer();
final ConnectionInitializer ci = object.getConnectionInitializer();