导航菜单

页面标题

页面副标题

Cashalo v2.25.0.0 - b.java 源代码

正在查看: Cashalo v2.25.0.0 应用的 b.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.intsig.view;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.Signature;
import android.os.Build;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.view.KeyCharacterMap;
import android.view.ViewConfiguration;
import com.fullstory.FS;
import com.google.firebase.messaging.Constants;
import com.google.firebase.perf.FirebasePerformance;
import com.intsig.scanner.CommonUtil;
import com.intsig.scanner.ScannerEngine;
import com.iterable.iterableapi.IterableConstants;
import com.oriente.adapter.widget.timepickerview.lib.MessageHandler;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import javax.net.ssl.HttpsURLConnection;
import org.json.JSONObject;

public class b {
    public static final int AUTH_SUCCESS = 0;
    public static final int ERROR_APP = 205;
    public static final int ERROR_APP_KEY = 102;
    public static final int ERROR_DEVICE_NUM_LIMITED = 104;
    public static final int ERROR_EXPIRED = 103;
    public static final int ERROR_INNER = 202;
    public static final int ERROR_PACKAGENAME = 101;
    public static final int ERROR_SIGNATURE = 201;
    public static final int INTERNET_ERROR = 204;
    public static final int SERVER_ERROR = 203;
    private static final String TAG = "SDK";
    public static final String VERSION = "1.0.10.20170505";
    static String sVendorId = "IntSig";
    String appKey;
    SharedPreferences mStorage;
    String pkg;
    String sClientId;
    String signature;
    private final String PREFERENCE_NAME = "IDCardScanSDK";
    private final String KEY_DEVICEID = "DEVICEID";
    private final String KEY_AUTHINFO = "AUTHINFO";
    protected boolean mCheckAvaiable = false;
    private String mSecret = "";
    final int TYPE_NO_REPORT = 0;
    final int TYPE_REPORT_EVERY_TIME = 1;
    final int TYPE_REPORT_AFTER_YEAR = 2;
    final int TYPE_REPORT_EVERY_WEEK = 3;
    int type_of_report = 0;
    final String sSdkName = "IDCardSDK";
    private String aesKeyValueString = "4545312";
    private final String KEY_AUTHINFO_OPEN = "AUTHINFOOPEN";

    public int authAndPostData(Context context, String str, String str2, String str3, SharedPreferences sharedPreferences) {
        String str4;
        HttpsURLConnection httpsURLConnection;
        HttpsURLConnection httpsURLConnection2 = null;
        try {
            try {
                str4 = "app_id:" + str + "\ndevice_id:" + getDeviceId(context) + "\napp_key:" + str2;
                String str5 = "https://bcrs.intsig.net/bcr/BCRSDK_Update_Usage_2?app_key=" + str2 + "&app_id=" + str;
                FS.log_d("Test---HTTP--urlStr", new StringBuilder(String.valueOf(str5)).toString());
                FS.log_d("Test---HTTP--postData", new StringBuilder(String.valueOf(str4)).toString());
                CommonUtil.webLoginfo = String.valueOf(CommonUtil.webLoginfo) + str4 + "\n" + str5;
                httpsURLConnection = (HttpsURLConnection) FS.urlconnection_wrapInstance(new URL(str5).openConnection());
            } catch (Throwable th) {
                th = th;
            }
        } catch (UnknownHostException e) {
            e = e;
        } catch (Exception e2) {
            e = e2;
        }
        try {
            httpsURLConnection.setRequestMethod(FirebasePerformance.HttpMethod.POST);
            httpsURLConnection.getOutputStream().write(str4.getBytes());
            int responseCode = httpsURLConnection.getResponseCode();
            CommonUtil.webLoginfo = String.valueOf(CommonUtil.webLoginfo) + "\n" + responseCode + "\n";
            FS.log_d("Test---HTTP--CODE", new StringBuilder(String.valueOf(responseCode)).toString());
            if (responseCode != 200) {
                if (httpsURLConnection != null) {
                    httpsURLConnection.disconnect();
                }
                return responseCode;
            }
            String readContent = readContent(httpsURLConnection.getInputStream());
            CommonUtil.webLoginfo = String.valueOf(CommonUtil.webLoginfo) + readContent + "\n";
            saveAuthInfo(readContent, sharedPreferences);
            int authCheck = authCheck(readContent, str3, context, str, str2, true);
            if (httpsURLConnection != null) {
                httpsURLConnection.disconnect();
            }
            return authCheck;
        } catch (UnknownHostException e3) {
            e = e3;
            httpsURLConnection2 = httpsURLConnection;
            CommonUtil.webLoginfo = String.valueOf(CommonUtil.webLoginfo) + e.getMessage() + "\n";
            if (httpsURLConnection2 != null) {
                httpsURLConnection2.disconnect();
            }
            return 204;
        } catch (Exception e4) {
            e = e4;
            httpsURLConnection2 = httpsURLConnection;
            CommonUtil.webLoginfo = String.valueOf(CommonUtil.webLoginfo) + e.getMessage() + "\n";
            e.printStackTrace();
            if (httpsURLConnection2 != null) {
                httpsURLConnection2.disconnect();
            }
            return 204;
        } catch (Throwable th2) {
            th = th2;
            httpsURLConnection2 = httpsURLConnection;
            if (httpsURLConnection2 != null) {
                httpsURLConnection2.disconnect();
            }
            throw th;
        }
    }

