org.apache.http.conn.scheme.Scheme.getSchemeSocketFactory()方法的使用及代码示例

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

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

Scheme.getSchemeSocketFactory介绍

[英]Obtains the socket factory. If this scheme is #isLayered, the factory implements LayeredSocketFactory.
[中]获得插座工厂。如果此方案为#IsLayed,工厂将实现LayeredSocketFactory。

代码示例

代码示例来源:origin: com.netflix.ribbon/ribbon-httpclient

public KeyStore getKeyStore(){
  SchemeRegistry registry = httpClient4.getConnectionManager().getSchemeRegistry();
  if(! registry.getSchemeNames().contains("https")){
    throw new IllegalStateException("Registry does not include an 'https' entry.");
  }
  SchemeSocketFactory awareSocketFactory = httpClient4.getConnectionManager().getSchemeRegistry().getScheme("https").getSchemeSocketFactory();
  if(awareSocketFactory instanceof KeyStoreAwareSocketFactory){
    return ((KeyStoreAwareSocketFactory) awareSocketFactory).getKeyStore();
  }else{
    throw new IllegalStateException("Cannot extract keystore from scheme socket factory of type: " + awareSocketFactory.getClass().getName());
  }
}

代码示例来源:origin: com.hynnet/solr-solrj

public static void setHostNameVerifier(DefaultHttpClient httpClient,
  X509HostnameVerifier hostNameVerifier) {
 Scheme httpsScheme = httpClient.getConnectionManager().getSchemeRegistry().get("https");
 if (httpsScheme != null) {
  SSLSocketFactory sslSocketFactory = (SSLSocketFactory) httpsScheme.getSchemeSocketFactory();
  sslSocketFactory.setHostnameVerifier(hostNameVerifier);
 }
}

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

@Override
public void updateSecureConnection(
    final OperatedClientConnection conn,
    final HttpHost target,
    final HttpContext context,
    final HttpParams params) throws IOException {
  Args.notNull(conn, "Connection");
  Args.notNull(target, "Target host");
  Args.notNull(params, "Parameters");
  Asserts.check(conn.isOpen(), "Connection must be open");
  final SchemeRegistry registry = getSchemeRegistry(context);
  final Scheme schm = registry.getScheme(target.getSchemeName());
  Asserts.check(schm.getSchemeSocketFactory() instanceof SchemeLayeredSocketFactory,
    "Socket factory must implement SchemeLayeredSocketFactory");
  final SchemeLayeredSocketFactory lsf = (SchemeLayeredSocketFactory) schm.getSchemeSocketFactory();
  final Socket sock = lsf.createLayeredSocket(
      conn.getSocket(), target.getHostName(), schm.resolvePort(target.getPort()), params);
  prepareSocket(sock, context, params);
  conn.update(sock, target, lsf.isSecure(sock), params);
}

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

public void updateSecureConnection(
    final OperatedClientConnection conn,
    final HttpHost target,
    final HttpContext context,
    final HttpParams params) throws IOException {
  Args.notNull(conn, "Connection");
  Args.notNull(target, "Target host");
  Args.notNull(params, "Parameters");
  Asserts.check(conn.isOpen(), "Connection must be open");
  final SchemeRegistry registry = getSchemeRegistry(context);
  final Scheme schm = registry.getScheme(target.getSchemeName());
  Asserts.check(schm.getSchemeSocketFactory() instanceof SchemeLayeredSocketFactory,
    "Socket factory must implement SchemeLayeredSocketFactory");
  final SchemeLayeredSocketFactory lsf = (SchemeLayeredSocketFactory) schm.getSchemeSocketFactory();
  final Socket sock = lsf.createLayeredSocket(
      conn.getSocket(), target.getHostName(), schm.resolvePort(target.getPort()), params);
  prepareSocket(sock, context, params);
  conn.update(sock, target, lsf.isSecure(sock), params);
}

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

public void updateSecureConnection(
    final OperatedClientConnection conn,
    final HttpHost target,
    final HttpContext context,
    final HttpParams params) throws IOException {
  Args.notNull(conn, "Connection");
  Args.notNull(target, "Target host");
  Args.notNull(params, "Parameters");
  Asserts.check(conn.isOpen(), "Connection must be open");
  final SchemeRegistry registry = getSchemeRegistry(context);
  final Scheme schm = registry.getScheme(target.getSchemeName());
  Asserts.check(schm.getSchemeSocketFactory() instanceof SchemeLayeredSocketFactory,
    "Socket factory must implement SchemeLayeredSocketFactory");
  final SchemeLayeredSocketFactory lsf = (SchemeLayeredSocketFactory) schm.getSchemeSocketFactory();
  final Socket sock = lsf.createLayeredSocket(
      conn.getSocket(), target.getHostName(), schm.resolvePort(target.getPort()), params);
  prepareSocket(sock, context, params);
  conn.update(sock, target, lsf.isSecure(sock), params);
}

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

@Override
public void updateSecureConnection(
    final OperatedClientConnection conn,
    final HttpHost target,
    final HttpContext context,
    final HttpParams params) throws IOException {
  Args.notNull(conn, "Connection");
  Args.notNull(target, "Target host");
  Args.notNull(params, "Parameters");
  Asserts.check(conn.isOpen(), "Connection must be open");
  final SchemeRegistry registry = getSchemeRegistry(context);
  final Scheme schm = registry.getScheme(target.getSchemeName());
  Asserts.check(schm.getSchemeSocketFactory() instanceof SchemeLayeredSocketFactory,
    "Socket factory must implement SchemeLayeredSocketFactory");
  final SchemeLayeredSocketFactory lsf = (SchemeLayeredSocketFactory) schm.getSchemeSocketFactory();
  final Socket sock = lsf.createLayeredSocket(
      conn.getSocket(), target.getHostName(), schm.resolvePort(target.getPort()), params);
  prepareSocket(sock, context, params);
  conn.update(sock, target, lsf.isSecure(sock), params);
}

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

final SchemeSocketFactory sf = schm.getSchemeSocketFactory();

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

final SchemeSocketFactory sf = schm.getSchemeSocketFactory();

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

final SchemeSocketFactory sf = schm.getSchemeSocketFactory();

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

final SchemeSocketFactory sf = schm.getSchemeSocketFactory();

相关文章