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

110 lines
3.7 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package okhttp3.repackaged;
import java.security.Principal;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.Collections;
import java.util.List;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import okhttp3.repackaged.internal.Util;
/* loaded from: classes6.dex */
public final class Handshake {
private final TlsVersion ahG;
private final CipherSuite ahH;
private final List<Certificate> ahI;
private final List<Certificate> ahJ;
private Handshake(TlsVersion tlsVersion, CipherSuite cipherSuite, List<Certificate> list, List<Certificate> list2) {
this.ahG = tlsVersion;
this.ahH = cipherSuite;
this.ahI = list;
this.ahJ = list2;
}
public static Handshake get(SSLSession sSLSession) {
Certificate[] certificateArr;
List emptyList;
List emptyList2;
String cipherSuite = sSLSession.getCipherSuite();
if (cipherSuite == null) {
throw new IllegalStateException("cipherSuite == null");
}
CipherSuite forJavaName = CipherSuite.forJavaName(cipherSuite);
String protocol = sSLSession.getProtocol();
if (protocol == null) {
throw new IllegalStateException("tlsVersion == null");
}
TlsVersion forJavaName2 = TlsVersion.forJavaName(protocol);
try {
certificateArr = sSLSession.getPeerCertificates();
} catch (SSLPeerUnverifiedException unused) {
certificateArr = null;
}
if (certificateArr != null) {
emptyList = Util.immutableList(certificateArr);
} else {
emptyList = Collections.emptyList();
}
Certificate[] localCertificates = sSLSession.getLocalCertificates();
if (localCertificates != null) {
emptyList2 = Util.immutableList(localCertificates);
} else {
emptyList2 = Collections.emptyList();
}
return new Handshake(forJavaName2, forJavaName, emptyList, emptyList2);
}
public static Handshake get(TlsVersion tlsVersion, CipherSuite cipherSuite, List<Certificate> list, List<Certificate> list2) {
if (cipherSuite == null) {
throw new IllegalArgumentException("cipherSuite == null");
}
return new Handshake(tlsVersion, cipherSuite, Util.immutableList(list), Util.immutableList(list2));
}
public final Principal peerPrincipal() {
if (this.ahI.isEmpty()) {
return null;
}
return ((X509Certificate) this.ahI.get(0)).getSubjectX500Principal();
}
public final Principal localPrincipal() {
if (this.ahJ.isEmpty()) {
return null;
}
return ((X509Certificate) this.ahJ.get(0)).getSubjectX500Principal();
}
public final boolean equals(Object obj) {
if (!(obj instanceof Handshake)) {
return false;
}
Handshake handshake = (Handshake) obj;
return Util.equal(this.ahH, handshake.ahH) && this.ahH.equals(handshake.ahH) && this.ahI.equals(handshake.ahI) && this.ahJ.equals(handshake.ahJ);
}
public final int hashCode() {
TlsVersion tlsVersion = this.ahG;
int hashCode = tlsVersion != null ? tlsVersion.hashCode() : 0;
return ((((((hashCode + 527) * 31) + this.ahH.hashCode()) * 31) + this.ahI.hashCode()) * 31) + this.ahJ.hashCode();
}
public final TlsVersion tlsVersion() {
return this.ahG;
}
public final List<Certificate> peerCertificates() {
return this.ahI;
}
public final List<Certificate> localCertificates() {
return this.ahJ;
}
public final CipherSuite cipherSuite() {
return this.ahH;
}
}