MCPcopy Create free account
hub / github.com/grpc/grpc-java / convertSpec

Method convertSpec

okhttp/src/main/java/io/grpc/okhttp/Utils.java:74–94  ·  view source on GitHub ↗

Converts an instance of com.squareup.okhttp.ConnectionSpec for a secure connection into that of ConnectionSpec in the current package. @throws IllegalArgumentException If spec is not with TLS

(com.squareup.okhttp.ConnectionSpec spec)

Source from the content-addressed store, hash-verified

72 * If {@code spec} is not with TLS
73 */
74 static ConnectionSpec convertSpec(com.squareup.okhttp.ConnectionSpec spec) {
75 Preconditions.checkArgument(spec.isTls(), "plaintext ConnectionSpec is not accepted");
76
77 List<com.squareup.okhttp.TlsVersion> tlsVersionList = spec.tlsVersions();
78 String[] tlsVersions = new String[tlsVersionList.size()];
79 for (int i = 0; i < tlsVersions.length; i++) {
80 tlsVersions[i] = tlsVersionList.get(i).javaName();
81 }
82
83 List<com.squareup.okhttp.CipherSuite> cipherSuiteList = spec.cipherSuites();
84 CipherSuite[] cipherSuites = new CipherSuite[cipherSuiteList.size()];
85 for (int i = 0; i < cipherSuites.length; i++) {
86 cipherSuites[i] = CipherSuite.valueOf(cipherSuiteList.get(i).name());
87 }
88
89 return new ConnectionSpec.Builder(spec.isTls())
90 .supportsTlsExtensions(spec.supportsTlsExtensions())
91 .tlsVersions(tlsVersions)
92 .cipherSuites(cipherSuites)
93 .build();
94 }
95
96 /**
97 * Attempts to capture all known socket options and return the results as a

Callers 4

connectionSpecMethod · 0.95
createMethod · 0.95

Calls 9

isTlsMethod · 0.80
javaNameMethod · 0.80
sizeMethod · 0.65
getMethod · 0.65
buildMethod · 0.65
tlsVersionsMethod · 0.45
cipherSuitesMethod · 0.45
nameMethod · 0.45
supportsTlsExtensionsMethod · 0.45

Tested by 2