百度手机卫士 v8.1.5版本的 MD5 值为:15af71eae74e2f2b5b9f845fe77a4804
以下内容为反编译后的 CMSFrontRestService.java 源代码,内容仅作参考
package com.dianxinos.cms.front.client;
import android.content.Context;
import com.baidu.security.plugin.alarm.AlarmUtil;
import com.quickbird.mini.vpn.vpn.VpnWatchdogThread;
import com.quickbird.sdk.internal.HttpsClient;
import dxoptimizer.aaa;
import dxoptimizer.aab;
import dxoptimizer.aad;
import dxoptimizer.aae;
import dxoptimizer.aaf;
import dxoptimizer.aah;
import dxoptimizer.aai;
import dxoptimizer.aaw;
import dxoptimizer.aba;
import dxoptimizer.abb;
import dxoptimizer.abc;
import dxoptimizer.abd;
import dxoptimizer.xo;
import dxoptimizer.xs;
import dxoptimizer.zu;
import dxoptimizer.zv;
import dxoptimizer.zw;
import dxoptimizer.zx;
import dxoptimizer.zy;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URI;
import java.security.PublicKey;
import java.util.Arrays;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.zip.GZIPInputStream;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIUtils;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.util.CharArrayBuffer;
import org.json.JSONException;
import org.json.JSONObject;
public class CMSFrontRestService {
private aae i;
private String j;
private Context k;
private String l;
private aab m;
private long n;
private static final String d = CMSFrontRestService.class.getName();
private static final PublicKey e = abb.a("91984037215497453715695537150101136180891052789697033543194092619618648264321686995125910645918307527361902207937849374278999247610081485346792920961341041235187112556183400885916498929543480156108595411929206248207390582439108464025592253754008974647620342386179132598251271296121068499378920392705867355039", "65537");
private static final Header f = new BasicHeader("Content-Encoding", "gzip");
private static final Header g = new BasicHeader("Accept-Encoding", "gzip");
public static String a = "10.18.102.104";
public static int b = 3724;
public static String c = "cms";
private static CMSFrontRestService h = null;
public enum Sort {
DEFAULT("sort"),
UPDATE("modifiedTime"),
DOWNLOAD("downloadCount");
private String field;
Sort(String str) {
this.field = str;
}
public String getField() {
return this.field;
}
public void setField(String str) {
this.field = str;
}
@Override
public String toString() {
return this.field;
}
}
public static void a(String str) {
if ("dev".equals(str)) {
a = "10.18.102.104";
b = 3724;
c = "cms";
aai.a = 2;
return;
}
if ("test".equals(str)) {
a = "sandbox.sjws.baidu.com";
b = 8080;
c = "cms";
aai.a = 2;
return;
}
if ("prod".equals(str)) {
a = "mk.jccjd.com";
b = 80;
c = "cf";
aai.a = 5;
return;
}
throw new IllegalArgumentException("bad env:" + str);
}
public static synchronized CMSFrontRestService a(Context context) {
CMSFrontRestService cMSFrontRestService;
synchronized (CMSFrontRestService.class) {
if (h == null) {
h = new CMSFrontRestService(context);
}
cMSFrontRestService = h;
}
return cMSFrontRestService;
}
private CMSFrontRestService(Context context) {
this(aaf.a(context), context);
}
private CMSFrontRestService(aae aaeVar, Context context) {
this.j = "862fe64a3f627a61727cd443ca79f1bf";
this.n = AlarmUtil.DAY;
this.i = aaeVar;
this.k = context;
this.l = xo.a(context);
this.m = new aab(2, 4, 60L, TimeUnit.SECONDS, new PriorityBlockingQueue(100), new ThreadPoolExecutor.DiscardOldestPolicy());
aba.a(aba.b(), aba.a(context));
}
public int a(URI uri, List list, aah aahVar, aad aadVar, boolean z) {
FileOutputStream fileOutputStream;
InputStream inputStream = null;
HttpResponse a2 = a(uri, list, false);
try {
int statusCode = a2.getStatusLine().getStatusCode();
if (statusCode != 200 && statusCode != 304) {
aahVar.a(statusCode, "NETWORK_FAIL");
} else if (statusCode == 200) {
aadVar.b = b(a2);
HttpEntity entity = a2.getEntity();
if (z) {
try {
File file = new File(aae.b, aadVar.a);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
fileOutputStream = new FileOutputStream(file);
} catch (Throwable th) {
th = th;
fileOutputStream = null;
}
try {
inputStream = entity.getContent();
Header contentEncoding = entity.getContentEncoding();
if (contentEncoding != null && contentEncoding.getValue().indexOf("gzip") != -1) {
inputStream = new GZIPInputStream(inputStream);
}
abd.a(inputStream, fileOutputStream);
abd.a(inputStream);
abd.a(fileOutputStream);
} catch (Throwable th2) {
th = th2;
abd.a(inputStream);
abd.a(fileOutputStream);
throw th;
}
} else {
aahVar.a(statusCode, entity.getContent());
}
}
return statusCode;
} finally {
a(a2);
}
}
public String b(String str) {
return str.substring(0, 2) + "/" + str.substring(2) + ".png";
}
public void a(String str, aah aahVar) {
aahVar.a(this.m.submit(new zu(this, str, aahVar)));
}
public int a(URI uri, List list, aah aahVar, zy zyVar, int i) {
if (i > 2) {
throw new IOException("Too much recursion:2");
}
HttpResponse a2 = a(uri, list, true);
try {
int statusCode = a2.getStatusLine().getStatusCode();
if (statusCode != 200 && statusCode != 304) {
aahVar.a(statusCode, "NETWORK_FAIL");
} else if (statusCode == 200) {
JSONObject c2 = c(a2);
JSONObject jSONObject = c2.getJSONObject("responseHeader");
zyVar.b = jSONObject;
statusCode = jSONObject.getInt(VpnWatchdogThread.VPN_WATCHDOG_STATUS);
if (statusCode == 200) {
zyVar.a = c2.getJSONObject("response");
zyVar.c = b(a2);
} else {
if (statusCode == 403) {
c();
int i2 = i + 1;
statusCode = a(uri, list, aahVar, zyVar, i);
return statusCode;
}
aahVar.a(statusCode, jSONObject.optString("msg"));
}
}
return statusCode;
} finally {
a(a2);
}
}
private void a(HttpResponse httpResponse) {
if (httpResponse != null && httpResponse.getEntity() != null) {
try {
httpResponse.getEntity().consumeContent();
} catch (Exception e2) {
aai.a(d, "failed to cosume entity", e2);
}
}
}
public void a(long j, long j2, long[] jArr, int i, aah aahVar) {
aahVar.a(this.m.submit(new zv(this, j, j2, i, jArr, aahVar)));
}
public int b(URI uri, List list, aah aahVar, zy zyVar, int i) {
if (i > 2) {
throw new IOException("Too much recursion:2");
}
HttpResponse a2 = a(uri, list, true);
try {
int statusCode = a2.getStatusLine().getStatusCode();
if (statusCode != 200 && statusCode != 304) {
aahVar.a(statusCode, "NETWORK_FAIL");
} else if (statusCode == 200) {
JSONObject c2 = c(a2);
JSONObject jSONObject = c2.getJSONObject("responseHeader");
zyVar.b = jSONObject;
statusCode = jSONObject.getInt(VpnWatchdogThread.VPN_WATCHDOG_STATUS);
if (statusCode == 200) {
zyVar.a = c2.getJSONObject("response");
zyVar.c = b(a2);
} else {
if (statusCode == 403) {
c();
int i2 = i + 1;
statusCode = b(uri, list, aahVar, zyVar, i);
return statusCode;
}
aahVar.a(statusCode, jSONObject.optString("msg"));
}
}
return statusCode;
} finally {
a(a2);
}
}
public void a(long j, long j2, long j3, int i, int i2, Sort sort, aah aahVar) {
aahVar.a(this.m.submit(new zw(this, j, j2, j3, i, i2, sort, aahVar)));
}
public int c(URI uri, List list, aah aahVar, zy zyVar, int i) {
if (i > 2) {
throw new IOException("Too much recursion:2");
}
HttpResponse a2 = a(uri, list, true);
try {
int statusCode = a2.getStatusLine().getStatusCode();
if (statusCode != 200 && statusCode != 304) {
aahVar.a(statusCode, "NETWORK_FAIL");
} else if (statusCode == 200) {
JSONObject c2 = c(a2);
JSONObject jSONObject = c2.getJSONObject("responseHeader");
zyVar.b = jSONObject;
statusCode = jSONObject.getInt(VpnWatchdogThread.VPN_WATCHDOG_STATUS);
if (statusCode == 200) {
zyVar.a = c2.getJSONObject("response");
zyVar.c = b(a2);
} else {
if (statusCode == 403) {
c();
int i2 = i + 1;
statusCode = c(uri, list, aahVar, zyVar, i);
return statusCode;
}
aahVar.a(statusCode, jSONObject.optString("msg"));
}
}
return statusCode;
} finally {
a(a2);
}
}
public void a(long j, long j2, long j3, long j4, int i, aah aahVar) {
a(j, j2, j3, j4, i, (String) null, aahVar);
}
public void a(long j, long j2, long j3, long j4, int i, String str, aah aahVar) {
aahVar.a(this.m.submit(new zx(this, j, j2, j3, j4, i, str, aahVar)));
}
public int d(URI uri, List list, aah aahVar, zy zyVar, int i) {
if (i > 2) {
throw new IOException("Too much recursion:2");
}
HttpResponse a2 = a(uri, list, true);
try {
int statusCode = a2.getStatusLine().getStatusCode();
if (statusCode != 200 && statusCode != 304) {
aahVar.a(statusCode, "NETWORK_FAIL");
} else if (statusCode == 200) {
JSONObject c2 = c(a2);
JSONObject jSONObject = c2.getJSONObject("responseHeader");
zyVar.b = jSONObject;
statusCode = jSONObject.getInt(VpnWatchdogThread.VPN_WATCHDOG_STATUS);
if (statusCode == 200) {
zyVar.a = c2.getJSONObject("response");
zyVar.c = b(a2);
} else {
if (statusCode == 403) {
c();
int i2 = i + 1;
statusCode = d(uri, list, aahVar, zyVar, i);
return statusCode;
}
aahVar.a(statusCode, jSONObject.optString("msg"));
}
}
return statusCode;
} finally {
a(a2);
}
}
private synchronized void c() {
URI createURI = URIUtils.createURI("http", a, b, c + "/rs", this.l, null);
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("ms", System.currentTimeMillis());
jSONObject.put("tk", xs.a(this.k));
} catch (JSONException e2) {
e2.printStackTrace();
}
HttpResponse a2 = a(createURI, new String(aaw.b(abb.a(jSONObject.toString(), e), 0)), (List) null);
try {
int statusCode = a2.getStatusLine().getStatusCode();
if (statusCode == 200) {
JSONObject c2 = c(a2);
JSONObject jSONObject2 = c2.getJSONObject("responseHeader");
int i = jSONObject2.getInt(VpnWatchdogThread.VPN_WATCHDOG_STATUS);
if (i == 200) {
this.j = new JSONObject(new String(abb.a(aaw.a(c2.getJSONObject("response").getString("session"), 0), e))).getString("sid");
} else {
throw new IOException("failed to get sid,status:" + i + ",msg:" + jSONObject2.optString("msg"));
}
} else {
throw new IOException("failed to get sid,status:" + statusCode);
}
} finally {
a(a2);
}
}
public void a() {
aba.a();
this.m.shutdownNow();
this.i.a();
d();
}
private static synchronized void d() {
synchronized (CMSFrontRestService.class) {
h = null;
}
}
private static long b(HttpResponse httpResponse) {
Header firstHeader = httpResponse.getFirstHeader("Last-Modified");
if (firstHeader != null) {
return abd.b(firstHeader.getValue()).getTime();
}
return 0L;
}
public static Header b(long j) {
return new BasicHeader("If-Modified-Since", abd.a(new Date(j)));
}
private static JSONObject c(HttpResponse httpResponse) {
HttpEntity entity = httpResponse.getEntity();
InputStream content = entity.getContent();
int contentLength = (int) entity.getContentLength();
int i = contentLength >= 0 ? contentLength : 1024;
Header contentEncoding = entity.getContentEncoding();
InputStreamReader inputStreamReader = new InputStreamReader((contentEncoding == null || contentEncoding.getValue().indexOf("gzip") == -1) ? content : new GZIPInputStream(content), HttpsClient.HTTP_CHARSET);
try {
CharArrayBuffer charArrayBuffer = new CharArrayBuffer(i);
char[] cArr = new char[1024];
while (true) {
int read = inputStreamReader.read(cArr);
if (read != -1) {
charArrayBuffer.append(cArr, 0, read);
} else {
return new JSONObject(charArrayBuffer.toString());
}
}
} finally {
abd.a(inputStreamReader);
}
}
private HttpResponse a(URI uri, String str, List list) {
String uri2 = uri.toString();
if (uri2.indexOf(63) > 0) {
uri2 = uri2 + "&sid=" + this.j + "&cv=1.0&cflv=" + aaa.a();
}
HttpPost httpPost = new HttpPost(uri2);
if (list != null) {
Iterator it = list.iterator();
while (it.hasNext()) {
httpPost.addHeader((Header) it.next());
}
}
httpPost.addHeader(f);
httpPost.addHeader(g);
httpPost.setEntity(new ByteArrayEntity(abd.c(str)));
aai.a(d, "request uri:" + httpPost.getURI() + ",body:" + str + ",headers:" + Arrays.asList(httpPost.getAllHeaders()));
httpPost.getParams().setParameter("http.socket.timeout", 20000);
DefaultHttpClient b2 = aba.b();
try {
try {
abc.a(81921);
return b2.execute(httpPost);
} catch (IOException e2) {
httpPost.abort();
throw e2;
}
} finally {
abc.a();
}
}
private HttpResponse a(URI uri, List list, boolean z) {
String uri2 = uri.toString();
if (uri2.indexOf(63) > 0) {
uri2 = uri2 + "&sid=" + this.j + "&cv=1.0&cflv=" + aaa.a();
}
HttpGet httpGet = new HttpGet(uri2);
if (list != null) {
Iterator it = list.iterator();
while (it.hasNext()) {
httpGet.addHeader((Header) it.next());
}
}
if (z) {
httpGet.addHeader(g);
}
aai.a(d, "request uri: " + httpGet.getURI() + ", headers: " + Arrays.asList(httpGet.getAllHeaders()));
httpGet.getParams().setParameter("http.socket.timeout", 20000);
DefaultHttpClient b2 = aba.b();
try {
try {
abc.a(81920);
return b2.execute(httpGet);
} catch (IOException e2) {
httpGet.abort();
throw e2;
}
} finally {
abc.a();
}
}
}