package com.mobile.auth.f; import android.content.Context; import android.content.SharedPreferences; import android.text.TextUtils; import com.cmic.sso.sdk.h.f; import com.cmic.sso.sdk.h.p; import com.cmic.sso.sdk.h.u; import com.czhj.sdk.common.Constants; import com.mobile.auth.BuildConfig; import com.mobile.auth.f.a; import org.json.JSONObject; public class b { private static b a; private a b; private a c; private volatile boolean d = false; private c e; /* access modifiers changed from: package-private */ public class a implements com.mobile.auth.h.b { a() { } @Override // com.mobile.auth.h.b public void a(String str, String str2, JSONObject jSONObject) { try { if ("103000".equals(str)) { b.this.a((b) jSONObject); p.a("sdk_config_ver", BuildConfig.CMCC_SDK_VERSION); b bVar = b.this; bVar.b = bVar.d(); if (b.this.e != null) { b.this.e.a(b.this.b); } } } catch (Exception e) { e.printStackTrace(); } b.this.d = false; } } /* access modifiers changed from: package-private */ /* renamed from: com.mobile.auth.f.b$b reason: collision with other inner class name */ public class C0246b extends u.a { final /* synthetic */ Context a; final /* synthetic */ com.cmic.sso.sdk.a b; C0246b(Context context, com.cmic.sso.sdk.a aVar) { this.a = context; this.b = aVar; } @Override // com.cmic.sso.sdk.h.u.a public void a() { f.b("UmcConfigHandle", "开始拉取配置.."); b.this.b(this.a, this.b); } } /* access modifiers changed from: package-private */ public interface c { void a(a aVar); } private b(boolean z) { a a2 = new a.b().a(); this.c = a2; if (!z) { this.b = d(); } else { this.b = a2; } } public static b a(boolean z) { if (a == null) { synchronized (b.class) { if (a == null) { a = new b(z); } } } return a; } private String a(String str, String str2) { String str3; String[] split = str.split("&"); int length = split.length; int i = 0; while (true) { if (i >= length) { str3 = ""; break; } str3 = split[i]; if (str3.contains(str2)) { break; } i++; } return !TextUtils.isEmpty(str3) ? str3.substring(str3.lastIndexOf("=") + 1) : str3; } /* access modifiers changed from: private */ /* access modifiers changed from: public */ /* JADX WARNING: Removed duplicated region for block: B:65:0x020a */ /* JADX WARNING: Removed duplicated region for block: B:75:0x024d */ private void a(JSONObject jSONObject) { JSONObject jSONObject2; String str; String str2; String str3; SharedPreferences.Editor b2 = p.b("sso_config_xf"); try { if (jSONObject.has("client_valid")) { b2.putLong("client_valid", System.currentTimeMillis() + (((long) Integer.parseInt(jSONObject.getString("client_valid"))) * 60 * 60 * 1000)); } if (jSONObject.has("Configlist")) { JSONObject jSONObject3 = jSONObject.getJSONObject("Configlist"); if (jSONObject3.has("CHANGE_HOST")) { String string = jSONObject3.getString("CHANGE_HOST"); if (string.contains("M005")) { String[] split = string.split("&"); str = "&"; int length = split.length; jSONObject2 = jSONObject3; int i = 0; while (true) { if (i >= length) { str3 = null; break; } String str4 = split[i]; if (str4.contains("M005")) { str3 = str4; break; } else { i++; length = length; } } if (!TextUtils.isEmpty(str3)) { if (str3.contains(",")) { String substring = str3.substring(str3.indexOf("=") + 1, str3.indexOf(",")); String substring2 = str3.substring(str3.lastIndexOf("=") + 1); f.a("UmcConfigHandle", "HTTP:" + substring + "||||||||HTTPS:" + substring2); b2.putString("httpHost", substring); b2.putString("httpsHost", substring2); } else if (str3.contains(Constants.HTTPS) || str3.contains("HTTPS")) { b2.putString("httpsHost", str3.substring(str3.lastIndexOf("=") + 1)); } else if (str3.contains(Constants.HTTP) || str3.contains("HTTP")) { b2.putString("httpHost", str3.substring(str3.lastIndexOf("=") + 1)); } } } else { jSONObject2 = jSONObject3; str = "&"; } if (string.contains("M007")) { String a2 = a(string, "M007"); if (!TextUtils.isEmpty(a2)) { b2.putString("logHost", a2); } } if (string.contains("M008")) { String a3 = a(string, "M008"); if (!TextUtils.isEmpty(a3)) { b2.putString("https_get_phone_scrip_host", a3); } } if (string.contains("M009")) { String a4 = a(string, "M009"); if (!TextUtils.isEmpty(a4)) { b2.putString("configHost", a4); } } } else { jSONObject2 = jSONObject3; str = "&"; b2.remove("httpHost"); b2.remove("httpsHost"); b2.remove("logHost"); b2.remove("https_get_phone_scrip_host"); b2.remove("configHost"); } if (jSONObject2.has("HOST_CERT_INFO")) { String optString = jSONObject2.optString("HOST_CERT_INFO"); if (!TextUtils.isEmpty(optString) && !"null".equalsIgnoreCase(optString)) { str2 = str; String[] split2 = optString.split(str2); if (split2[0].contains(":") && split2[0].contains(",")) { String substring3 = split2[0].substring(split2[0].indexOf(":") + 1, split2[0].indexOf(",")); f.b("UmcConfigHandle", "cer = " + substring3); b2.putString("CERT_INFO", substring3); } a(jSONObject2, "CLOSE_CERT_VERIFY", "0", b2); a(jSONObject2, "CLOSE_FRIEND_WAPKS", "0", b2); a(jSONObject2, "CLOSE_LOGS_VERSION", "0", b2); a(jSONObject2, "CLOSE_IPV4_LIST", "0", b2); a(jSONObject2, "CLOSE_IPV6_LIST", "1", b2); a(jSONObject2, "CLOSE_M005_SDKVERSION_LIST", "0", b2); a(jSONObject2, "CLOSE_M005_APPID_LIST", "0", b2); a(jSONObject2, "CLOSE_M008_APPID_LIST", "0", b2); a(jSONObject2, "CLOSE_M008_SDKVERSION_LIST", "0", b2); a(jSONObject2, "WAPKS_HTTPS", "0", b2); if (!jSONObject2.has("LOGS_CONTROL")) { String[] split3 = jSONObject2.getString("LOGS_CONTROL").replace("h", "").split(str2); if (split3.length == 2 && !TextUtils.isEmpty(split3[0]) && !TextUtils.isEmpty(split3[1])) { try { int parseInt = Integer.parseInt(split3[0]); int parseInt2 = Integer.parseInt(split3[1]); b2.putInt("maxFailedLogTimes", parseInt); b2.putInt("pauseTime", parseInt2); } catch (Exception unused) { f.a("UmcConfigHandle", "解析日志上报限制时间次数异常"); } } } else { b2.remove("maxFailedLogTimes"); b2.remove("pauseTime"); } } } str2 = str; a(jSONObject2, "CLOSE_CERT_VERIFY", "0", b2); a(jSONObject2, "CLOSE_FRIEND_WAPKS", "0", b2); a(jSONObject2, "CLOSE_LOGS_VERSION", "0", b2); a(jSONObject2, "CLOSE_IPV4_LIST", "0", b2); a(jSONObject2, "CLOSE_IPV6_LIST", "1", b2); a(jSONObject2, "CLOSE_M005_SDKVERSION_LIST", "0", b2); a(jSONObject2, "CLOSE_M005_APPID_LIST", "0", b2); a(jSONObject2, "CLOSE_M008_APPID_LIST", "0", b2); a(jSONObject2, "CLOSE_M008_SDKVERSION_LIST", "0", b2); a(jSONObject2, "WAPKS_HTTPS", "0", b2); if (!jSONObject2.has("LOGS_CONTROL")) { } } b2.commit(); } catch (Exception e2) { f.a("UmcConfigHandle", "配置项异常,配置失效"); e2.printStackTrace(); } } private void a(JSONObject jSONObject, String str, String str2, SharedPreferences.Editor editor) { if (jSONObject.has(str)) { String optString = jSONObject.optString(str, str2); if (!"CLOSE_FRIEND_WAPKS".equals(str)) { if (!"0".equals(optString) && !"1".equals(optString)) { return; } } else if (TextUtils.isEmpty(optString)) { return; } else { if (!optString.contains("CU") && !optString.contains("CT") && !optString.contains("CM")) { return; } } editor.putString(str, jSONObject.optString(str, str2)); return; } editor.remove(str); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void b(Context context, com.cmic.sso.sdk.a aVar) { if (this.d) { f.a("UmcConfigHandle", "正在获取配置中..."); return; } boolean z = true; this.d = true; if ((!TextUtils.isEmpty(this.c.a()) || !TextUtils.isEmpty(this.b.a())) && !aVar.a("is_need_to_get_cert", false)) { z = false; } f.b("UmcConfigHandle", "httpsDefaultCert: " + this.c.a()); f.b("UmcConfigHandle", "httpsLocalCert: " + this.b.a()); com.mobile.auth.h.a.a(context).a(z, aVar, new a()); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private a d() { return new a.b().a(d.b(this.c.b())).b(d.d(this.c.c())).e(d.a(this.c.e())).c(d.c(this.c.d())).f(d.e(this.c.f())).d(d.f(this.c.a())).f(d.a(this.c.l())).g(d.b(this.c.m())).b(d.h(this.c.h())).c(d.g(this.c.i())).a(d.f(this.c.g())).d(d.c(this.c.j())).e(d.d(this.c.k())).h(d.e(this.c.n())).i(d.i(this.c.o())).a(d.a(this.c.p())).b(d.b(this.c.q())).a(); } /* access modifiers changed from: package-private */ public a a() { return this.c; } /* access modifiers changed from: package-private */ public void a(Context context, com.cmic.sso.sdk.a aVar) { if (d.a() || aVar.a("downLoadConfig", false) || aVar.a("is_need_to_get_cert", false)) { u.a(new C0246b(context, aVar)); } } /* access modifiers changed from: package-private */ public void a(c cVar) { this.e = cVar; } /* access modifiers changed from: package-private */ public a b() { return this.b; } /* access modifiers changed from: package-private */ public void c() { SharedPreferences.Editor b2 = p.b("sso_config_xf"); b2.clear(); b2.commit(); } }