@Bean public ConnectionFactory connectionFactory() { return new DefaultConnectionFactory(connectionConfig()); }
/** * Prepare a new LDAP connection. * * @param ldapURL the ldap uRL * @return connection factory */ protected ConnectionFactory prepareConnectionFactory(final String ldapURL) { final ConnectionConfig cc = ConnectionConfig.newConnectionConfig(this.connectionConfig); cc.setLdapUrl(ldapURL); return new DefaultConnectionFactory(cc); }
@Override public ConnectionFactory getConnectionFactory(final ConnectionConfig config, final String ldapUrl) { final ConnectionConfig cc = ConnectionConfig.newConnectionConfig(config); cc.setLdapUrl(ldapUrl); return new DefaultConnectionFactory(cc); } };
/** * Prepare a new LDAP connection. * * @param ldapURL the ldap uRL * @return connection factory */ protected ConnectionFactory prepareConnectionFactory(final String ldapURL) { val cc = ConnectionConfig.newConnectionConfig(this.connectionConfig); cc.setLdapUrl(ldapURL); return new DefaultConnectionFactory(cc); } }
/** * New connection factory connection factory. * * @param l the l * @return the connection factory */ public static DefaultConnectionFactory newConnectionFactory(final AbstractLdapProperties l) { final ConnectionConfig cc = newConnectionConfig(l); final DefaultConnectionFactory bindCf = new DefaultConnectionFactory(cc); if (l.getProviderClass() != null) { try { final Class clazz = ClassUtils.getClass(l.getProviderClass()); bindCf.setProvider(Provider.class.cast(clazz.getDeclaredConstructor().newInstance())); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); } } return bindCf; }
/** * Initializes the supplied connection factory manager using the properties in this property source. * * @param cfm to initialize */ private void initConnectionFactoryManager(final ConnectionFactoryManager cfm) { final DefaultConnectionFactory cf = new DefaultConnectionFactory(); final DefaultConnectionFactoryPropertySource cfPropSource = new DefaultConnectionFactoryPropertySource( cf, propertiesDomain, properties); cfPropSource.initialize(); cfm.setConnectionFactory(cf); }
/** * Initializes the supplied connection factory manager using the properties in this property source. * * @param cfm to initialize */ private void initConnectionFactoryManager(final ConnectionFactoryManager cfm) { final DefaultConnectionFactory cf = new DefaultConnectionFactory(); final DefaultConnectionFactoryPropertySource cfPropSource = new DefaultConnectionFactoryPropertySource( cf, propertiesDomain, properties); cfPropSource.initialize(); cfm.setConnectionFactory(cf); }
/** * Initializes the supplied connection factory manager using the properties in this property source. * * @param cfm to initialize */ private void initConnectionFactoryManager(final ConnectionFactoryManager cfm) { final DefaultConnectionFactory cf = new DefaultConnectionFactory(); final DefaultConnectionFactoryPropertySource cfPropSource = new DefaultConnectionFactoryPropertySource( cf, propertiesDomain, properties); cfPropSource.initialize(); cfm.setConnectionFactory(cf); }
@Override public void initialize() { initializeObject(INVOKER); Schema schema = object.getSchema(); if (schema == null) { final DefaultConnectionFactory cf = new DefaultConnectionFactory(); final DefaultConnectionFactoryPropertySource cfPropSource = new DefaultConnectionFactoryPropertySource( cf, propertiesDomain, properties); cfPropSource.initialize(); try { schema = SchemaFactory.createSchema(cf); } catch (LdapException e) { throw new IllegalArgumentException("Error reading schema from LDAP", e); } object.setSchema(schema); } }
final DefaultConnectionFactory cf = new DefaultConnectionFactory(); final DefaultConnectionFactoryPropertySource source = new DefaultConnectionFactoryPropertySource( cf,
final DefaultConnectionFactory cf = new DefaultConnectionFactory(); final DefaultConnectionFactoryPropertySource source = new DefaultConnectionFactoryPropertySource( cf,
final DefaultConnectionFactory cf = new DefaultConnectionFactory(); final DefaultConnectionFactoryPropertySource source = new DefaultConnectionFactoryPropertySource( cf,
/** * 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; }
/** * Test connection factories. * * @return test data * * @throws Exception on test failure */ @DataProvider(name = "factories") @SuppressWarnings("unchecked") public Object[][] connectionFactories() throws Exception { //Make sure native libraries are loaded and supported for the current unix based operating system. AssertJUnit.assertTrue(AFUNIXSocket.isSupported()); final Map<String, Object> props = new HashMap<>(); props.put(JndiProvider.SOCKET_FACTORY, "org.ldaptive.ldapi.AFUnixSocketFactory"); final DefaultConnectionFactory nativeFactory = new DefaultConnectionFactory( new ConnectionConfig("ldap://domainsocket")); nativeFactory.getProvider().getProviderConfig().setProperties(props); final DefaultConnectionFactory localFactory = new DefaultConnectionFactory(new ConnectionConfig(ldapHost)); final SearchRequest request = new SearchRequest(ldapBaseDn, ldapSearchFilter); return new Object[][] { new Object[] {nativeFactory, request, }, new Object[] {localFactory, request, }, }; }
@Override public void initialize() { initializeObject(INVOKER); DefaultConnectionFactory cf = object.getConnectionFactory(); if (cf == null) { cf = new DefaultConnectionFactory(); final DefaultConnectionFactoryPropertySource cfPropSource = new DefaultConnectionFactoryPropertySource( cf, propertiesDomain, properties); cfPropSource.initialize(); object.setConnectionFactory(cf); } PoolConfig pc = object.getPoolConfig(); if (pc == null) { pc = new PoolConfig(); final PoolConfigPropertySource pcPropSource = new PoolConfigPropertySource(pc, propertiesDomain, properties); pcPropSource.initialize(); object.setPoolConfig(pc); } else { final SimplePropertySource<PoolConfig> sPropSource = new SimplePropertySource<>(pc, propertiesDomain, properties); sPropSource.initialize(); } }
@Override public void initialize() { initializeObject(INVOKER); DefaultConnectionFactory cf = object.getConnectionFactory(); if (cf == null) { cf = new DefaultConnectionFactory(); final DefaultConnectionFactoryPropertySource cfPropSource = new DefaultConnectionFactoryPropertySource( cf, propertiesDomain, properties); cfPropSource.initialize(); object.setConnectionFactory(cf); } PoolConfig pc = object.getPoolConfig(); if (pc == null) { pc = new PoolConfig(); final PoolConfigPropertySource pcPropSource = new PoolConfigPropertySource(pc, propertiesDomain, properties); pcPropSource.initialize(); object.setPoolConfig(pc); } else { final SimplePropertySource<PoolConfig> sPropSource = new SimplePropertySource<>(pc, propertiesDomain, properties); sPropSource.initialize(); } }
@Override public void initialize() { initializeObject(INVOKER); DefaultConnectionFactory cf = object.getConnectionFactory(); if (cf == null) { cf = new DefaultConnectionFactory(); final DefaultConnectionFactoryPropertySource cfPropSource = new DefaultConnectionFactoryPropertySource( cf, propertiesDomain, properties); cfPropSource.initialize(); object.setConnectionFactory(cf); } PoolConfig pc = object.getPoolConfig(); if (pc == null) { pc = new PoolConfig(); final PoolConfigPropertySource pcPropSource = new PoolConfigPropertySource(pc, propertiesDomain, properties); pcPropSource.initialize(); object.setPoolConfig(pc); } else { final SimplePropertySource<PoolConfig> sPropSource = new SimplePropertySource<>(pc, propertiesDomain, properties); sPropSource.initialize(); } }
connectionConfig.setLdapUrl("ldap://localhost:" + LdapServer.PORT); connectionFactory = new DefaultConnectionFactory(); ((DefaultConnectionFactory) connectionFactory).setConnectionConfig(connectionConfig);