All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ldaptive.provider.jldap.JLdapSSLConnectionFactory Maven / Gradle / Ivy

/* See LICENSE for licensing and NOTICE for copyright. */
package org.ldaptive.provider.jldap;

import java.time.Duration;
import javax.net.ssl.SSLSocketFactory;
import com.novell.ldap.LDAPConnection;
import com.novell.ldap.LDAPConstraints;
import com.novell.ldap.LDAPException;
import com.novell.ldap.LDAPJSSESecureSocketFactory;
import org.ldaptive.ConnectionStrategy;

/**
 * Creates LDAPS connections using the JLDAP LDAPConnection class.
 *
 * @author  Middleware Services
 */
public class JLdapSSLConnectionFactory extends AbstractJLdapConnectionFactory
{

  /** SSL socket factory to use for SSL. */
  private final SSLSocketFactory sslSocketFactory;


  /**
   * Creates a new jldap ssl connection factory.
   *
   * @param  url  of the ldap to connect to
   * @param  strategy  connection strategy
   * @param  config  provider configuration
   * @param  constraints  connection constraints
   * @param  timeOut  time in milliseconds that operations will wait
   * @param  factory  SSL socket factory
   */
  public JLdapSSLConnectionFactory(
    final String url,
    final ConnectionStrategy strategy,
    final JLdapProviderConfig config,
    final LDAPConstraints constraints,
    final Duration timeOut,
    final SSLSocketFactory factory)
  {
    super(url, strategy, config, constraints, timeOut);
    sslSocketFactory = factory;
  }


  @Override
  protected LDAPConnection createLDAPConnection()
    throws LDAPException
  {
    final LDAPConnection conn;
    if (sslSocketFactory != null) {
      conn = new LDAPConnection(new LDAPJSSESecureSocketFactory(sslSocketFactory));
    } else {
      conn = new LDAPConnection(new LDAPJSSESecureSocketFactory());
    }
    return conn;
  }


  @Override
  protected JLdapSSLConnection createJLdapConnection(final LDAPConnection conn, final JLdapProviderConfig config)
  {
    return new JLdapSSLConnection(conn, config);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy