绒毛墙 v1.2.2版本的 MD5 值为:c016c327d19b09a996218d3acd478b85
以下内容为反编译后的 MpaasScanModule.java 源代码,内容仅作参考
package com.mpaas.uniapp.scan;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.text.TextUtils;
import com.alibaba.fastjson.JSONObject;
import com.alipay.android.phone.scancode.export.ScanCallback;
import com.alipay.android.phone.scancode.export.ScanRequest;
import com.alipay.android.phone.scancode.export.adapter.MPScan;
import com.alipay.mobile.common.logging.util.Base64;
import com.mpaas.project.aar.convert.converter.FinalRInit;
import com.taobao.weex.annotation.JSMethod;
import com.taobao.weex.bridge.JSCallback;
import com.taobao.weex.common.WXModule;
import com.taobao.weex.el.parse.Operators;
import com.taobao.weex.ui.component.WXImage;
import java.lang.reflect.Method;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.Signature;
import java.security.spec.X509EncodedKeySpec;
public class MpaasScanModule extends WXModule {
private static final String LICENSE_TAG = "mPaaSConfigLicense";
private static final String PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0VwrpV6ux/gYVyJqRH14BVRn8fnAs4gSi3UI83/AQFVVtchNmxh5oqlsUbLYyUbL5kBrKOizoDG0l4NCnkGkzDz02QL+rgbDU4vqtqjqT40iJwUfC1sRGLj26nDQJ/Qafb0qgMkynZWoTI807tz51RnNNxYf/TDlxSxnNwbWOt1Jevv9qv/J7l+0FCwGqnfyq+p9vKMkVYRvVf4bsZoWGneZMNhEKjAGzh/0/adfU3/FgQxEWGmQSGV8PHP26zRfqCJ7dfTRs02fTcTM3EPHcmIZ2GVo0f8+qRrCXf+cEG+dT0CPKMwTQW5XU+16IIRzsgbGMfSM9AB+ut02iKHVOQIDAQAB";
private static final String SIGNATURE_ALGORITHM = "SHA256withRSA";
private static final String VERSION = "1.0.0";
private static String checkBaseline = "";
private static String checkLicense = "";
private static boolean hasCheckBaseline = false;
private static boolean hasCheckConfig = false;
private static boolean hasCheckInstallMpaasScan = false;
private static boolean hasCheckLicense = false;
private static boolean hasConfig = false;
private static boolean hasInstallMpaasScan = false;
private ApplicationInfo mMetaDataAppInfo = null;
@JSMethod(uiThread = true)
public void mpaasScan(JSONObject jSONObject, final JSCallback jSCallback) {
try {
if (!(this.mWXSDKInstance.getContext() instanceof Activity)) {
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("resp_code", (Object) 11);
jSONObject2.put("resp_message", (Object) "mWXSDKInstance.getContext() is not activity.");
jSCallback.invoke(jSONObject2);
return;
}
final Activity activity = (Activity) this.mWXSDKInstance.getContext();
String check = check(activity);
if (!TextUtils.isEmpty(check)) {
new AlertDialog.Builder(activity).setMessage(check).setPositiveButton("确定", (DialogInterface.OnClickListener) null).create().show();
JSONObject jSONObject3 = new JSONObject();
jSONObject3.put("resp_code", (Object) 11);
jSONObject3.put("resp_message", (Object) check);
jSCallback.invoke(jSONObject3);
return;
}
FinalRInit.setR(activity.getApplicationContext());
ScanRequest scanRequest = new ScanRequest();
try {
scanRequest.setTranslucentStatusBar(true);
scanRequest.setScanType(ScanRequest.ScanType.QRCODE);
if (jSONObject.containsKey("type")) {
String string = jSONObject.getString("type");
if (!TextUtils.isEmpty(string)) {
if (ScanRequest.ScanType.BARCODE.name().equals(string)) {
scanRequest.setScanType(ScanRequest.ScanType.BARCODE);
}
if (ScanRequest.ScanType.QRCODE.name().equals(string)) {
scanRequest.setScanType(ScanRequest.ScanType.QRCODE);
}
}
}
if (jSONObject.containsKey("hideAlbum")) {
scanRequest.setNotSupportAlbum(jSONObject.getBoolean("hideAlbum").booleanValue());
}
scanRequest.setRecognizeType(ScanRequest.RecognizeType.BAR_CODE, ScanRequest.RecognizeType.QR_CODE, ScanRequest.RecognizeType.DM_CODE, ScanRequest.RecognizeType.PDF417_Code);
MPScan.startMPaasScanActivity(activity, scanRequest, new ScanCallback() {
@Override
public void onScanResult(boolean z, final Intent intent) {
if (!z) {
JSONObject jSONObject4 = new JSONObject();
jSONObject4.put("resp_code", (Object) 10);
jSONObject4.put("resp_message", (Object) "processed back");
jSCallback.invoke(jSONObject4);
return;
}
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
Intent intent2 = intent;
if (intent2 == null || intent2.getData() == null) {
JSONObject jSONObject5 = new JSONObject();
jSONObject5.put("resp_code", (Object) 11);
jSONObject5.put("resp_message", (Object) "url is null");
jSCallback.invoke(jSONObject5);
return;
}
String uri = intent.getData().toString();
JSONObject jSONObject6 = new JSONObject();
jSONObject6.put("resp_code", (Object) 1000);
jSONObject6.put("resp_message", (Object) WXImage.SUCCEED);
jSONObject6.put("resp_result", (Object) uri);
jSCallback.invoke(jSONObject6);
}
});
}
});
} catch (Exception e) {
JSONObject jSONObject4 = new JSONObject();
jSONObject4.put("resp_code", (Object) 11);
jSONObject4.put("resp_message", (Object) ("input param error: " + e));
jSCallback.invoke(jSONObject4);
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
private String check(Context context) {
if (hasInstallMpaasScan()) {
try {
Method method = Class.forName("com.alipay.android.phone.scancode.export.adapter.MPScan").getMethod("init", Context.class);
method.setAccessible(true);
method.invoke(null, context);
} catch (Exception e) {
e.printStackTrace();
}
if (hasConfig(context)) {
String checkLicense2 = checkLicense(context);
return !TextUtils.isEmpty(checkLicense2) ? checkLicense2 : "";
}
return "您没有配置 mPaaS Config 文件,请先参考接入文档配置并下载 Config。\n\n如有疑问,可以在钉钉上搜索 41708565 进群进行解答。";
}
return "您没有使用 mPaaS 插件添加扫码组件,请先参考文档,接入 mPaaS 扫码。\n\n如有疑问,可以在钉钉上搜索 41708565 进群进行解答。";
}
private boolean hasInstallMpaasScan() {
if (!hasCheckInstallMpaasScan) {
try {
try {
Class<?> cls = Class.forName("com.alipay.mobile.common.logging.api.LoggerFactory");
Class<?> cls2 = Class.forName("com.alipay.android.phone.scancode.export.adapter.MPScan");
if (cls != null && cls2 != null) {
hasInstallMpaasScan = true;
}
} catch (Exception unused) {
hasInstallMpaasScan = false;
}
} finally {
hasCheckInstallMpaasScan = true;
}
}
return hasInstallMpaasScan;
}
private boolean hasConfig(Context context) {
if (!hasCheckConfig) {
try {
try {
hasConfig = !TextUtils.isEmpty(getMetaData(context, "mobilegw.appid", ""));
} catch (Exception e) {
e.printStackTrace();
}
} finally {
hasCheckConfig = true;
}
}
return hasConfig;
}
private String checkLicense(Context context) {
if (hasCheckLicense) {
return checkLicense;
}
try {
String metaData = getMetaData(context, "mpaasConfigVersion", "");
String metaData2 = getMetaData(context, "mobilegw.appid", "");
String metaData3 = getMetaData(context, "workspaceId", "");
String packageName = context.getPackageName();
String metaData4 = getMetaData(context, "logging.gateway", "");
String metaData5 = getMetaData(context, "mpaasapi", "");
String metaData6 = getMetaData(context, "mpaasConfigEnv", "");
String metaData7 = getMetaData(context, "mpaasConfigPluginExpired", "");
String metaData8 = getMetaData(context, "mpaasConfigLicense", "");
String[] strArr = {"https://mdap.mpaas.cn-hangzhou.aliyuncs.com", "https://mpaasapi.mpaas.cn-hangzhou.aliyuncs.com/mgw.htm"};
if (!metaData2.startsWith("ONEX") && !metaData2.startsWith("ALIPUB")) {
checkLicense = "当前仅支持阿里云用户使用 mPaaS 扫码。\n\n如有疑问,可以在钉钉上搜索 41708565 进群进行解答。";
return "当前仅支持阿里云用户使用 mPaaS 扫码。\n\n如有疑问,可以在钉钉上搜索 41708565 进群进行解答。";
}
if (!TextUtils.isEmpty(metaData4) && !metaData4.equals(strArr[0]) && !TextUtils.isEmpty(metaData5) && !metaData5.equals(strArr[1])) {
checkLicense = "config 文件信息有误,请勿手动修改 config 内容。\n\n如有疑问,可以在钉钉上搜索 41708565 进群进行解答。";
return "config 文件信息有误,请勿手动修改 config 内容。\n\n如有疑问,可以在钉钉上搜索 41708565 进群进行解答。";
}
if (!TextUtils.isEmpty(metaData) && "V_1.0".endsWith(metaData)) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(metaData).append(Operators.ARRAY_SEPRATOR).append(metaData2).append(Operators.ARRAY_SEPRATOR).append(packageName).append(Operators.ARRAY_SEPRATOR).append("").append(Operators.ARRAY_SEPRATOR).append(metaData3).append(Operators.ARRAY_SEPRATOR).append(metaData4).append(Operators.ARRAY_SEPRATOR).append(metaData5).append(Operators.ARRAY_SEPRATOR).append(metaData6).append(Operators.ARRAY_SEPRATOR).append(metaData7);
String stringBuffer2 = stringBuffer.toString();
PublicKey publicKey = getPublicKey(PUBLIC_KEY);
Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);
signature.initVerify(publicKey);
signature.update(stringBuffer2.getBytes());
if (signature.verify(Base64.decode(metaData8))) {
checkLicense = "";
return "";
}
checkLicense = "您的 mPaaS Config License 验证失败。\n请确认您的 packageName 和您运行时的包名一致,且 Config 内容没有人为修改。\n\n如有疑问,可以在钉钉上搜索 41708565 进群进行解答。";
return "您的 mPaaS Config License 验证失败。\n请确认您的 packageName 和您运行时的包名一致,且 Config 内容没有人为修改。\n\n如有疑问,可以在钉钉上搜索 41708565 进群进行解答。";
}
checkLicense = "您的 config 版本为空,或不等于 V_1.0,暂时无法使用 mPaaS 扫码。\n\n如有疑问,可以在钉钉上搜索 41708565 进群进行解答。";
return "您的 config 版本为空,或不等于 V_1.0,暂时无法使用 mPaaS 扫码。\n\n如有疑问,可以在钉钉上搜索 41708565 进群进行解答。";
} catch (Exception e) {
String str = "验签过程发生异常:" + e + "\n\n如有疑问,可以在钉钉上搜索 41708565 进群进行解答。";
checkLicense = str;
return str;
} finally {
hasCheckLicense = true;
}
}
private ApplicationInfo getMetaDataAppInfo(Context context) {
ApplicationInfo applicationInfo = this.mMetaDataAppInfo;
if (applicationInfo != null) {
return applicationInfo;
}
try {
this.mMetaDataAppInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128);
} catch (Throwable th) {
th.printStackTrace();
}
return this.mMetaDataAppInfo;
}
private String getMetaData(Context context, String str, String str2) {
String string = getMetaDataAppInfo(context).metaData.getString(str);
return TextUtils.isEmpty(string) ? str2 : string;
}
private static PublicKey getPublicKey(String str) throws Exception {
return KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(Base64.decode(str.replace("\r", "").replace("\n", ""))));
}
private static byte[] hexStringToBytes(String str) {
if (TextUtils.isEmpty(str)) {
return null;
}
String lowerCase = str.toLowerCase();
byte[] bArr = new byte[lowerCase.length() >> 1];
int i = 0;
for (int i2 = 0; i2 < lowerCase.length() && i <= lowerCase.length() - 1; i2++) {
bArr[i2] = (byte) ((((byte) (Character.digit(lowerCase.charAt(i), 16) & 255)) << 4) | ((byte) (Character.digit(lowerCase.charAt(i + 1), 16) & 255)));
i += 2;
}
return bArr;
}
}