    public int authAndPostDataApi(Context context, String str, String str2, String str3, SharedPreferences sharedPreferences) {
        String str4;
        HttpsURLConnection httpsURLConnection;
        HttpsURLConnection httpsURLConnection2 = null;
        try {
            try {
                str4 = "app_id:" + str + "\ndevice_id:" + getDeviceId(context) + "\napp_key:" + str2;
                String str5 = "https://bcrs.intsig.net/bcr/BCRSDK_Update_Usage_2?app_key=" + str2 + "&app_id=" + str;
                CommonUtil.webLoginfo = String.valueOf(CommonUtil.webLoginfo) + str4 + "\n" + str5;
                httpsURLConnection = (HttpsURLConnection) FS.urlconnection_wrapInstance(new URL(str5).openConnection());
            } catch (Throwable th) {
                th = th;
            }
        } catch (UnknownHostException e) {
            e = e;
        } catch (Exception e2) {
            e = e2;
        }
        try {
            httpsURLConnection.setRequestMethod(FirebasePerformance.HttpMethod.POST);
            httpsURLConnection.setDoOutput(true);
            httpsURLConnection.getOutputStream().write(str4.getBytes());
            int responseCode = httpsURLConnection.getResponseCode();
            CommonUtil.webLoginfo = String.valueOf(CommonUtil.webLoginfo) + "\n" + responseCode + "\n";
            if (responseCode != 200) {
                if (httpsURLConnection == null) {
                    return 203;
                }
                httpsURLConnection.disconnect();
                return 203;
            }
            String readContent = readContent(httpsURLConnection.getInputStream());
            CommonUtil.webLoginfo = String.valueOf(CommonUtil.webLoginfo) + readContent + "\n";
            saveAuthInfoApi(readContent, sharedPreferences);
            int authCheckApi = authCheckApi(readContent, str3);
            if (httpsURLConnection != null) {
                httpsURLConnection.disconnect();
            }
            return authCheckApi;
        } catch (UnknownHostException e3) {
            e = e3;
            httpsURLConnection2 = httpsURLConnection;
            CommonUtil.webLoginfo = String.valueOf(CommonUtil.webLoginfo) + e.getMessage() + "\n";
            if (httpsURLConnection2 != null) {
                httpsURLConnection2.disconnect();
            }
            return 204;
        } catch (Exception e4) {
            e = e4;
            httpsURLConnection2 = httpsURLConnection;
            CommonUtil.webLoginfo = String.valueOf(CommonUtil.webLoginfo) + e.getMessage() + "\n";
            e.printStackTrace();
            if (httpsURLConnection2 != null) {
                httpsURLConnection2.disconnect();
            }
            return 204;
        } catch (Throwable th2) {
            th = th2;
            httpsURLConnection2 = httpsURLConnection;
            if (httpsURLConnection2 != null) {
                httpsURLConnection2.disconnect();
            }
            throw th;
        }
    }

    private void authAndPostDataInBackground(Context context, String str, String str2, String str3, SharedPreferences sharedPreferences) {
        new Thread(new c(this, context, str, str2, str3, sharedPreferences)).start();
    }

    private void authAndPostDataInBackgroundApi(Context context, String str, String str2, String str3, SharedPreferences sharedPreferences) {
        new Thread(new e(this, context, str, str2, str3, sharedPreferences)).start();
    }

