okhttp3.internal.Util.intersect()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(167)

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

Util.intersect介绍

[英]Returns an array containing containing only elements found in first and also in second. The returned elements are in the same order as in first.
[中]返回一个数组,该数组只包含在第一个和第二个中找到的元素。返回的元素与第一个元素的顺序相同。

代码示例

代码示例来源:origin: square/okhttp

/**
 * 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();
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

/**
 * 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();
}

代码示例来源:origin: huxq17/SwipeCardsView

/**
 * Returns an array containing containing only elements found in {@code first}  and also in
 * {@code second}. The returned elements are in the same order as in {@code first}.
 */
@SuppressWarnings("unchecked")
public static <T> T[] intersect(Class<T> arrayType, T[] first, T[] second) {
 List<T> result = intersect(first, second);
 return result.toArray((T[]) Array.newInstance(arrayType, result.size()));
}

代码示例来源:origin: huxq17/tractor

/**
 * Returns an array containing containing only elements found in {@code first}  and also in
 * {@code second}. The returned elements are in the same order as in {@code first}.
 */
@SuppressWarnings("unchecked")
public static <T> T[] intersect(Class<T> arrayType, T[] first, T[] second) {
 List<T> result = intersect(first, second);
 return result.toArray((T[]) Array.newInstance(arrayType, result.size()));
}

代码示例来源:origin: duzechao/OKHttpUtils

/**
 * Returns an array containing containing only elements found in {@code first}  and also in {@code
 * second}. The returned elements are in the same order as in {@code first}.
 */
@SuppressWarnings("unchecked")
public static <T> T[] intersect(Class<T> arrayType, T[] first, T[] second) {
 List<T> result = intersect(first, second);
 return result.toArray((T[]) Array.newInstance(arrayType, result.size()));
}

代码示例来源:origin: huxq17/SwipeCardsView

/**
 * 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(String.class, cipherSuites, sslSocket.getEnabledCipherSuites())
   : sslSocket.getEnabledCipherSuites();
 String[] tlsVersionsIntersection = tlsVersions != null
   ? intersect(String.class, tlsVersions, sslSocket.getEnabledProtocols())
   : 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.
 if (isFallback && contains(sslSocket.getSupportedCipherSuites(), "TLS_FALLBACK_SCSV")) {
  cipherSuitesIntersection = concat(cipherSuitesIntersection, "TLS_FALLBACK_SCSV");
 }
 return new Builder(this)
   .cipherSuites(cipherSuitesIntersection)
   .tlsVersions(tlsVersionsIntersection)
   .build();
}

代码示例来源:origin: huxq17/tractor

/**
 * 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(String.class, cipherSuites, sslSocket.getEnabledCipherSuites())
   : sslSocket.getEnabledCipherSuites();
 String[] tlsVersionsIntersection = tlsVersions != null
   ? intersect(String.class, tlsVersions, sslSocket.getEnabledProtocols())
   : 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.
 if (isFallback && contains(sslSocket.getSupportedCipherSuites(), "TLS_FALLBACK_SCSV")) {
  cipherSuitesIntersection = concat(cipherSuitesIntersection, "TLS_FALLBACK_SCSV");
 }
 return new Builder(this)
   .cipherSuites(cipherSuitesIntersection)
   .tlsVersions(tlsVersionsIntersection)
   .build();
}

代码示例来源:origin: duzechao/OKHttpUtils

/**
 * 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(String.class, cipherSuites, sslSocket.getEnabledCipherSuites())
   : sslSocket.getEnabledCipherSuites();
 String[] tlsVersionsIntersection = tlsVersions != null
   ? intersect(String.class, tlsVersions, sslSocket.getEnabledProtocols())
   : 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.
 if (isFallback && contains(sslSocket.getSupportedCipherSuites(), "TLS_FALLBACK_SCSV")) {
  cipherSuitesIntersection = concat(cipherSuitesIntersection, "TLS_FALLBACK_SCSV");
 }
 return new Builder(this)
   .cipherSuites(cipherSuitesIntersection)
   .tlsVersions(tlsVersionsIntersection)
   .build();
}

代码示例来源:origin: com.github.ljun20160606/okhttp

/**
 * 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();
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * 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();
}

相关文章