what-the-bank/sources/com/huawei/hms/hatool/w.java

342 lines
16 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.huawei.hms.hatool;
import android.text.TextUtils;
import com.google.common.net.HttpHeaders;
import com.kofax.kmc.kut.utilities.IpLibUtil;
import io.grpc.internal.GrpcUtil;
import java.io.BufferedOutputStream;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.net.ConnectException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.Map;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException;
/* loaded from: classes2.dex */
public abstract class w {
private static String b(HttpURLConnection httpURLConnection) {
InputStream inputStream = null;
try {
try {
inputStream = httpURLConnection.getInputStream();
return k1.a(inputStream);
} catch (IOException unused) {
int responseCode = httpURLConnection.getResponseCode();
StringBuilder sb = new StringBuilder("When Response Content From Connection inputStream operation exception! ");
sb.append(responseCode);
v.f("hmsSdk", sb.toString());
k1.a((Closeable) inputStream);
return "";
}
} finally {
k1.a((Closeable) inputStream);
}
}
/* JADX WARN: Removed duplicated region for block: B:10:0x0031 */
/* JADX WARN: Removed duplicated region for block: B:7:0x0025 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private static void a(java.net.HttpURLConnection r2) {
/*
boolean r0 = r2 instanceof javax.net.ssl.HttpsURLConnection
if (r0 == 0) goto L39
javax.net.ssl.HttpsURLConnection r2 = (javax.net.ssl.HttpsURLConnection) r2
android.content.Context r0 = com.huawei.hms.hatool.q0.i() // Catch: java.lang.IllegalAccessException -> Lf java.io.IOException -> L12 java.security.GeneralSecurityException -> L15 java.security.KeyStoreException -> L18 java.security.NoSuchAlgorithmException -> L1b
o.WCI r0 = o.WCI.d(r0) // Catch: java.lang.IllegalAccessException -> Lf java.io.IOException -> L12 java.security.GeneralSecurityException -> L15 java.security.KeyStoreException -> L18 java.security.NoSuchAlgorithmException -> L1b
goto L23
Lf:
java.lang.String r0 = "getSocketFactory(): Illegal Access Exception "
goto L1d
L12:
java.lang.String r0 = "getSocketFactory(): IO Exception!"
goto L1d
L15:
java.lang.String r0 = "getSocketFactory(): General Security Exception"
goto L1d
L18:
java.lang.String r0 = "getSocketFactory(): Key Store exception"
goto L1d
L1b:
java.lang.String r0 = "getSocketFactory(): Algorithm Exception!"
L1d:
java.lang.String r1 = "hmsSdk"
com.huawei.hms.hatool.v.f(r1, r0)
r0 = 0
L23:
if (r0 == 0) goto L31
r2.setSSLSocketFactory(r0)
o.wgU r0 = new o.wgU
r0.<init>()
r2.setHostnameVerifier(r0)
return
L31:
com.huawei.hms.hatool.w$a r2 = new com.huawei.hms.hatool.w$a
java.lang.String r0 = "No ssl socket factory set"
r2.<init>(r0)
throw r2
L39:
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.huawei.hms.hatool.w.a(java.net.HttpURLConnection):void");
}
private static HttpURLConnection a(String str, int i, Map<String, String> map, String str2) {
if (TextUtils.isEmpty(str)) {
v.b("hmsSdk", "CreateConnection: invalid urlPath.");
return null;
}
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
a(httpURLConnection);
httpURLConnection.setRequestMethod(str2);
httpURLConnection.setConnectTimeout(15000);
httpURLConnection.setReadTimeout(15000);
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestProperty(HttpHeaders.CONTENT_TYPE, "application/json; charset=UTF-8");
httpURLConnection.setRequestProperty(HttpHeaders.CONTENT_LENGTH, String.valueOf(i));
httpURLConnection.setRequestProperty(HttpHeaders.CONNECTION, "close");
if (map != null && map.size() > 0) {
for (Map.Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
if (key != null && !TextUtils.isEmpty(key)) {
httpURLConnection.setRequestProperty(key, entry.getValue());
}
}
}
return httpURLConnection;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class a extends Exception {
a(String str) {
super(str);
}
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r6v0, types: [java.lang.CharSequence, java.lang.String] */
/* JADX WARN: Type inference failed for: r6v10, types: [java.net.HttpURLConnection] */
/* JADX WARN: Type inference failed for: r6v11, types: [java.net.HttpURLConnection] */
/* JADX WARN: Type inference failed for: r6v12, types: [java.net.HttpURLConnection] */
/* JADX WARN: Type inference failed for: r6v13, types: [java.net.HttpURLConnection] */
/* JADX WARN: Type inference failed for: r6v14, types: [java.net.HttpURLConnection] */
/* JADX WARN: Type inference failed for: r6v15, types: [java.net.HttpURLConnection] */
/* JADX WARN: Type inference failed for: r6v16, types: [java.net.HttpURLConnection] */
/* JADX WARN: Type inference failed for: r6v17, types: [java.net.HttpURLConnection] */
/* JADX WARN: Type inference failed for: r6v18, types: [java.net.HttpURLConnection, java.net.URLConnection] */
/* JADX WARN: Type inference failed for: r6v2 */
/* JADX WARN: Type inference failed for: r6v3 */
/* JADX WARN: Type inference failed for: r6v4 */
/* JADX WARN: Type inference failed for: r6v5 */
/* JADX WARN: Type inference failed for: r6v6 */
/* JADX WARN: Type inference failed for: r6v7 */
/* JADX WARN: Type inference failed for: r6v8 */
/* JADX WARN: Type inference failed for: r6v9 */
/* JADX WARN: Type inference failed for: r8v0, types: [java.util.Map<java.lang.String, java.lang.String>, java.util.Map] */
/* JADX WARN: Type inference failed for: r8v1 */
/* JADX WARN: Type inference failed for: r8v10, types: [java.io.Closeable] */
/* JADX WARN: Type inference failed for: r8v11, types: [java.io.Closeable] */
/* JADX WARN: Type inference failed for: r8v12, types: [java.io.Closeable] */
/* JADX WARN: Type inference failed for: r8v13, types: [java.io.Closeable] */
/* JADX WARN: Type inference failed for: r8v14, types: [java.io.Closeable] */
/* JADX WARN: Type inference failed for: r8v15, types: [java.io.Closeable] */
/* JADX WARN: Type inference failed for: r8v16, types: [java.io.Closeable] */
/* JADX WARN: Type inference failed for: r8v17 */
/* JADX WARN: Type inference failed for: r8v18 */
/* JADX WARN: Type inference failed for: r8v19 */
/* JADX WARN: Type inference failed for: r8v2 */
/* JADX WARN: Type inference failed for: r8v20 */
/* JADX WARN: Type inference failed for: r8v21 */
/* JADX WARN: Type inference failed for: r8v22 */
/* JADX WARN: Type inference failed for: r8v23 */
/* JADX WARN: Type inference failed for: r8v24 */
/* JADX WARN: Type inference failed for: r8v25, types: [java.io.OutputStream, java.io.Closeable] */
/* JADX WARN: Type inference failed for: r8v3 */
/* JADX WARN: Type inference failed for: r8v4 */
/* JADX WARN: Type inference failed for: r8v5 */
/* JADX WARN: Type inference failed for: r8v6 */
/* JADX WARN: Type inference failed for: r8v7 */
/* JADX WARN: Type inference failed for: r8v8 */
/* JADX WARN: Type inference failed for: r8v9, types: [java.io.Closeable] */
public static n0 a(String str, byte[] bArr, Map<String, String> map, String str2) {
Throwable th;
BufferedOutputStream bufferedOutputStream;
if (TextUtils.isEmpty(str)) {
return new n0(-100, "");
}
int i = IpLibUtil.KIPP_BAD_POINTER;
BufferedOutputStream bufferedOutputStream2 = null;
try {
try {
str = a((String) str, bArr.length, (Map<String, String>) map, str2);
try {
if (str == 0) {
n0 n0Var = new n0(IpLibUtil.KIPP_BAD_HISTOGRAM, "");
k1.a((Closeable) null);
k1.a((Closeable) null);
if (str != 0) {
k1.a((HttpURLConnection) str);
}
return n0Var;
}
map = str.getOutputStream();
try {
bufferedOutputStream = new BufferedOutputStream(map);
} catch (a unused) {
} catch (SecurityException unused2) {
} catch (ConnectException unused3) {
} catch (UnknownHostException unused4) {
} catch (SSLHandshakeException unused5) {
} catch (SSLPeerUnverifiedException unused6) {
} catch (IOException unused7) {
}
try {
bufferedOutputStream.write(bArr);
bufferedOutputStream.flush();
i = str.getResponseCode();
n0 n0Var2 = new n0(i, b(str));
k1.a((Closeable) bufferedOutputStream);
k1.a((Closeable) map);
k1.a((HttpURLConnection) str);
return n0Var2;
} catch (a unused8) {
bufferedOutputStream2 = bufferedOutputStream;
v.f("hmsSdk", "PostRequest(byte[]): No ssl socket factory set!");
n0 n0Var3 = new n0(IpLibUtil.KIPP_BAD_HISTOGRAM, "");
k1.a((Closeable) bufferedOutputStream2);
k1.a((Closeable) map);
if (str != 0) {
k1.a((HttpURLConnection) str);
}
return n0Var3;
} catch (SecurityException unused9) {
bufferedOutputStream2 = bufferedOutputStream;
v.f("hmsSdk", "SecurityException with HttpClient. Please check INTERNET permission.");
n0 n0Var4 = new n0(i, "");
k1.a((Closeable) bufferedOutputStream2);
k1.a((Closeable) map);
if (str != 0) {
k1.a((HttpURLConnection) str);
}
return n0Var4;
} catch (ConnectException unused10) {
bufferedOutputStream2 = bufferedOutputStream;
v.f("hmsSdk", "Network is unreachable or Connection refused");
n0 n0Var5 = new n0(i, "");
k1.a((Closeable) bufferedOutputStream2);
k1.a((Closeable) map);
if (str != 0) {
k1.a((HttpURLConnection) str);
}
return n0Var5;
} catch (UnknownHostException unused11) {
bufferedOutputStream2 = bufferedOutputStream;
v.f("hmsSdk", "No address associated with hostname or No network");
n0 n0Var6 = new n0(i, "");
k1.a((Closeable) bufferedOutputStream2);
k1.a((Closeable) map);
if (str != 0) {
k1.a((HttpURLConnection) str);
}
return n0Var6;
} catch (SSLHandshakeException unused12) {
bufferedOutputStream2 = bufferedOutputStream;
v.f("hmsSdk", "Chain validation failed,Certificate expired");
n0 n0Var7 = new n0(i, "");
k1.a((Closeable) bufferedOutputStream2);
k1.a((Closeable) map);
if (str != 0) {
k1.a((HttpURLConnection) str);
}
return n0Var7;
} catch (SSLPeerUnverifiedException unused13) {
bufferedOutputStream2 = bufferedOutputStream;
v.f("hmsSdk", "Certificate has not been verified,Request is restricted!");
n0 n0Var8 = new n0(i, "");
k1.a((Closeable) bufferedOutputStream2);
k1.a((Closeable) map);
if (str != 0) {
k1.a((HttpURLConnection) str);
}
return n0Var8;
} catch (IOException unused14) {
bufferedOutputStream2 = bufferedOutputStream;
v.f("hmsSdk", "events PostRequest(byte[]): IOException occurred.");
n0 n0Var9 = new n0(i, "");
k1.a((Closeable) bufferedOutputStream2);
k1.a((Closeable) map);
if (str != 0) {
k1.a((HttpURLConnection) str);
}
return n0Var9;
} catch (Throwable th2) {
th = th2;
bufferedOutputStream2 = bufferedOutputStream;
k1.a((Closeable) bufferedOutputStream2);
k1.a((Closeable) map);
if (str != 0) {
k1.a((HttpURLConnection) str);
}
throw th;
}
} catch (a unused15) {
map = 0;
} catch (SecurityException unused16) {
map = 0;
} catch (ConnectException unused17) {
map = 0;
} catch (UnknownHostException unused18) {
map = 0;
} catch (SSLHandshakeException unused19) {
map = 0;
} catch (SSLPeerUnverifiedException unused20) {
map = 0;
} catch (IOException unused21) {
map = 0;
} catch (Throwable th3) {
th = th3;
map = 0;
}
} catch (Throwable th4) {
th = th4;
}
} catch (a unused22) {
str = 0;
map = 0;
} catch (SecurityException unused23) {
str = 0;
map = 0;
} catch (ConnectException unused24) {
str = 0;
map = 0;
} catch (UnknownHostException unused25) {
str = 0;
map = 0;
} catch (SSLHandshakeException unused26) {
str = 0;
map = 0;
} catch (SSLPeerUnverifiedException unused27) {
str = 0;
map = 0;
} catch (IOException unused28) {
str = 0;
map = 0;
} catch (Throwable th5) {
th = th5;
str = 0;
map = 0;
}
}
public static n0 a(String str, byte[] bArr, Map<String, String> map) {
return a(str, bArr, map, GrpcUtil.HTTP_METHOD);
}
}