    private int authCheck(String str, String str2, Context context, String str3, String str4, boolean z) {
        try {
            JSONObject jSONObject = new JSONObject(str);
            int optInt = jSONObject.optInt(Constants.IPC_BUNDLE_KEY_SEND_ERROR);
            String optString = jSONObject.optString("secret");
            long optLong = jSONObject.optLong("deadLine");
            this.mSecret = optString;
            FS.log_d("Test-Local--content--detail:", "error:" + optInt + ",secret:" + optString + ",deadLine" + optLong);
            if (!z) {
                if (optInt == 103) {
                    return authAndPostData(context, str3, str4, str2, this.mStorage);
                }
                long currentTimeMillis = System.currentTimeMillis() / 1000;
                FS.log_d("Test-Time:deadLine date:", stampToDate(new StringBuilder(String.valueOf(1000 * optLong)).toString()));
                FS.log_d("Test-Time:", "currentTime:" + currentTimeMillis + ",deadLine:" + optLong);
                if (currentTimeMillis > optLong) {
                    authAndPostDataInBackground(context, str3, str4, str2, this.mStorage);
                }
                return 0;
            }
            if (optInt != 0) {
                return optInt;
            }
            FS.log_d("secret:", "secret:" + optString + ",signature:" + str2);
            if (TextUtils.isEmpty(optString) || TextUtils.equals(str2, optString.replace(":", "").toUpperCase())) {
                return 0;
            }
            FS.log_d("secret:", "secret:" + optString + ",signature:" + str2);
            return 201;
        } catch (Exception e) {
            e.printStackTrace();
            return 202;
        }
    }

    private int authCheckApi(String str, String str2) {
        try {
            JSONObject jSONObject = new JSONObject(str);
            int optInt = jSONObject.optInt(Constants.IPC_BUNDLE_KEY_SEND_ERROR);
            String optString = jSONObject.optString("secret");
            long optLong = jSONObject.optLong("deadLine");
            this.mSecret = optString;
            long currentTimeMillis = System.currentTimeMillis() / 1000;
            if (optInt != 0) {
                return optInt;
            }
            if (!TextUtils.isEmpty(optString)) {
                if (!TextUtils.equals(str2, optString.replace(":", "").toUpperCase())) {
                    return 201;
                }
            }
            return currentTimeMillis > optLong ? 103 : 0;
        } catch (Exception e) {
            e.printStackTrace();
            return 202;
        }
    }

    private String byteArrayToHex(byte[] bArr) {
        char[] cArr = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
        StringBuilder sb = new StringBuilder();
        for (byte b : bArr) {
            sb.append(cArr[(b >> 4) & 15]);
            sb.append(cArr[b & 15]);
        }
        return sb.toString();
    }

    public static boolean checkDeviceHasNavigationBar(Context context) {
        return (ViewConfiguration.get(context).hasPermanentMenuKey() && KeyCharacterMap.deviceHasKey(4)) ? false : true;
    }

    static char convert(char r2) {
        throw new UnsupportedOperationException("Method not decompiled: com.intsig.view.b.convert(char):char");
    }

    private void debug(String str) {
        FS.log_d(TAG, str);
    }

    public static String getExpireDate(String str) {
        int lastIndexOf = str.lastIndexOf(45);
        try {
            int parseInt = Integer.parseInt(lastIndexOf > 0 ? str.substring(lastIndexOf - 6, lastIndexOf - 1) : str.substring(20, 25), 16) + 20000000;
            if (parseInt < 20150000) {
                return null;
            }
            return new StringBuilder(String.valueOf(parseInt)).toString();
        } catch (NumberFormatException e) {
            e.printStackTrace();
            return Constants.IPC_BUNDLE_KEY_SEND_ERROR;
        }
    }

    public static int getReportType(String str) {
        try {
            int lastIndexOf = str.lastIndexOf(45);
            return lastIndexOf > 0 ? Integer.parseInt(str.substring(lastIndexOf - 1, lastIndexOf)) : Integer.parseInt(str.substring(str.length() - 1, str.length()));
        } catch (NumberFormatException e) {
            e.printStackTrace();
            return -1;
        }
    }

