what-the-bank/sources/okhttp3/Handshake.java

226 lines
9.2 KiB
Java

package okhttp3;
import com.airbnb.deeplinkdispatch.UrlTreeKt;
import java.io.IOException;
import java.security.Principal;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import o.C14851gaI;
import o.C14953gcr;
import o.C14957gcv;
import o.InterfaceC13393fZL;
import o.InterfaceC14890gbN;
import o.fZZ;
import okhttp3.internal.Util;
/* loaded from: classes.dex */
public final class Handshake {
public static final Companion Companion = new Companion(null);
private final CipherSuite cipherSuite;
private final List<Certificate> localCertificates;
private final InterfaceC13393fZL peerCertificates$delegate;
private final TlsVersion tlsVersion;
/* JADX WARN: Multi-variable type inference failed */
public Handshake(TlsVersion tlsVersion, CipherSuite cipherSuite, List<? extends Certificate> list, InterfaceC14890gbN<? extends List<? extends Certificate>> interfaceC14890gbN) {
C14957gcv.e(tlsVersion, "");
C14957gcv.e(cipherSuite, "");
C14957gcv.e(list, "");
C14957gcv.e(interfaceC14890gbN, "");
this.tlsVersion = tlsVersion;
this.cipherSuite = cipherSuite;
this.localCertificates = list;
Handshake$peerCertificates$2 handshake$peerCertificates$2 = new Handshake$peerCertificates$2(interfaceC14890gbN);
C14957gcv.e(handshake$peerCertificates$2, "");
this.peerCertificates$delegate = new fZZ(handshake$peerCertificates$2);
}
public final List<Certificate> peerCertificates() {
return (List) this.peerCertificates$delegate.e();
}
/* renamed from: -deprecated_peerCertificates, reason: not valid java name */
public final List<Certificate> m401deprecated_peerCertificates() {
return peerCertificates();
}
public final Principal peerPrincipal() {
List<Certificate> peerCertificates = peerCertificates();
C14957gcv.e(peerCertificates, "");
Certificate certificate = peerCertificates.isEmpty() ? null : peerCertificates.get(0);
X509Certificate x509Certificate = certificate instanceof X509Certificate ? (X509Certificate) certificate : null;
return x509Certificate != null ? x509Certificate.getSubjectX500Principal() : null;
}
/* renamed from: -deprecated_peerPrincipal, reason: not valid java name */
public final Principal m402deprecated_peerPrincipal() {
return peerPrincipal();
}
public final Principal localPrincipal() {
List<Certificate> list = this.localCertificates;
C14957gcv.e(list, "");
Certificate certificate = list.isEmpty() ? null : list.get(0);
X509Certificate x509Certificate = certificate instanceof X509Certificate ? (X509Certificate) certificate : null;
return x509Certificate != null ? x509Certificate.getSubjectX500Principal() : null;
}
/* renamed from: -deprecated_localPrincipal, reason: not valid java name */
public final Principal m400deprecated_localPrincipal() {
return localPrincipal();
}
public final boolean equals(Object obj) {
if (obj instanceof Handshake) {
Handshake handshake = (Handshake) obj;
if (handshake.tlsVersion == this.tlsVersion && C14957gcv.b(handshake.cipherSuite, this.cipherSuite) && C14957gcv.b(handshake.peerCertificates(), peerCertificates()) && C14957gcv.b(handshake.localCertificates, this.localCertificates)) {
return true;
}
}
return false;
}
public final int hashCode() {
int hashCode = this.tlsVersion.hashCode();
int hashCode2 = this.cipherSuite.hashCode();
return ((((((hashCode + 527) * 31) + hashCode2) * 31) + peerCertificates().hashCode()) * 31) + this.localCertificates.hashCode();
}
public final String toString() {
List<Certificate> peerCertificates = peerCertificates();
C14957gcv.e(peerCertificates, "");
ArrayList arrayList = new ArrayList(peerCertificates instanceof Collection ? peerCertificates.size() : 10);
Iterator<T> it = peerCertificates.iterator();
while (it.hasNext()) {
arrayList.add(getName((Certificate) it.next()));
}
String obj = arrayList.toString();
StringBuilder sb = new StringBuilder("Handshake{tlsVersion=");
sb.append(this.tlsVersion);
sb.append(" cipherSuite=");
sb.append(this.cipherSuite);
sb.append(" peerCertificates=");
sb.append(obj);
sb.append(" localCertificates=");
List<Certificate> list = this.localCertificates;
C14957gcv.e(list, "");
ArrayList arrayList2 = new ArrayList(list instanceof Collection ? list.size() : 10);
Iterator<T> it2 = list.iterator();
while (it2.hasNext()) {
arrayList2.add(getName((Certificate) it2.next()));
}
sb.append(arrayList2);
sb.append(UrlTreeKt.componentParamSuffixChar);
return sb.toString();
}
private final String getName(Certificate certificate) {
if (certificate instanceof X509Certificate) {
return ((X509Certificate) certificate).getSubjectDN().toString();
}
String type = certificate.getType();
C14957gcv.c((Object) type, "");
return type;
}
/* loaded from: classes.dex */
public static final class Companion {
private Companion() {
}
public final Handshake get(SSLSession sSLSession) throws IOException {
C14851gaI c14851gaI;
C14957gcv.e(sSLSession, "");
String cipherSuite = sSLSession.getCipherSuite();
if (cipherSuite == null) {
throw new IllegalStateException("cipherSuite == null".toString());
}
if (C14957gcv.b((Object) cipherSuite, (Object) "TLS_NULL_WITH_NULL_NULL") || C14957gcv.b((Object) cipherSuite, (Object) "SSL_NULL_WITH_NULL_NULL")) {
throw new IOException(C14957gcv.c("cipherSuite == ", (Object) cipherSuite));
}
CipherSuite forJavaName = CipherSuite.Companion.forJavaName(cipherSuite);
String protocol = sSLSession.getProtocol();
if (protocol == null) {
throw new IllegalStateException("tlsVersion == null".toString());
}
if (C14957gcv.b((Object) "NONE", (Object) protocol)) {
throw new IOException("tlsVersion == NONE");
}
TlsVersion forJavaName2 = TlsVersion.Companion.forJavaName(protocol);
try {
c14851gaI = toImmutableList(sSLSession.getPeerCertificates());
} catch (SSLPeerUnverifiedException unused) {
c14851gaI = C14851gaI.c;
}
return new Handshake(forJavaName2, forJavaName, toImmutableList(sSLSession.getLocalCertificates()), new Handshake$Companion$handshake$1(c14851gaI));
}
private final List<Certificate> toImmutableList(Certificate[] certificateArr) {
if (certificateArr != null) {
return Util.immutableListOf(Arrays.copyOf(certificateArr, certificateArr.length));
}
return C14851gaI.c;
}
/* renamed from: -deprecated_get, reason: not valid java name */
public final Handshake m404deprecated_get(SSLSession sSLSession) throws IOException {
C14957gcv.e(sSLSession, "");
return get(sSLSession);
}
public final Handshake get(TlsVersion tlsVersion, CipherSuite cipherSuite, List<? extends Certificate> list, List<? extends Certificate> list2) {
C14957gcv.e(tlsVersion, "");
C14957gcv.e(cipherSuite, "");
C14957gcv.e(list, "");
C14957gcv.e(list2, "");
return new Handshake(tlsVersion, cipherSuite, Util.toImmutableList(list2), new Handshake$Companion$get$1(Util.toImmutableList(list)));
}
public /* synthetic */ Companion(C14953gcr c14953gcr) {
this();
}
}
public final TlsVersion tlsVersion() {
return this.tlsVersion;
}
public final List<Certificate> localCertificates() {
return this.localCertificates;
}
public final CipherSuite cipherSuite() {
return this.cipherSuite;
}
/* renamed from: -deprecated_tlsVersion, reason: not valid java name */
public final TlsVersion m403deprecated_tlsVersion() {
return this.tlsVersion;
}
/* renamed from: -deprecated_localCertificates, reason: not valid java name */
public final List<Certificate> m399deprecated_localCertificates() {
return this.localCertificates;
}
/* renamed from: -deprecated_cipherSuite, reason: not valid java name */
public final CipherSuite m398deprecated_cipherSuite() {
return this.cipherSuite;
}
public static final Handshake get(TlsVersion tlsVersion, CipherSuite cipherSuite, List<? extends Certificate> list, List<? extends Certificate> list2) {
return Companion.get(tlsVersion, cipherSuite, list, list2);
}
public static final Handshake get(SSLSession sSLSession) throws IOException {
return Companion.get(sSLSession);
}
}