org.apache.http.conn.ssl.SSLSocketFactory.connectSocket()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(252)

本文整理了Java中org.apache.http.conn.ssl.SSLSocketFactory.connectSocket()方法的一些代码示例,展示了SSLSocketFactory.connectSocket()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SSLSocketFactory.connectSocket()方法的具体详情如下:
包路径:org.apache.http.conn.ssl.SSLSocketFactory
类名称:SSLSocketFactory
方法名:connectSocket

SSLSocketFactory.connectSocket介绍

暂无

代码示例

代码示例来源:origin: k9mail/k-9

public Socket connectSocket(Socket sock, String host, int port,
    InetAddress localAddress, int localPort, HttpParams params)
    throws IOException {
  return mSchemeSocketFactory.connectSocket(sock, host, port, localAddress, localPort, params);
}

代码示例来源:origin: org.keycloak/keycloak-adapter-core

@Override
public Socket connectSocket(int connectTimeout, Socket socket, HttpHost host, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpContext context) throws IOException {
  return super.connectSocket(connectTimeout, applySNI(socket, host.getHostName()), host, remoteAddress, localAddress, context);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.ecf.provider.filetransfer.httpclient4

@Override
  public Socket connectSocket(int connectTimeout, Socket socket, HttpHost host, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpContext context) throws IOException, ConnectTimeoutException {
    // This is to work around HttpClient bug as described
    // in description and comments here:  
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=478655
    if (socket instanceof SSLSocket) {
      try {
        final Method mSetHost = socket.getClass().getMethod("setHost", String.class);
        mSetHost.setAccessible(true);
        mSetHost.invoke(socket, host.getHostName());
      } catch (NoSuchMethodException ex) {
      } catch (IllegalAccessException ex) {
      } catch (InvocationTargetException ex) {
      }
    }
    return super.connectSocket(connectTimeout, socket, host, remoteAddress, localAddress, context);
  }
};

代码示例来源:origin: org.keycloak/keycloak-saml-adapter-core

