/**
   * Return a new LDAPConnection with the appropriate socket factory set for the connection type.
   */
  private LDAPConnection createConnectionWithSocketFactory() {
    LDAPSocketFactory factory;

    if (config.isSecureConnection()) {
      factory = config.getSecureSocketFactory();

      if (factory == null) {
        throw new RuntimeException(
            "You must set a 'secureSocketFactory' (in jldap-beans.xml) when using LDAPS");
      }
    } else {
      factory = config.getSocketFactory();
    }

    if (factory == null) {
      return new LDAPConnection();
    } else {
      return new LDAPConnection(factory);
    }
  }
 protected boolean isTlsSocketFactory() {
   return config.getSecureSocketFactory() instanceof LDAPTLSSocketFactory;
 }