CarrotChat v2.8.60.240131版本的 MD5 值为:2baf8b9f31830b86b5c5a85ae6b47e05
以下内容为反编译后的 b.java 源代码,内容仅作参考
package com.kinggrid.commonrequestauthority;
import android.annotation.SuppressLint;
import android.content.Context;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import android.util.SparseArray;
import com.kinggrid.iapppdf.droids.mupdf.codec.cosobject.PdfBoolean;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import org.apache.commons.httpclient.cookie.CookieSpec;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.Node;
public class b extends AppRegister {
private static String G;
private static String J;
private static String K;
private static File N;
private static b ae;
private String H;
private String I;
private l L;
private String M;
private String O = "";
private String P = "";
private String Q = "";
private String R = "";
private String S = "";
private String T = "0";
private String U = "http://www.kinggrid.com:8080/iWebRegister/register/app2Register.htm?os=1&UUID=";
private String V = "http://www.kinggrid.com:8080/iWebRegister/register/app2RegisterVerify.htm?os=1&UUID=";
private boolean W = true;
private boolean X = true;
private String Y;
private String Z;
private String aa;
private String ab;
private String ac;
private boolean ad;
private b(Context context, String str, String str2, String str3, String str4, String str5, String str6) {
this.ab = "";
this.H = f.a(context);
this.Y = f.b(context);
this.Z = f.d(context);
this.aa = f.c(context);
this.I = str5;
if (!TextUtils.isEmpty(str)) {
G = str;
}
if (!TextUtils.isEmpty(str2)) {
AppRegister.licFilePath = str2;
}
if (!TextUtils.isEmpty(str3)) {
J = str3;
}
if (!TextUtils.isEmpty(str4)) {
K = str4;
}
if (!TextUtils.isEmpty(str6)) {
this.ab = str6;
}
a();
}
public static b a(Context context, String str, String str2, String str3, String str4, String str5, String str6) {
if (ae == null || !G.equals(str) || !J.equals(str3)) {
ae = new b(context, str, str2, str3, str4, str5, str6);
}
return ae;
}
private SparseArray<String> b() {
if (AppRegister.DEBUG) {
Log.v(AppRegister.TAG, "file.exists()==" + N.exists());
}
if (N.exists()) {
l lVar = this.L;
if (lVar != null) {
if (J.equalsIgnoreCase(lVar.j()) && this.P.equals(this.L.g())) {
if (AppRegister.DEBUG) {
Log.v(AppRegister.TAG, "解码成功:" + J + "---" + this.L.j() + ",and licType is " + this.P + "---" + this.L.g());
}
return d();
} else if (AppRegister.DEBUG) {
Log.v(AppRegister.TAG, "file.exists,and responceLic is not null,but match failed: productTypeValue is " + J + "---" + this.L.j() + ",and licType is " + this.P + "---" + this.L.g());
}
} else if (AppRegister.DEBUG) {
Log.v(AppRegister.TAG, "file.exists,but responceLic is null ");
}
return c();
}
return c();
}
private SparseArray<String> c() {
SparseArray<String> sparseArray = new SparseArray<>();
int a = f.a() ? a(false, false) : 106;
StringBuilder sb = new StringBuilder(String.valueOf("" + getAuthorizationType(this.P) + ","));
sb.append(this.S);
sb.append(",");
String sb2 = sb.toString();
if (a == 200) {
sb2 = String.valueOf(sb2) + this.validTime;
} else if (a == 201) {
sb2 = String.valueOf(sb2) + this.validTime;
} else if (a == 300) {
sb2 = String.valueOf(sb2) + this.M;
}
if (AppRegister.DEBUG) {
Log.v(AppRegister.TAG, "doAppRegister_hasLicCode_and_noLicFile(),code==" + a + ",value==" + sb2);
}
sparseArray.put(a, sb2);
return sparseArray;
}
private SparseArray<String> d() {
int i;
String str;
SparseArray<String> sparseArray = new SparseArray<>();
if (this.L != null) {
i = d(this.P);
if (AppRegister.DEBUG) {
Log.v(AppRegister.TAG, "doAppRegister_hasLicCode_and_hasLicFile,code_key==" + i);
}
String str2 = "";
if (i != 113) {
if (i == 300) {
str2 = this.M;
} else if (i == 200) {
StringBuilder sb = new StringBuilder(String.valueOf("" + getAuthorizationType(this.P) + ","));
sb.append(f.b(this.L.d()));
sb.append(",");
str = String.valueOf(sb.toString()) + this.validTime;
} else if (i == 201) {
StringBuilder sb2 = new StringBuilder(String.valueOf("" + getAuthorizationType(this.P) + ","));
sb2.append(f.b(this.L.d()));
sb2.append(",");
str = String.valueOf(sb2.toString()) + this.validTime;
}
str = str2;
} else {
StringBuilder sb3 = new StringBuilder(String.valueOf("" + getAuthorizationType(this.P) + ","));
sb3.append(f.b(this.L.d()));
sb3.append(",");
str = String.valueOf(sb3.toString()) + this.validTime;
}
} else {
if (AppRegister.DEBUG) {
Log.v(AppRegister.TAG, "doAppRegister_hasLicCode_and_hasLicFile() responceLic is null");
}
i = 109;
str = "本地授权文件异常,请手动删除后再操作!";
}
sparseArray.put(i, str);
return sparseArray;
}
private boolean e() {
l lVar = this.L;
if (lVar != null) {
try {
this.W = lVar.d().trim().equals(this.O.trim());
boolean c2 = c(this.L.e().trim());
this.X = c2;
if (!this.W) {
Log.v(AppRegister.TAG, "File companySn:" + this.L.d().trim() + "==App companySn:" + this.O.trim());
} else if (!c2) {
Log.v(AppRegister.TAG, "File hardSn:" + this.L.e().trim() + "==App hardSn:" + this.H.trim());
}
if (this.W) {
return this.X;
}
return false;
} catch (Exception e2) {
Log.v(AppRegister.TAG, "checkCompanyIsOK failed,error info:" + e2.toString());
return false;
}
}
return false;
}
private int f() {
if (a(false)) {
long j = this.validTime;
if (j > 30 || j == -1) {
return 201;
}
if (this.ad) {
return 200;
}
this.ad = true;
if (f.a()) {
return a(false, true);
}
return 113;
} else if (this.validTime == -10000) {
return 111;
} else {
if (this.W && this.X) {
if (f.a()) {
return a(false, true);
}
return 112;
}
return 105;
}
}
private int g() {
if (e()) {
this.validTime = -1L;
return 201;
}
return 105;
}
@Override
public SparseArray<String> doInBackground(Void... voidArr) {
if (!TextUtils.isEmpty(G)) {
if (AppRegister.DEBUG) {
Log.v(AppRegister.TAG, "doAppRegister(...) has licCode");
}
return a(G);
}
SparseArray<String> sparseArray = new SparseArray<>();
sparseArray.put(107, "");
return sparseArray;
}
private void a() {
File file = new File(AppRegister.licFilePath);
N = file;
if (file.exists()) {
this.L = f.a(f.a(N), true, J);
}
}
private SparseArray<String> a(String str) {
Document a;
SparseArray<String> sparseArray = new SparseArray<>();
try {
String b2 = h.b(str, k.f11918b, 0);
if (!TextUtils.isEmpty(b2) && (a = o.a().a(b2)) != null) {
String text = a.selectSingleNode("/k/b/csn").getText();
this.O = text;
this.S = f.b(text);
this.P = a.selectSingleNode("/k/p[pc=" + J + "]/pt").getText();
this.R = a.selectSingleNode("/k/p[pc=" + J + "]/ed").getText();
this.Q = J;
K = this.P;
this.ac = a.selectSingleNode("/k/p[pc=" + J + "]/ssn").getText();
}
} catch (Exception e2) {
Log.e(AppRegister.TAG, "doAppRegister_hasLicCode(...) error:" + e2.toString());
}
if (AppRegister.DEBUG) {
Log.v(AppRegister.TAG, "licType:" + this.P + ",expireDate:" + this.R + ",companyName:" + this.S);
}
int i = 110;
String str2 = "";
if (!TextUtils.isEmpty(this.P)) {
StringBuilder sb = new StringBuilder(String.valueOf("" + getAuthorizationType(this.P) + ","));
sb.append(this.S);
sb.append(",");
str2 = sb.toString();
if (this.P.equals("2")) {
i = 202;
} else if (this.P.equals("3")) {
long a2 = f.a(this.R.replaceAll("-", CookieSpec.PATH_DELIM), f.a(k.f11919c));
if (AppRegister.DEBUG) {
Log.v(AppRegister.TAG, "validDays:" + a2);
}
if (a2 >= 1 || this.validTime == -1) {
this.validTime = a2;
i = (a2 > 30 || a2 == -1) ? 201 : 200;
str2 = String.valueOf(str2) + this.validTime;
} else {
i = 100;
}
} else if (this.P.equals("1")) {
return b();
} else {
if (this.P.equals("0")) {
if (!TextUtils.isEmpty(this.ac)) {
if (AppRegister.DEBUG) {
Log.i(AppRegister.TAG, "唯一码不为空,可能执行离线授权");
}
return a(this.ac, this.S);
}
if (AppRegister.DEBUG) {
Log.i(AppRegister.TAG, "永久许可,唯一码为空,走正常授权流程");
}
return b();
}
}
}
sparseArray.put(i, str2);
return sparseArray;
}
private boolean c(String str) {
if (str != null) {
boolean equals = str.equals(this.Y);
if (!equals) {
equals = str.equals(this.Z);
}
return !equals ? str.equals(this.aa) : equals;
}
return false;
}
private int d(String str) {
if (str.equals("1")) {
return f();
}
if (str.equals("0")) {
return g();
}
if (AppRegister.DEBUG) {
Log.v(AppRegister.TAG, "doAppRegister_hasLicCode_and_hasLicFile_and_hasLicType is other");
return 0;
}
return 0;
}
private String b(String str) {
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
httpURLConnection.setUseCaches(false);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setConnectTimeout(3000);
httpURLConnection.setReadTimeout(5000);
return f.a(httpURLConnection.getInputStream());
} catch (Exception e2) {
Log.e(AppRegister.TAG, "requestAuthority(...) error:" + e2.toString());
return null;
}
}
@SuppressLint({"NewApi"})
private SparseArray<String> a(String str, String str2) {
String str3;
SparseArray<String> sparseArray = new SparseArray<>();
String str4 = "";
int i = 301;
if (TextUtils.isEmpty(str)) {
str4 = "离线授权唯一码为空";
} else if (TextUtils.isEmpty(this.ab)) {
str4 = "离线授权服务器地址为空";
} else {
try {
String encodeToString = Base64.encodeToString(str2.getBytes("UTF-8"), 2);
str3 = b(String.valueOf(this.ab) + "?username=" + encodeToString);
} catch (UnsupportedEncodingException e2) {
Log.e(AppRegister.TAG, "doOffLineAuth:" + e2.toString());
str3 = "";
}
if (TextUtils.isEmpty(str3)) {
str4 = "离线授权服务器返回数据为空,请检查网络后重试";
} else if (str.equals(str3)) {
i = 203;
} else {
if (AppRegister.DEBUG) {
Log.i(AppRegister.TAG, "不匹配:" + str + "===" + str3);
}
str4 = "离线授权检测不通过";
}
}
sparseArray.put(i, str4);
return sparseArray;
}
private int a(boolean z, boolean z2) {
String a;
if (AppRegister.DEBUG) {
Log.d(AppRegister.TAG, "hardSn = " + this.H + ", androidId = " + this.aa);
}
String a2 = a(PdfBoolean.TRUE, "false");
if (AppRegister.DEBUG) {
Log.i(AppRegister.TAG, "判断是否注册过,result = " + a2);
}
if (a2.equals(PdfBoolean.TRUE)) {
a = a("false", PdfBoolean.TRUE);
} else {
a = a("false", "false");
}
if (a.equals(PdfBoolean.TRUE)) {
return a(false, 102);
}
if (z) {
Log.i(AppRegister.TAG, "failed:" + a + ",and read the local file.");
return a(false, 103);
}
this.M = a;
return 300;
}
private String a(String... strArr) {
String str;
String str2;
String b2;
int i;
String str3 = PdfBoolean.TRUE;
new c().a(c.a);
try {
n nVar = new n();
nVar.a("2.0");
nVar.g("WDDSED12KINGGRID");
nVar.b(this.O);
if (!strArr[0].equals(PdfBoolean.TRUE) && !strArr[1].equals(PdfBoolean.TRUE)) {
nVar.c(c.a(this.H.getBytes("UTF-8")));
nVar.p("1");
nVar.h(c.a(this.I.getBytes("UTF-8")));
nVar.i(f.a("yyyyMMddHHmmsss"));
nVar.j(J);
nVar.k(K);
nVar.l(this.T);
str = new String(h.a(o.a().a(nVar), k.a, 0), "UTF-8");
str2 = String.valueOf(!strArr[0].equals(PdfBoolean.TRUE) ? this.V : this.U) + f.a("yyyyMMddHHmmsss");
b2 = f.b(str, str2, "requestStr=");
for (i = 0; i < 10 && TextUtils.isEmpty(b2); i++) {
b2 = f.b(str, str2, "requestStr=");
try {
Thread.sleep(1000L);
} catch (InterruptedException unused) {
}
}
if (TextUtils.isEmpty(b2)) {
l lVar = new l(b2, true, J);
this.L = lVar;
try {
if (lVar.b().equals("1")) {
if (AppRegister.DEBUG) {
Log.v(AppRegister.TAG, "注册成功!过期日期:" + this.L.i());
}
if (strArr[0].equals("false")) {
if (!new File(AppRegister.licFilePath).exists()) {
f.a(AppRegister.licFilePath, b2.getBytes("UTF-8"));
return PdfBoolean.TRUE;
}
String b3 = h.b(f.a(new File(AppRegister.licFilePath)), k.a, 0);
if (b3 == null) {
f.a(AppRegister.licFilePath, b2.getBytes("UTF-8"));
return PdfBoolean.TRUE;
}
Document a = o.a().a(b3);
Node selectSingleNode = a.selectSingleNode("/ks/k/rp[rpc=" + this.Q + "]");
if (selectSingleNode != null) {
selectSingleNode.selectSingleNode("rt").setText(this.L.g());
selectSingleNode.getParent().selectSingleNode("rr/rd").setText(this.L.h());
selectSingleNode.getParent().selectSingleNode("rr/ed").setText(this.L.i());
} else {
a.getRootElement().add((Element) o.a().a(h.b(b2, k.a, 0)).selectSingleNode("/ks/k").clone());
}
f.a(AppRegister.licFilePath, h.a(a.asXML(), k.a, 0));
return PdfBoolean.TRUE;
}
return PdfBoolean.TRUE;
}
String c2 = this.L.c();
Log.e(AppRegister.TAG, "注册失败!错误信息:" + this.L.c());
return c2;
} catch (UnsupportedEncodingException e2) {
e = e2;
e.printStackTrace();
return str3;
} catch (Exception e3) {
e = e3;
e.printStackTrace();
return str3;
}
}
return "服务器返回注册数据为空";
}
nVar.c(c.a(this.aa.getBytes("UTF-8")));
nVar.p("1");
nVar.h(c.a(this.I.getBytes("UTF-8")));
nVar.i(f.a("yyyyMMddHHmmsss"));
nVar.j(J);
nVar.k(K);
nVar.l(this.T);
str = new String(h.a(o.a().a(nVar), k.a, 0), "UTF-8");
str2 = String.valueOf(!strArr[0].equals(PdfBoolean.TRUE) ? this.V : this.U) + f.a("yyyyMMddHHmmsss");
b2 = f.b(str, str2, "requestStr=");
while (i < 10) {
b2 = f.b(str, str2, "requestStr=");
Thread.sleep(1000L);
}
if (TextUtils.isEmpty(b2)) {
}
} catch (UnsupportedEncodingException e4) {
e = e4;
str3 = "";
} catch (Exception e5) {
e = e5;
str3 = "";
}
}
private int a(boolean z, int i) {
if (a(z)) {
long j = this.validTime;
return (j > 30 || j == -1) ? 201 : 200;
} else if (this.validTime == -10000) {
return 111;
} else {
return i;
}
}
private boolean a(boolean z) {
if ((z || e()) && this.L != null) {
String a = f.a(k.f11919c);
String a2 = f.a(this.L, this.P);
String b2 = f.b(this.L, this.P);
if (AppRegister.DEBUG) {
Log.v(AppRegister.TAG, "currentTime" + a + "====xmlTime:" + a2 + "regTime = " + b2);
}
if (a2.equals(PdfBoolean.TRUE)) {
this.validTime = -1L;
} else {
long a3 = f.a(a2, a, b2);
if (a3 == -10000) {
this.validTime = -10000L;
}
if (AppRegister.DEBUG) {
Log.v(AppRegister.TAG, "validDays:" + a3);
}
if (a3 < 1) {
return false;
}
this.validTime = a3;
}
return true;
}
return false;
}
}