當前位置: 首頁>>代碼示例>>Java>>正文


Java SSLSocket.getEnabledProtocols方法代碼示例

本文整理匯總了Java中javax.net.ssl.SSLSocket.getEnabledProtocols方法的典型用法代碼示例。如果您正苦於以下問題:Java SSLSocket.getEnabledProtocols方法的具體用法?Java SSLSocket.getEnabledProtocols怎麽用?Java SSLSocket.getEnabledProtocols使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.net.ssl.SSLSocket的用法示例。


在下文中一共展示了SSLSocket.getEnabledProtocols方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: supportedSpec

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
/**
 * Returns a copy of this that omits cipher suites and TLS versions not enabled by {@code
 * sslSocket}.
 */
private ConnectionSpec supportedSpec(SSLSocket sslSocket, boolean isFallback) {
  String[] cipherSuitesIntersection = cipherSuites != null
      ? intersect(CipherSuite.ORDER_BY_NAME, sslSocket.getEnabledCipherSuites(), cipherSuites)
      : sslSocket.getEnabledCipherSuites();
  String[] tlsVersionsIntersection = tlsVersions != null
      ? intersect(Util.NATURAL_ORDER, sslSocket.getEnabledProtocols(), tlsVersions)
      : sslSocket.getEnabledProtocols();

  // In accordance with https://tools.ietf.org/html/draft-ietf-tls-downgrade-scsv-00
  // the SCSV cipher is added to signal that a protocol fallback has taken place.
  String[] supportedCipherSuites = sslSocket.getSupportedCipherSuites();
  int indexOfFallbackScsv = indexOf(
      CipherSuite.ORDER_BY_NAME, supportedCipherSuites, "TLS_FALLBACK_SCSV");
  if (isFallback && indexOfFallbackScsv != -1) {
    cipherSuitesIntersection = concat(
        cipherSuitesIntersection, supportedCipherSuites[indexOfFallbackScsv]);
  }

  return new Builder(this)
      .cipherSuites(cipherSuitesIntersection)
      .tlsVersions(tlsVersionsIntersection)
      .build();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:28,代碼來源:ConnectionSpec.java

示例2: createSSLSocket

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
private static TSocket createSSLSocket(SSLSocketFactory factory, String host,
                                       int port, int timeout, List<String> excludeProtocols)
    throws FlumeException {
  try {
    SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
    socket.setSoTimeout(timeout);

    List<String> enabledProtocols = new ArrayList<String>();
    for (String protocol : socket.getEnabledProtocols()) {
      if (!excludeProtocols.contains(protocol)) {
        enabledProtocols.add(protocol);
      }
    }
    socket.setEnabledProtocols(enabledProtocols.toArray(new String[0]));
    return new TSocket(socket);
  } catch (Exception e) {
    throw new FlumeException("Could not connect to " + host + " on port " + port, e);
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:20,代碼來源:ThriftRpcClient.java

示例3: supportedSpec

import javax.net.ssl.SSLSocket; //導入方法依賴的package包/類
private ConnectionSpec supportedSpec(SSLSocket sslSocket, boolean isFallback) {
    String[] cipherSuitesIntersection;
    String[] tlsVersionsIntersection;
    if (this.cipherSuites != null) {
        cipherSuitesIntersection = (String[]) Util.intersect(String.class, this.cipherSuites,
                sslSocket.getEnabledCipherSuites());
    } else {
        cipherSuitesIntersection = sslSocket.getEnabledCipherSuites();
    }
    if (this.tlsVersions != null) {
        tlsVersionsIntersection = (String[]) Util.intersect(String.class, this.tlsVersions,
                sslSocket.getEnabledProtocols());
    } else {
        tlsVersionsIntersection = sslSocket.getEnabledProtocols();
    }
    if (isFallback && Util.contains(sslSocket.getSupportedCipherSuites(),
            "TLS_FALLBACK_SCSV")) {
        cipherSuitesIntersection = Util.concat(cipherSuitesIntersection, "TLS_FALLBACK_SCSV");
    }
    return new Builder(this).cipherSuites(cipherSuitesIntersection).tlsVersions
            (tlsVersionsIntersection).build();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:23,代碼來源:ConnectionSpec.java


注:本文中的javax.net.ssl.SSLSocket.getEnabledProtocols方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。