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

127 lines
4.4 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.huawei.hms.hatool;
import android.text.TextUtils;
import java.util.HashMap;
import o.gPM;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes2.dex */
public class w0 {
private static void d(String str, String str2) {
try {
JSONObject jSONObject = new JSONObject(str);
String optString = jSONObject.optString("publicKey");
String optString2 = jSONObject.optString("publicKeyOM");
String optString3 = jSONObject.optString("pubkey_version");
StringBuilder sb = new StringBuilder();
sb.append(System.currentTimeMillis());
String obj = sb.toString();
String optString4 = jSONObject.optString("timeInterval");
d.b(q0.i(), "Privacy_MY", "public_key_oper", gPM.a("HiAnalytics_Sdk_Public_Sp_Key", optString));
d.b(q0.i(), "Privacy_MY", "public_key_maint", gPM.a("HiAnalytics_Sdk_Public_Sp_Key", optString2));
d.b(q0.i(), "Privacy_MY", "public_key_time_interval", optString4);
d.b(q0.i(), "Privacy_MY", "public_key_version", optString3);
d.b(q0.i(), "Privacy_MY", "public_key_time_last", obj);
q0.e(optString);
q0.d(optString2);
q0.g(optString3);
q0.c(obj);
q0.f(optString4);
} catch (JSONException e) {
StringBuilder sb2 = new StringBuilder("get pubKey parse json JSONException :");
sb2.append(e.getMessage());
v.e("GetPublicKey", sb2.toString());
}
}
public static String c(String str, String str2) {
String o2;
String c = q0.c();
if (TextUtils.isEmpty(c)) {
c = d.a(q0.i(), "Privacy_MY", "public_key_version", "");
q0.g(c);
}
if (!"2.0".equals(c)) {
a(str, str2);
return null;
}
if ("maint".equals(str2)) {
o2 = q0.n();
if (TextUtils.isEmpty(o2)) {
o2 = gPM.e("HiAnalytics_Sdk_Public_Sp_Key", d.a(q0.i(), "Privacy_MY", "public_key_maint", ""));
q0.d(o2);
}
} else {
o2 = q0.o();
if (TextUtils.isEmpty(o2)) {
o2 = gPM.e("HiAnalytics_Sdk_Public_Sp_Key", d.a(q0.i(), "Privacy_MY", "public_key_oper", ""));
q0.e(o2);
}
}
if (!TextUtils.isEmpty(o2) && !a()) {
return o2;
}
a(str, str2);
return null;
}
public static void b(String str, String str2) {
n0 n0Var;
String obj;
String replace = "{url}/getPublicKey?keytype=4".replace("{url}", a1.f(str, str2));
String f = q0.f();
HashMap hashMap = new HashMap();
hashMap.put("App-Id", f);
try {
n0Var = w.a(replace, new byte[0], hashMap);
} catch (Exception e) {
StringBuilder sb = new StringBuilder("get pubKey response Exception :");
sb.append(e.getMessage());
v.e("GetPublicKey", sb.toString());
n0Var = null;
}
if (n0Var == null) {
obj = "get pubKey response is null";
} else if (n0Var.b() == 200) {
if (TextUtils.isEmpty(n0Var.a())) {
return;
}
d(n0Var.a(), str2);
return;
} else {
StringBuilder sb2 = new StringBuilder("get pubKey fail HttpCode :");
sb2.append(n0Var.b());
obj = sb2.toString();
}
v.e("GetPublicKey", obj);
}
public static boolean a() {
String a = q0.a();
if (TextUtils.isEmpty(a)) {
a = d.a(q0.i(), "Privacy_MY", "public_key_time_interval", "");
q0.f(a);
}
String m = q0.m();
if (TextUtils.isEmpty(m)) {
m = d.a(q0.i(), "Privacy_MY", "public_key_time_last", "");
q0.c(m);
}
if (!TextUtils.isEmpty(a) && !TextUtils.isEmpty(m)) {
try {
return System.currentTimeMillis() - Long.parseLong(m) > ((long) Integer.parseInt(a));
} catch (NumberFormatException e) {
StringBuilder sb = new StringBuilder("checkCachePubKey NumberFormatException :");
sb.append(e.getMessage());
v.e("GetPublicKey", sb.toString());
}
}
return true;
}
private static void a(String str, String str2) {
b0.a().a(new j1(str, str2));
}
}