@Override
public Socket connectSocket(int connectTimeout, Socket socket, HttpHost host, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpContext context) throws IOException {
  return super.connectSocket(connectTimeout, applySNI(socket, host.getHostName()), host, remoteAddress, localAddress, context);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient

public Socket connectSocket(
    final Socket socket,
    final String host, final int port,
    final InetAddress local, final int localPort,
    final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
  final InetAddress remote;
  if (this.nameResolver != null) {
    remote = this.nameResolver.resolve(host);
  } else {
    remote = InetAddress.getByName(host);
  }
  InetSocketAddress localAddress = null;
  if (local != null || localPort > 0) {
    localAddress = new InetSocketAddress(local, localPort > 0 ? localPort : 0);
  }
  final InetSocketAddress remoteAddress = new HttpInetSocketAddress(
      new HttpHost(host, port), remote, port);
  return connectSocket(socket, remoteAddress, localAddress, params);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

@Override
public Socket connectSocket(
    final Socket socket,
    final String host, final int port,
    final InetAddress local, final int localPort,
    final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
  final InetAddress remote;
  if (this.nameResolver != null) {
    remote = this.nameResolver.resolve(host);
  } else {
    remote = InetAddress.getByName(host);
  }
  InetSocketAddress localAddress = null;
  if (local != null || localPort > 0) {
    localAddress = new InetSocketAddress(local, localPort > 0 ? localPort : 0);
  }
  final InetSocketAddress remoteAddress = new HttpInetSocketAddress(
      new HttpHost(host, port), remote, port);
  return connectSocket(socket, remoteAddress, localAddress, params);
}

代码示例来源:origin: Nextdoor/bender

@Override
public Socket connectSocket(
    final Socket socket,
    final String host, final int port,
    final InetAddress local, final int localPort,
    final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
  final InetAddress remote;
  if (this.nameResolver != null) {
    remote = this.nameResolver.resolve(host);
  } else {
    remote = InetAddress.getByName(host);
  }
  InetSocketAddress localAddress = null;
  if (local != null || localPort > 0) {
    localAddress = new InetSocketAddress(local, localPort > 0 ? localPort : 0);
  }
  final InetSocketAddress remoteAddress = new HttpInetSocketAddress(
      new HttpHost(host, port), remote, port);
  return connectSocket(socket, remoteAddress, localAddress, params);
}

代码示例来源:origin: com.hynnet/httpclient

public Socket connectSocket(
    final Socket socket,
    final String host, final int port,
    final InetAddress local, final int localPort,
    final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
  final InetAddress remote;
  if (this.nameResolver != null) {
    remote = this.nameResolver.resolve(host);
  } else {
    remote = InetAddress.getByName(host);
  }
  InetSocketAddress localAddress = null;
  if (local != null || localPort > 0) {
    localAddress = new InetSocketAddress(local, localPort > 0 ? localPort : 0);
  }
  final InetSocketAddress remoteAddress = new HttpInetSocketAddress(
      new HttpHost(host, port), remote, port);
  return connectSocket(socket, remoteAddress, localAddress, params);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient

/**
 * @since 4.1
 */
public Socket connectSocket(
    final Socket socket,
    final InetSocketAddress remoteAddress,
    final InetSocketAddress localAddress,
    final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
  Args.notNull(remoteAddress, "Remote address");
  Args.notNull(params, "HTTP parameters");
  final HttpHost host;
  if (remoteAddress instanceof HttpInetSocketAddress) {
    host = ((HttpInetSocketAddress) remoteAddress).getHttpHost();
  } else {
    host = new HttpHost(remoteAddress.getHostName(), remoteAddress.getPort(), "https");
  }
  final int socketTimeout = HttpConnectionParams.getSoTimeout(params);
  final int connectTimeout = HttpConnectionParams.getConnectionTimeout(params);
  socket.setSoTimeout(socketTimeout);
  return connectSocket(connectTimeout, socket, host, remoteAddress, localAddress, null);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * @since 4.1
 */
@Override
public Socket connectSocket(
    final Socket socket,
    final InetSocketAddress remoteAddress,
    final InetSocketAddress localAddress,
    final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
  Args.notNull(remoteAddress, "Remote address");
  Args.notNull(params, "HTTP parameters");
  final HttpHost host;
  if (remoteAddress instanceof HttpInetSocketAddress) {
    host = ((HttpInetSocketAddress) remoteAddress).getHttpHost();
  } else {
    host = new HttpHost(remoteAddress.getHostName(), remoteAddress.getPort(), "https");
  }
  final int socketTimeout = HttpConnectionParams.getSoTimeout(params);
  final int connectTimeout = HttpConnectionParams.getConnectionTimeout(params);
  socket.setSoTimeout(socketTimeout);
  return connectSocket(connectTimeout, socket, host, remoteAddress, localAddress, null);
}

代码示例来源:origin: Nextdoor/bender

/**
 * @since 4.1
 */
@Override
public Socket connectSocket(
    final Socket socket,
    final InetSocketAddress remoteAddress,
    final InetSocketAddress localAddress,
    final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
  Args.notNull(remoteAddress, "Remote address");
  Args.notNull(params, "HTTP parameters");
  final HttpHost host;
  if (remoteAddress instanceof HttpInetSocketAddress) {
    host = ((HttpInetSocketAddress) remoteAddress).getHttpHost();
  } else {
    host = new HttpHost(remoteAddress.getHostName(), remoteAddress.getPort(), "https");
  }
  final int socketTimeout = HttpConnectionParams.getSoTimeout(params);
  final int connectTimeout = HttpConnectionParams.getConnectionTimeout(params);
  socket.setSoTimeout(socketTimeout);
  return connectSocket(connectTimeout, socket, host, remoteAddress, localAddress, null);
}

代码示例来源:origin: com.hynnet/httpclient

/**
 * @since 4.1
 */
public Socket connectSocket(
    final Socket socket,
    final InetSocketAddress remoteAddress,
    final InetSocketAddress localAddress,
    final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
  Args.notNull(remoteAddress, "Remote address");
  Args.notNull(params, "HTTP parameters");
  final HttpHost host;
  if (remoteAddress instanceof HttpInetSocketAddress) {
    host = ((HttpInetSocketAddress) remoteAddress).getHttpHost();
  } else {
    host = new HttpHost(remoteAddress.getHostName(), remoteAddress.getPort(), "https");
  }
  final int socketTimeout = HttpConnectionParams.getSoTimeout(params);
  final int connectTimeout = HttpConnectionParams.getConnectionTimeout(params);
  socket.setSoTimeout(socketTimeout);
  return connectSocket(connectTimeout, socket, host, remoteAddress, localAddress, null);
}

相关文章