package cn.jiguang.verifysdk.f.d; import android.content.Context; import android.text.TextUtils; import android.util.Base64; import android.util.Log; import cn.jiguang.api.JCoreInterface; import cn.jiguang.verifysdk.f.e.b; import cn.jiguang.verifysdk.f.e.c; import cn.jiguang.verifysdk.i.d; import cn.jiguang.verifysdk.i.h; import cn.jiguang.verifysdk.i.i; import cn.jiguang.verifysdk.i.k; import cn.jiguang.verifysdk.i.l; import cn.jiguang.verifysdk.i.n; import cn.jiguang.verifysdk.i.o; import cn.jiguang.verifysdk.i.r; import com.google.android.exoplayer2.PlaybackException; import com.king.zxing.util.LogUtils; import org.json.JSONException; import org.json.JSONObject; import tv.danmaku.ijk.media.player.IjkMediaPlayer; public class a { /* renamed from: cn.jiguang.verifysdk.f.d.a$a reason: collision with other inner class name */ public static class C0016a extends Thread { public static String a = "https://sdk.sms.jpush.cn"; private Context b; private cn.jiguang.verifysdk.f.a.a c; private String d; private String e; private String f; private int g; private int h; public C0016a(Context context, String str, String str2, String str3, int i, int i2, cn.jiguang.verifysdk.f.a.a aVar) { this.b = context.getApplicationContext(); this.c = aVar; this.d = str; this.e = str3; this.f = str2; this.g = i; this.h = i2; } private static cn.jiguang.verifysdk.f.b.a a(cn.jiguang.verifysdk.f.b.a aVar, String str, String str2, String str3) { String str4; int i; try { l.b("SmsCodeAction", "getCodeInfoWithUrl :" + str); h hVar = new h(str); hVar.a(15000); a(hVar, str2, str3); cn.jiguang.verifysdk.test.a.d(8002, "SMS:body请求体加密后", str3); cn.jiguang.verifysdk.test.a.d(8003, "SMS:aes_secret", str2); cn.jiguang.verifysdk.test.a.d(8004, "SMS:url", str); i a2 = k.a(hVar, str3, null); l.b("SmsCodeAction", "response = " + a2.toString()); cn.jiguang.verifysdk.test.a.d(8005, "SMS:response", a2); int b2 = a2.b(); if (b2 == 200 || b2 == 401) { JSONObject jSONObject = new JSONObject(a2.a()); String optString = jSONObject.optString("uuid"); if (!TextUtils.isEmpty(optString)) { aVar.a(2000); aVar.b(optString); return aVar; } JSONObject optJSONObject = jSONObject.optJSONObject(IjkMediaPlayer.OnNativeInvokeListener.ARG_ERROR); if (optJSONObject != null) { str4 = optJSONObject.optInt("code", PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED) + LogUtils.COLON + optJSONObject.optString("message", "获取失败"); aVar.a(PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED); } else { str4 = jSONObject.optInt("code", PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED) + LogUtils.COLON + jSONObject.optString("content", "获取失败"); aVar.a(PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED); } } else { str4 = a2.a(); if (b2 == 2998 || b2 == 3001 || b2 == 3003 || b2 == 3004) { i = 2013; } else { str4 = b2 + LogUtils.COLON + str4; i = 3004; } aVar.a(i); } aVar.c(str4); } catch (JSONException e2) { e2.printStackTrace(); aVar.a(PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED); aVar.c("数据解析失败:" + e2); } return aVar; } private static cn.jiguang.verifysdk.f.b.a a(String str, String str2, String str3, int i, int i2) { l.b("SmsCodeAction", "getSmsCodeInfo phone:" + str + ",sign_id:" + str2 + ",temp_id:" + str3 + ",type:" + i + ",language:" + i2); cn.jiguang.verifysdk.f.b.a aVar = new cn.jiguang.verifysdk.f.b.a(); aVar.a(str); aVar.b(i); try { String a2 = o.a(16); String a3 = n.a(a2, n.a("MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCceeH8W34acRazDFnTbEhSEJj9GwyiwqDgDd3PKJIXmjzAWx+r+W/2Nl+jyw6lQuTXGIqwXvvu56laPiGZlGDwsZN4eNPv9i4GSYHgQH+ZC/SyEwOFq5YpbEgbYSKsrFt/QCX2S1NKGCbf5KwgvCW2lXUnSwmuURirFDVDEkyqIwIDAQAB")); JSONObject jSONObject = new JSONObject(); jSONObject.put("mobile", str); JSONObject b2 = b.a().b(); long uid = JCoreInterface.getUid(); aVar.a(uid); l.b("SmsCodeAction", "uid = " + uid); if (uid != 0) { b2.put("uid", uid); } jSONObject.put("extra", b2); String a4 = a(); String str4 = a4 + "/v3/sms/android/sms_code/"; if (i == 0) { jSONObject.put("temp_id", str3); jSONObject.put("sign_id", str2); } else if (i == 1) { str4 = a4 + "/v3/sms/android/voice_code/"; jSONObject.put("voice_lang", i2); } else { l.f("SmsCodeAction", "unknow type :" + i); } String str5 = Long.toString(Long.valueOf(System.currentTimeMillis()).longValue(), 32) + jSONObject.toString(); String a5 = cn.jiguang.verifysdk.f.e.a.a(str5, a2); l.b("SmsCodeAction", "body:" + str5); l.b("SmsCodeAction", "body_ser:" + a5); cn.jiguang.verifysdk.test.a.d(8001, "SMS:body请求体", str5); c.a().a(str, i, Long.valueOf(System.currentTimeMillis())); return a(aVar, str4, a3, a5); } catch (Throwable th) { th.printStackTrace(); aVar.a(PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED); aVar.c("其它未知错误:" + th); return aVar; } } private static String a() { return a; } private static void a(Context context, cn.jiguang.verifysdk.f.b.a aVar, cn.jiguang.verifysdk.f.a.a aVar2) { cn.jiguang.verifysdk.test.a.d(0, "response codeInfo", aVar); if (aVar.b() == 2000) { if (aVar.a() <= 0) { cn.jiguang.verifysdk.f.c.a aVar3 = new cn.jiguang.verifysdk.f.c.a(System.currentTimeMillis() / 1000); aVar3.a(aVar.e()); aVar3.b(context); } aVar2.a(aVar.e()); return; } if (aVar.d() != null && c.a().c(aVar.d(), aVar.c())) { c.a().b(aVar.d(), aVar.c()); } aVar2.a(aVar.b(), aVar.f()); } private static void a(h hVar, String str, String str2) { hVar.a("Android-Sms-Code-V1"); String str3 = JCoreInterface.getAppKey() + LogUtils.COLON + str; hVar.a("Authorization", "Basic " + Base64.encodeToString(str3.getBytes(), 10)); hVar.a("Content-Length", String.valueOf(str2.getBytes().length)); } public void run() { if (!r.d(this.d)) { this.c.a(PlaybackException.ERROR_CODE_PARSING_MANIFEST_MALFORMED, "手机号码无效"); Log.e("SmsCodeAction", "phonenum is invalid"); } else if (!d.a(this.b)) { this.c.a(2013, "无网络"); Log.e("SmsCodeAction", "no network connected"); } else { Long a2 = c.a().a(this.d, this.g); long j = 0; if (a2 != null) { j = a2.longValue(); } if (System.currentTimeMillis() - j < cn.jiguang.verifysdk.f.a.a) { cn.jiguang.verifysdk.f.a.a aVar = this.c; aVar.a(PlaybackException.ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED, "前后两次时间间隔不超过" + (cn.jiguang.verifysdk.f.a.a / 1000) + "s"); Log.e("SmsCodeAction", "please get code after " + (cn.jiguang.verifysdk.f.a.a / 1000) + "s every time"); return; } cn.jiguang.verifysdk.f.b.a a3 = a(this.d, this.f, this.e, this.g, this.h); l.b("SmsCodeAction", "codeInfo:" + a3); a(this.b, a3, this.c); } } } }