QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 LoginImpl.java 源代码,内容仅作参考
package com.tencent.ilivesdk.loginservice;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import com.tencent.falco.base.libapi.login.LoginCallback;
import com.tencent.falco.base.libapi.login.LoginInfo;
import com.tencent.falco.base.libapi.login.LoginServiceAdapter;
import com.tencent.falco.base.libapi.login.LoginType;
import com.tencent.falco.base.libapi.login.LogoutCallback;
import com.tencent.falco.utils.HexUtil;
import com.tencent.falco.utils.TimeUtil;
import com.tencent.mtt.hippy.qb.modules.offlineResource.HippyOfflineResourceZipUtils;
import com.tencent.thumbplayer.tplayer.plugins.report.TPReportKeys;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLConnection;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import org.json.JSONException;
import org.json.JSONObject;
public class LoginImpl {
protected final String f12831a = "https://test.ilive.qq.com/cgi-bin/core/platform_login/user_login";
protected final String f12832b = "https://ilive.qq.com/cgi-bin/core/platform_login/user_login";
protected String f12833c;
protected String f12834d;
protected String e;
protected String f;
protected String g;
protected String h;
protected LoginType i;
protected String j;
protected boolean k;
protected String l;
protected long m;
protected long n;
protected LoginServiceAdapter o;
protected LoginInfo p;
public static class AnonymousClass3 {
static final int[] f12841a = new int[LoginType.values().length];
static {
try {
f12841a[LoginType.QQ.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
f12841a[LoginType.WX.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
f12841a[LoginType.GUEST.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
}
}
class LoginException extends Exception {
final int errorCode;
final String errorMessage;
LoginException(int i, String str) {
super("errorCode==" + i + " errorMessage==" + str);
this.errorCode = i;
this.errorMessage = str;
}
}
public LoginImpl(LoginServiceAdapter loginServiceAdapter) {
this.o = loginServiceAdapter;
}
public LoginInfo a() {
return this.p;
}
public void a(final LoginCallback loginCallback) {
new Thread(new Runnable() {
@Override
public void run() {
LoginImpl loginImpl;
LoginCallback loginCallback2;
int i;
String str;
try {
try {
JSONObject jSONObject = new JSONObject(new String(LoginImpl.this.a(new URL(LoginImpl.this.k ? "https://test.ilive.qq.com/cgi-bin/core/platform_login/user_login" : "https://ilive.qq.com/cgi-bin/core/platform_login/user_login"), (byte[]) null)));
int i2 = jSONObject.getInt("retcode");
LoginImpl.this.o.a().c("LoginImpl", "retCode = " + i2, new Object[0]);
if (i2 != 0) {
LoginImpl.this.p = null;
LoginImpl.this.a(loginCallback, jSONObject.getInt("retcode"), "鉴权失败", (LoginInfo) null);
return;
}
JSONObject jSONObject2 = jSONObject.getJSONObject("result");
LoginImpl.this.p = new LoginInfo();
LoginImpl.this.p.f10862d = LoginImpl.this.f12833c;
LoginImpl.this.p.e = LoginImpl.this.f12834d;
LoginImpl.this.p.f = LoginImpl.this.f12833c;
String string = jSONObject2.getString("openid");
if (!TextUtils.isEmpty(string)) {
LoginImpl.this.p.f10862d = string;
}
LoginImpl.this.p.f10859a = jSONObject2.optLong("uid", 0L);
try {
LoginImpl.this.p.f10860b = Long.valueOf(jSONObject2.optString("tiny_id")).longValue();
} catch (Exception unused) {
LoginImpl.this.p.f10860b = 0L;
}
LoginImpl.this.p.f10861c = HexUtil.a(jSONObject2.optString("a2", ""));
LoginImpl.this.p.g = LoginImpl.this.i;
LoginImpl.this.p.h = jSONObject2.optString(HippyOfflineResourceZipUtils.FILE_CONFIG_NAME);
LoginImpl.this.m = TimeUtil.a() / 1000;
TimeUtil.a(jSONObject2.optLong("timestamp"));
LoginImpl.this.n = jSONObject2.optInt("a2_expire_time");
LoginImpl.this.o.a().c("LoginImpl", "lastLoginTime=" + LoginImpl.this.m + "a2ExpireTime=" + LoginImpl.this.n + ", loginInfo=" + LoginImpl.this.p.toString(), new Object[0]);
LoginImpl.this.a(loginCallback, 0, (String) null, LoginImpl.this.p.clone());
} catch (SocketTimeoutException e) {
e = e;
loginImpl = LoginImpl.this;
loginCallback2 = loginCallback;
i = -2;
str = "请求超时";
loginImpl.a(loginCallback2, i, e, str);
}
} catch (Exception e2) {
e = e2;
loginImpl = LoginImpl.this;
loginCallback2 = loginCallback;
i = -1;
str = "请求错误";
loginImpl.a(loginCallback2, i, e, str);
}
}
}).start();
}
public void a(LoginCallback loginCallback, int i, Exception exc, String str) {
this.o.a().e("LoginImpl", "doLogin with Exception : " + str, new Object[0]);
a(loginCallback, i, str, (LoginInfo) null);
exc.printStackTrace();
}
public void a(final LoginCallback loginCallback, final int i, final String str, final LoginInfo loginInfo) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
LoginInfo loginInfo2 = loginInfo;
if (loginInfo2 == null) {
loginCallback.a(i, str);
} else {
loginCallback.a(loginInfo2);
}
}
});
}
public void a(LogoutCallback logoutCallback) {
logoutCallback.a();
}
public void a(String str, String str2) {
this.o.a().c("LoginImpl", "setAuthTicket-> accountId=" + str, new Object[0]);
if (!TextUtils.equals(this.f12833c, str)) {
this.o.a().e("LoginImpl", "setAuthTicket-> Id has changed, oldId=" + this.f12833c + ", newId=" + str, new Object[0]);
}
this.f12833c = str;
this.f12834d = str2;
LoginInfo loginInfo = this.p;
if (loginInfo != null) {
loginInfo.f10862d = str;
loginInfo.e = str2;
}
}
public void a(boolean z, String str, String str2, String str3, String str4, String str5, String str6, LoginType loginType, String str7, String str8) {
this.f12833c = str;
this.f12834d = str2;
this.e = str3;
this.f = str4;
this.g = str5;
this.h = str6;
this.i = loginType;
this.j = str7;
this.l = str8;
this.k = z;
}
protected byte[] a(URL url, byte[] bArr) throws LoginException, Exception {
try {
URLConnection openConnection = url.openConnection();
if (!(openConnection instanceof HttpsURLConnection)) {
throw new IllegalStateException("URL不是Https协议的或彻底不正确.");
}
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) openConnection;
httpsURLConnection.setRequestMethod("POST");
httpsURLConnection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
httpsURLConnection.setConnectTimeout(30000);
httpsURLConnection.setReadTimeout(30000);
JSONObject jSONObject = new JSONObject();
jSONObject.put("account_id", this.f12833c);
jSONObject.put("client_type", this.f);
jSONObject.put(TPReportKeys.Common.COMMON_DEVICE_NAME, this.g);
jSONObject.put("auth_appid", this.e);
jSONObject.put("auth_key", this.f12834d);
jSONObject.put("version_code", this.h);
jSONObject.put("ext_data", b());
httpsURLConnection.setDoOutput(true);
DataOutputStream dataOutputStream = new DataOutputStream(httpsURLConnection.getOutputStream());
dataOutputStream.write(jSONObject.toString().getBytes());
dataOutputStream.flush();
dataOutputStream.close();
try {
try {
try {
try {
try {
httpsURLConnection.setSSLSocketFactory(SSLContext.getDefault().getSocketFactory());
int responseCode = httpsURLConnection.getResponseCode();
if (responseCode != 200) {
throw new Exception("请求服务器端失败, HTTP返回码:" + responseCode);
}
BufferedInputStream bufferedInputStream = new BufferedInputStream(httpsURLConnection.getInputStream());
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(1024);
while (true) {
int read = bufferedInputStream.read();
if (read == -1) {
byte[] byteArray = byteArrayOutputStream.toByteArray();
bufferedInputStream.close();
byteArrayOutputStream.close();
return byteArray;
}
byteArrayOutputStream.write(read);
}
} finally {
httpsURLConnection.disconnect();
}
} catch (IOException e) {
throw new Exception("IOException", e);
}
} catch (NoSuchAlgorithmException e2) {
throw new Exception("SSLContext算法设置错误", e2);
}
} catch (SocketTimeoutException unused) {
throw new SocketTimeoutException("请求超时");
}
} catch (KeyManagementException e3) {
throw new Exception("KeyManagementException", e3);
} catch (JSONException e4) {
throw new Exception("解析服务器返回Json发生错误", e4);
}
} catch (IOException e5) {
throw new Exception("打开连接出错", e5);
}
}
public String b() {
StringBuilder sb;
String str;
if (!TextUtils.isEmpty(this.j)) {
return this.j;
}
int i = AnonymousClass3.f12841a[this.i.ordinal()];
if (i == 1) {
sb = new StringBuilder();
str = "0:";
} else {
if (i != 2) {
return i != 3 ? "" : "sp_live_platform_guest";
}
sb = new StringBuilder();
str = "1:";
}
sb.append(str);
sb.append(this.l);
return sb.toString();
}
public void b(LoginCallback loginCallback) {
if (this.m != 0) {
long j = this.n;
if (j != 0) {
if (j <= 7200) {
j = 7200;
}
long a2 = TimeUtil.a() / 1000;
long j2 = this.m;
if (a2 - j2 <= 3600 || j - (a2 - j2) >= 604800) {
this.o.a().c("LoginImpl", "refreshLogin-> Don't need to refreshLogin, lastLoginTime=" + this.m + ", a2ExpireTime=" + this.n + ", miniRefreshTime=" + j, new Object[0]);
return;
}
this.o.a().c("LoginImpl", "refreshLogin-> start refreshLogin, lastLoginTime=" + this.m + ", a2ExpireTime=" + this.n + ", miniRefreshTime=" + j, new Object[0]);
a(loginCallback);
return;
}
}
this.o.a().e("LoginImpl", "refreshLogin-> fail, lastLoginTime=" + this.m + ", a2ExpireTime=" + this.n, new Object[0]);
}
}