    private String getSignature(Context context, String str) {
        try {
            Signature[] signatureArr = context.getPackageManager().getPackageInfo(str, 64).signatures;
            if (signatureArr.length != 0) {
                return stringMD5(signatureArr[0].toByteArray());
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static String getVenodrId(String str) {
        int lastIndexOf = str.lastIndexOf(45);
        if (lastIndexOf <= 0) {
            return null;
        }
        try {
            String substring = str.substring(lastIndexOf + 1);
            int length = substring.length();
            char[] cArr = new char[length];
            for (int i = 0; i < length; i++) {
                cArr[i] = convert(substring.charAt(i));
            }
            return new String(cArr);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    private int initEngine(Context context, String str) {
        FS.log_e("initSDKjy", "initEngine:" + str);
        int initEngine = ScannerEngine.initEngine(context, str);
        FS.log_e("initSDKjy", "initEngine code:" + initEngine);
        if (initEngine == -1) {
            return 102;
        }
        if (initEngine == -2) {
            return 205;
        }
        if (initEngine == -3) {
            return 103;
        }
        return initEngine;
    }

    private boolean isOpenApiKey(String str) {
        return str.length() < 26;
    }

    private boolean isZeros(String str) {
        if (str == null) {
            return true;
        }
        int i = 0;
        for (char c : str.toCharArray()) {
            if (c == '0') {
                i++;
            }
        }
        return i > 10;
    }

    private int localCheck(Context context, String str, SharedPreferences sharedPreferences) {
        String string = sharedPreferences.getString("AUTHINFO", null);
        if (!TextUtils.isEmpty(string)) {
            FS.log_d("Test--Local-content", new StringBuilder(String.valueOf(string)).toString());
            return authCheck(string, str, context, this.pkg, this.appKey, false);
        }
        FS.log_d("Test-Local-No-content", "");
        authAndPostDataInBackground(context, this.pkg, this.appKey, str, this.mStorage);
        return 0;
    }

    private int localCheckApi(Context context, String str, SharedPreferences sharedPreferences) {
        String string = sharedPreferences.getString("AUTHINFOOPEN", null);
        if (TextUtils.isEmpty(string)) {
            return 103;
        }
        return authCheckApi(string, str);
    }

    private int openApiCheck(Context context, String str) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("IDCardScanSDK", 0);
        String packageName = context.getPackageName();
        String signature = getSignature(context, packageName);
        debug(" pkg " + packageName + " " + signature);
        int localCheckApi = localCheckApi(context, signature, sharedPreferences);
        if (localCheckApi != 0) {
            return authAndPostDataApi(context, packageName, str, signature, sharedPreferences);
        }
        authAndPostDataInBackgroundApi(context, packageName, str, signature, sharedPreferences);
        return localCheckApi;
    }

    private String readContent(InputStream inputStream) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        StringBuffer stringBuffer = new StringBuffer();
        while (true) {
            String readLine = bufferedReader.readLine();
            if (readLine == null) {
                return stringBuffer.toString();
            }
            stringBuffer.append(String.valueOf(readLine) + "\n");
        }
    }

    public String report() {
        try {
            String str = sVendorId;
            String str2 = IterableConstants.ITBL_PLATFORM_ANDROID + Build.VERSION.RELEASE;
            String str3 = Build.MODEL;
            Locale locale = Locale.getDefault();
            String lowerCase = locale.toString().toLowerCase();
            int i = 5;
            if (lowerCase.length() <= 5) {
                i = lowerCase.length();
            }
            lowerCase.subSequence(0, i);
            String str4 = "https://download.intsig.net/app/query_updates2?ID=" + urlencode(this.sClientId) + "&PL=" + urlencode(str2) + "&PV=1.0.10.20170505&P=IDCardSDK&VE=" + str + "&M=" + urlencode(str3) + "&L=" + locale.getCountry() + "&LANG=" + lowerCase;
            HttpsURLConnection httpsURLConnection = (HttpsURLConnection) FS.urlconnection_wrapInstance(new URL(str4).openConnection());
            httpsURLConnection.setConnectTimeout(MessageHandler.WHAT_ITEM_SELECTED);
            httpsURLConnection.setReadTimeout(MessageHandler.WHAT_ITEM_SELECTED);
            int responseCode = httpsURLConnection.getResponseCode();
            httpsURLConnection.disconnect();
            FS.log_d("report info: ", new StringBuilder(String.valueOf(str4)).toString());
            FS.log_d("report code", new StringBuilder(String.valueOf(responseCode)).toString());
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    private void saveAuthInfo(String str, SharedPreferences sharedPreferences) {
        FS.log_d("Test---HTTP--saveAuthInfo", new StringBuilder(String.valueOf(str)).toString());
        sharedPreferences.edit().putString("AUTHINFO", str).commit();
    }

    private void saveAuthInfoApi(String str, SharedPreferences sharedPreferences) {
        FS.log_d("Test---HTTP--saveAuthInfo--OPNE", new StringBuilder(String.valueOf(str)).toString());
        sharedPreferences.edit().putString("AUTHINFOOPEN", str).commit();
    }

    public static String stampToDate(String str) {
        return new SimpleDateFormat(IterableConstants.DATEFORMAT).format(new Date(new Long(str).longValue()));
    }

    private String stringMD5(byte[] bArr) {
        try {
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");
            messageDigest.update(bArr);
            return byteArrayToHex(messageDigest.digest());
        } catch (Exception unused) {
            return null;
        }
    }

    private String urlencode(String str) {
        try {
            return URLEncoder.encode(str, "utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return str;
        }
    }

    public String getDeviceId(Context context) {
        SharedPreferences sharedPreferences = this.mStorage;
        String string = sharedPreferences.getString("DEVICEID", null);
        if (string != null) {
            try {
                return a.b(string);
            } catch (Exception unused) {
                FS.log_d("AESEncryptor", "AESEncryptor error");
                return string;
            }
        }
        try {
            string = ((TelephonyManager) context.getSystemService("phone")).getDeviceId();
        } catch (Exception unused2) {
            FS.log_d("TelephonyManager", "TelephonyManager error");
        }
        if (TextUtils.isEmpty(string) || isZeros(string)) {
            try {
                Class<?> cls = Class.forName("android.os.SystemProperties");
                string = (String) cls.getMethod("get", String.class).invoke(cls, "ro.serialno");
            } catch (Exception unused3) {
                FS.log_d("ro.serialno", "ro.serialno error");
            }
        }
        if (TextUtils.isEmpty(string)) {
            string = Settings.Secure.getString(context.getContentResolver(), "android_id");
        }
        if (TextUtils.isEmpty(string)) {
            string = new StringBuilder(String.valueOf(System.currentTimeMillis())).toString();
        }
        try {
            string = a.a(string);
        } catch (Exception e) {
            e.printStackTrace();
        }
        sharedPreferences.edit().putString("DEVICEID", string).commit();
        return string;
    }

    public String getSDKVersion() {
        return "Intsig_Android_ImageScannerDemo_SDK_v1.8.3.20170912";
    }

    public int initIDCardScan(Context context, String str) {
        int openApiCheck;
        this.appKey = str;
        if (str == null) {
            return 102;
        }
        this.mStorage = context.getSharedPreferences("IDCardScanSDK", 0);
        String packageName = context.getPackageName();
        this.pkg = packageName;
        this.signature = getSignature(context, packageName);
        debug(" pkg " + this.pkg + " " + this.signature);
        this.sClientId = getDeviceId(context);
        int lastIndexOf = this.appKey.lastIndexOf("-");
        FS.log_d("Test--linenum", new StringBuilder(String.valueOf(lastIndexOf)).toString());
        if ((lastIndexOf != 0 || this.appKey.length() < 26) && lastIndexOf < 26) {
            openApiCheck = openApiCheck(context, this.appKey);
            if (openApiCheck == 0) {
                this.mCheckAvaiable = true;
                initEngine(context, this.mSecret);
            }
        } else {
            openApiCheck = initEngine(context, this.appKey);
            FS.log_d("Test--Auth-code", new StringBuilder(String.valueOf(openApiCheck)).toString());
            if (openApiCheck == 0) {
                int reportType = getReportType(this.appKey);
                this.type_of_report = reportType;
                FS.log_d("Test---type_of_report", new StringBuilder(String.valueOf(reportType)).toString());
                String venodrId = getVenodrId(this.appKey);
                if (venodrId != null) {
                    sVendorId = venodrId;
                }
                reportCheck(context, this.type_of_report);
                if (this.type_of_report != 0) {
                    openApiCheck = localCheck(context, this.signature, this.mStorage);
                }
                this.mCheckAvaiable = true;
            }
        }
        FS.log_d("Test--Auth-Finish---code", new StringBuilder(String.valueOf(openApiCheck)).toString());
        CommonUtil.code = openApiCheck;
        FS.log_d("intsiglog:", CommonUtil.getPkgSigKeyLog(context, str));
        return openApiCheck;
    }

    public int initIDCardScanJy(Context context, String str) {
        this.appKey = str;
        if (str == null) {
            return 102;
        }
        int initEngine = initEngine(context, str);
        FS.log_e("initSDKjy", "out:");
        return initEngine;
    }

    void reportCheck(Context context, int i) {
        if (i == 1) {
            sendReport();
        } else {
            if (i != 2) {
                return;
            }
            reportLogAfterYear(context);
        }
    }

    void reportLogAfterYear(Context context) {
        long j = this.mStorage.getLong("INTSIG-SDK-INSTALL-TIME", -1L);
        if (j == -1) {
            j = System.currentTimeMillis();
            this.mStorage.edit().putLong("INTSIG-SDK-INSTALL-TIME", j).commit();
        }
        if (System.currentTimeMillis() > j + 1471228928) {
            sendReport();
        }
    }

    void sendReport() {
        new Thread(new d(this)).start();
    }
}