导航菜单

页面标题

页面副标题

Minits v4.9.3.32 - a.java 源代码

正在查看: Minits v4.9.3.32 应用的 a.java JAVA 源代码文件

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


package Na;

import Qa.h;
import android.content.Context;
import android.net.Uri;
import android.os.Environment;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import com.android.xone.statesaver.PersistableBundleCompat;
import com.google.firebase.messaging.FirebaseMessaging;
import com.xone.android.nfc.runtimeobjects.XoneNFCRuntime;
import com.xone.android.utils.Utils;
import com.xone.replicator.helpers.DatabaseFilesHelper;
import fb.C0694g;
import fb.t;
import ha.AbstractC0751f;
import j$.util.concurrent.ConcurrentHashMap;
import ja.C0792d;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.OAEPParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import javax.security.cert.CertificateException;
import javax.security.cert.X509Certificate;
import ka.EnumC0825j;
import m4.o;
import ua.r;

public final class a implements r, Ta.d, Ta.c, Parcelable {
    public SecretKeySpec A;
    public SecretKeySpec B;
    public SecretKeySpec C;
    public byte[] D;
    public boolean E;
    public String F;
    public boolean G;
    public final int H;
    public Context I;
    public final boolean J;
    public X509Certificate K;
    public final boolean L;
    public final int M;
    public final boolean N;
    public int O;
    public int P;
    public final boolean Q;
    public final Set R;
    public final int S;
    public final boolean T;
    public final boolean U;
    public final boolean V;
    public int W;
    public g X;
    public Qa.h Y;
    public EnumC0825j Z;
    public final long a0;
    public byte[] b0;
    public byte[] c0;
    public final int d0;
    public final int e0;
    public final Qa.i f0;
    public final boolean g0;
    public final boolean h0;
    public final boolean i0;
    public final boolean j0;
    public final boolean k0;
    public final String l;
    public String m;
    public String n;
    public final String o;
    public final String p;
    public File q;
    public File r;
    public int s;
    public final boolean t;
    public final String u;
    public final List v;
    public final String w;
    public final byte[] x;
    public byte[] y;
    public byte[] z;
    public static final Map l0 = new ConcurrentHashMap();
    public static final byte[] m0 = {69, -119, -69, -111, -84, 25, -104, 22, 12, 35, -3, 72};
    public static final Parcelable.Creator<a> CREATOR = new b();

    public static class C0005a {
        public static final int[] a;
        public static final int[] b;

        static {
            int[] iArr = new int[Ta.e.values().length];
            b = iArr;
            try {
                iArr[Ta.e.Logon.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                b[Ta.e.Client.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                b[Ta.e.Server.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            int[] iArr2 = new int[EnumC0825j.values().length];
            a = iArr2;
            try {
                iArr2[EnumC0825j.WebSocket.ordinal()] = 1;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                a[EnumC0825j.RestJson.ordinal()] = 2;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                a[EnumC0825j.Tcp.ordinal()] = 3;
            } catch (NoSuchFieldError unused6) {
            }
        }
    }

    public static class b implements Parcelable.Creator {
        @Override
        public a createFromParcel(Parcel parcel) {
            return new a(parcel);
        }

        @Override
        public a[] newArray(int i) {
            return new a[i];
        }
    }

    public a(Context context, File file) {
        FileInputStream fileInputStream;
        Throwable th;
        ObjectInputStream objectInputStream;
        this.D = null;
        this.I = context.getApplicationContext();
        this.x = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
        this.K = null;
        this.O = 0;
        this.P = 60;
        this.Z = EnumC0825j.Tcp;
        try {
            this.W = 0;
            String absolutePath = file.getAbsolutePath();
            this.o = absolutePath;
            File file2 = new File(absolutePath, "license.ini");
            this.a0 = Long.parseLong(Utils.r1(file2));
            C0694g c0694g = new C0694g(file2);
            String name = file.getName();
            this.n = name;
            if (name.startsWith("app_")) {
                this.n = this.n.substring(4);
            }
            if (c0694g.a("Disabled", false)) {
                DatabaseFilesHelper.updateStatus(this.I, "load", "Replica Disabled.", s());
                throw new Ra.a();
            }
            String f = c0694g.f("ConnString");
            if (TextUtils.isEmpty(f)) {
                throw new C0792d(" *** RPL Load. Empty connection string. ***");
            }
            String replace = f.replace('\\', '/');
            String str = absolutePath + "/" + (TextUtils.isEmpty(replace) ? "db/gestion.db" : replace);
            this.p = str;
            z0();
            this.w = c0694g.f("FileDownloadURL");
            if (TextUtils.isEmpty(str)) {
                DatabaseFilesHelper.updateStatus(this.I, "load", "No ConnString.", s());
                throw new C0792d(" *** RPL load failed. No ConnString. ***");
            }
            boolean a = c0694g.a("RemoteBroker", false);
            String f2 = c0694g.f("RemoteDest");
            this.v = new ArrayList();
            int i = 0;
            while (true) {
                String str2 = "ServerPort";
                if (i > 10) {
                    break;
                }
                String str3 = "HostName";
                if (i != 0) {
                    str3 = "HostName" + i;
                }
                String f3 = c0694g.f(str3);
                if (!TextUtils.isEmpty(f3)) {
                    String str4 = "ConnectionMode";
                    if (i != 0) {
                        str4 = "ConnectionMode" + i;
                    }
                    String f4 = c0694g.f(str4);
                    if (!TextUtils.isEmpty(f4) && !TextUtils.equals(f4, "direct")) {
                        if (i != 0) {
                            str2 = "ServerPort" + i;
                        }
                        String f5 = c0694g.f(str2);
                        if (!TextUtils.isEmpty(f5)) {
                            f3 = f3 + ":" + f5;
                        }
                        if (f4.startsWith("ws")) {
                            this.Z = EnumC0825j.WebSocket;
                        } else if (!f4.startsWith("http")) {
                            this.Z = EnumC0825j.Tcp;
                        } else if (!TextUtils.isEmpty(f2) || a) {
                            this.Z = EnumC0825j.RestJson;
                        } else {
                            this.Z = EnumC0825j.Tcp;
                        }
                        String str5 = f4 + "://";
                        if (!f3.startsWith(str5)) {
                            f3 = str5 + f3;
                        }
                        this.v.add(f3);
                    }
                    this.v.add(f3);
                }
                i++;
            }
            if (a) {
                this.Y = new h.b().d(t.y(c0694g.f("RemoteMapped"))).b(t.y(c0694g.f("RemoteFileDownloadMapped"))).c(t.z(c0694g.f("RemoteKey"), "1234567890")).a();
            } else if (!TextUtils.isEmpty(f2)) {
                this.Y = new h.b().c(t.z(c0694g.f("RemoteKey"), "1234567890")).a();
            }
            if (this.v.isEmpty()) {
                DatabaseFilesHelper.updateStatus(this.I, "load", "No host name.", s());
                throw new C0792d(" *** RPL load failed. No host name. *** ");
            }
            this.s = c0694g.e("Interval", 30);
            int e = c0694g.e("IntervalType", 1);
            if (e != 0) {
                if (e == 1) {
                    this.s *= 1000;
                } else if (e == 2) {
                    this.s *= 60000;
                } else if (e != 3) {
                    this.s *= 1000;
                } else {
                    this.s *= 3600000;
                }
            }
            this.H = c0694g.e("ServerPort", 7757);
            this.d0 = c0694g.e("PacketSize", 32768);
            this.e0 = c0694g.e("PacketSizeDownload", 1048576);
            this.P = c0694g.e("Timeout", 60);
            this.m = c0694g.f("License");
            String f6 = c0694g.f("Database");
            this.l = f6;
            if (TextUtils.isEmpty(this.m)) {
                if (TextUtils.isEmpty(f6)) {
                    DatabaseFilesHelper.updateStatus(this.I, "load", "Missing Database.", s());
                    throw new C0792d(" *** RPL load failed. Missing database path. *** ");
                }
            } else if (this.m.length() != 24) {
                DatabaseFilesHelper.updateStatus(this.I, "load", "Invalid license.", s());
                throw new C0792d(" *** RPL load failed. Invalid license. *** ");
            }
            this.J = c0694g.a("BatterySave", true);
            this.L = c0694g.a("SupportBatch", true);
            this.M = c0694g.e("BatchSize", 30);
            this.N = c0694g.a("SendWarning", false);
            this.O = c0694g.e("LogLevel", 1);
            this.t = c0694g.a("UsePush", false);
            this.u = t.y(c0694g.f("GooglePushSenderId"));
            this.S = c0694g.e("MaxCacheOpers", 100);
            this.Q = c0694g.a("ReplicaSync", true);
            this.V = c0694g.a("SupportBES", false);
            String f7 = c0694g.f("CertFileName");
            if (!TextUtils.isEmpty(f7)) {
                if (!f7.startsWith("/")) {
                    f7 = this.o + "/" + f7;
                }
                this.K = x0(f7);
            }
            this.T = c0694g.a("KeepSession", true);
            this.f0 = Qa.i.d(c0694g.f("FilesPriority"));
            this.U = c0694g.a("SkipFileReplicaOnFailure", true);
            this.g0 = c0694g.a("DisableReplicaOk", false);
            this.h0 = c0694g.a("DisableReplicaFilesIn", false);
            this.i0 = c0694g.a("DisableReplicaFilesOut", false);
            this.j0 = c0694g.a("AppCheckEnabled", false);
            this.k0 = c0694g.a("LogRequestsEnabled", Utils.d3(this.I));
            F0();
            c0694g.clear();
            File I = I();
            if (!I.exists()) {
                Utils.l("XOneReplicator", "readOperIds(): No operids file found for application " + this.n);
                this.R = new LinkedHashSet();
                return;
            }
            try {
                fileInputStream = new FileInputStream(I);
                try {
                    objectInputStream = new ObjectInputStream(fileInputStream);
                    try {
                        this.R = (LinkedHashSet) objectInputStream.readObject();
                        Utils.P(objectInputStream, fileInputStream);
                    } catch (Throwable th2) {
                        th = th2;
                        Utils.P(objectInputStream, fileInputStream);
                        throw th;
                    }
                } catch (Throwable th3) {
                    th = th3;
                    objectInputStream = null;
                }
            } catch (Throwable th4) {
                fileInputStream = null;
                th = th4;
                objectInputStream = null;
            }
        } catch (IOException e2) {
            e = e2;
            throw AbstractC0751f.e(e);
        } catch (ClassNotFoundException e3) {
            e = e3;
            throw AbstractC0751f.e(e);
        }
    }

    public static void A0(Context context, File file) {
        Context applicationContext = context.getApplicationContext();
        a aVar = new a(applicationContext, file);
        String s = aVar.s();
        m(applicationContext, s, aVar.O(), aVar.b());
        Map map = l0;
        map.remove(s);
        map.put(s, aVar);
        R0(applicationContext, aVar);
    }

    public static File D(Context context, String str) {
        return new File(context.getFilesDir(), str + ".ini");
    }

    public static void R0(Context context, a aVar) {
        PersistableBundleCompat persistableBundleCompat = new PersistableBundleCompat();
        persistableBundleCompat.putParcelable(aVar.s(), aVar);
        persistableBundleCompat.saveToBinaryFile(v(context, aVar.s()), 19);
    }

    public static void j(Context context, a aVar) {
        if (aVar == null) {
            return;
        }
        Context applicationContext = context.getApplicationContext();
        String s = aVar.s();
        v(applicationContext, s).delete();
        l0.remove(s);
    }

    public static void k(Context context) {
        Context applicationContext = context.getApplicationContext();
        Iterator it = l0.keySet().iterator();
        while (it.hasNext()) {
            j(applicationContext, (a) l0.get((String) it.next()));
        }
    }

    public static void m(Context context, String str, String str2, List list) {
        File D = D(context.getApplicationContext(), str);
        if (m0(D, str2, (String) list.get(0))) {
            return;
        }
        String str3 = (String) list.get(0);
        C0694g c0694g = new C0694g(D, true);
        c0694g.B0("License", str2);
        c0694g.B0("ServerADDR", str3);
        c0694g.n();
    }

    public static boolean m0(File file, String str, String str2) {
        if (!file.exists()) {
            return false;
        }
        C0694g c0694g = new C0694g(file);
        return TextUtils.equals(c0694g.f("License"), str) && TextUtils.equals(c0694g.f("ServerADDR"), str2);
    }

    public static byte[] o() {
        byte[] bArr = new byte[64];
        new SecureRandom().nextBytes(bArr);
        return bArr;
    }

    public static a q(Context context, String str) {
        Map map = l0;
        if (map.containsKey(str)) {
            return (a) map.get(str);
        }
        File v = v(context, str);
        if (!v.exists()) {
            Utils.l("AppDescriptor", "No previously saved application descriptor found");
            return null;
        }
        try {
            a aVar = (a) PersistableBundleCompat.restoreFromBinaryFile(v, 19).getParcelable(str);
            if (aVar == null) {
                throw new RuntimeException("Cannot obtain saved descriptor file!");
            }
            aVar.C0(context);
            map.put(str, aVar);
            return aVar;
        } catch (Exception e) {
            e.printStackTrace();
            if ((e instanceof com.android.xone.statesaver.f) || (e instanceof ClassNotFoundException)) {
                Utils.l("AppDescriptor", "Saved application descriptor appears to be from an older version. Recreating file.");
            } else {
                Utils.l("AppDescriptor", "Error obtaining saved application descriptor from file, deleting file.");
            }
            if (v.exists() && v.isFile() && !v.delete()) {
                throw new RuntimeException("Cannot delete incompatible saved descriptor file!");
            }
            Utils.l("AppDescriptor", "File deleted.");
            return null;
        }
    }

    public static List r() {
        ArrayList arrayList = new ArrayList();
        Iterator it = l0.keySet().iterator();
        while (it.hasNext()) {
            arrayList.add((a) l0.get((String) it.next()));
        }
        return arrayList;
    }

    public static String t(File file) {
        if (file == null || !file.exists() || !file.isDirectory()) {
            return "";
        }
        String name = file.getName();
        return !name.startsWith("app_") ? "" : name.substring(4);
    }

    public static File v(Context context, String str) {
        if (TextUtils.isEmpty(str)) {
            throw new NullPointerException("getCachedDescriptor(): sAppName == null");
        }
        File file = new File(context.getApplicationContext().getFilesDir(), "saved_application_descriptors");
        if (file.exists() || file.mkdirs()) {
            return new File(file, str);
        }
        throw new RuntimeException("Cannot create saved application descriptors directory");
    }

    public Uri A() {
        if (TextUtils.isEmpty(this.w)) {
            return null;
        }
        try {
            return Uri.parse(this.w);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public String B() {
        return this.w;
    }

    public File C() {
        return this.q;
    }

    public void C0(Context context) {
        this.I = context.getApplicationContext();
        z0();
        F0();
    }

    public int E() {
        return this.O;
    }

    public final void F0() {
        try {
            this.C = null;
            this.B = null;
            this.A = null;
            if (this.b0 == null || !v0()) {
                a0();
            } else {
                this.C = l(this.b0);
            }
            if (this.c0 != null && v0() && this.C != null) {
                byte[] bArr = this.c0;
                this.D = bArr;
                this.B = l(bArr);
                this.A = l(m0);
                c0();
                return;
            }
            this.b0 = null;
            this.c0 = null;
            this.C = null;
            this.B = null;
            a0();
            Q0();
        } catch (Exception e) {
            e.printStackTrace();
            a0();
            this.C = null;
            this.B = null;
            this.A = null;
        }
    }

    public int G() {
        return this.S;
    }

    public void G0() {
        a0();
    }

    public Set H() {
        return this.R;
    }

    public final File I() {
        return new File(this.I.getDir("data", 0), "operids." + this.n);
    }

    public int J() {
        return this.d0;
    }

    public final String J0() {
        Va.b bVar = new Va.b(250);
        bVar.p("lic", this.l);
        bVar.p("tid", Utils.Y0(this.I));
        bVar.p("model", "android");
        try {
            Va.b P0 = P0(bVar.k(this));
            if (P0 == null) {
                throw new IOException("Communication error, transferData returned null response");
            }
            int h = P0.h();
            if (h == 0) {
                return P0.e("lic");
            }
            throw new IOException("Communication error, transferData returned status " + h);
        } catch (Exception e) {
            j.d(" *** RPL QUERYLIC failed. ***", e);
            return null;
        }
    }

    public int K() {
        return this.e0;
    }

    public final X509Certificate K0() {
        String substring = !TextUtils.isEmpty(this.m) ? this.m.substring(0, 8) : this.l;
        Va.b bVar = new Va.b(252);
        bVar.p("db", substring);
        try {
            Va.b P0 = P0(bVar.k(this));
            if (P0 == null) {
                j.b(" *** RPL Error sending GETCERT. *** ");
                return null;
            }
            byte[] d = P0.d("cer");
            if (d != null) {
                return X509Certificate.getInstance(d);
            }
            j.f(" *** RPL Server did not send certificate info. *** ");
            return null;
        } catch (Exception e) {
            j.d(" *** RPL Error retrieving certificate from server. *** ", e);
            return null;
        }
    }

    public final String L() {
        try {
            m4.l p = FirebaseMessaging.m().p();
            o.a(p);
            String str = (String) p.l();
            return str == null ? "" : str;
        } catch (InterruptedException e) {
            throw AbstractC0751f.e(e);
        } catch (ExecutionException e2) {
            AbstractC0751f.i(e2).printStackTrace();
            return "";
        }
    }

    public Qa.h M() {
        return this.Y;
    }

    public void M0(String str) {
        this.m = str;
    }

    public int N() {
        return this.s;
    }

    public void N0(int i) {
        this.W = i;
    }

    public String O() {
        return this.m;
    }

    public Qa.i P() {
        return this.f0;
    }

    public synchronized Va.b P0(byte[] bArr) {
        try {
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        return V().b(bArr);
    }

    public g Q() {
        if (this.X == null) {
            this.X = new g(this.o);
        }
        this.X.c();
        return this.X;
    }

    public final void Q0() {
        R0(this.I, this);
    }

    public boolean S() {
        return this.N;
    }

    public final void S0() {
        try {
            C0694g c0694g = new C0694g(new File(this.o, "license.ini"));
            c0694g.B0("License", this.m);
            c0694g.n();
        } catch (Exception e) {
            j.d(" *** RPL: Error updating license.ini with new license number", e);
        }
    }

    public synchronized byte[] T() {
        return this.x;
    }

    public void T0() {
        FileOutputStream fileOutputStream;
        Throwable th;
        ObjectOutputStream objectOutputStream;
        if (this.R == null) {
            return;
        }
        File I = I();
        if (!I.exists()) {
            Utils.l("XOneReplicator", "writeOperIds(): No operids file found for application " + this.n + ". Creating a new one.");
        }
        try {
            fileOutputStream = new FileOutputStream(I);
            try {
                objectOutputStream = new ObjectOutputStream(fileOutputStream);
                try {
                    objectOutputStream.writeObject(this.R);
                    objectOutputStream.flush();
                    Utils.P(objectOutputStream, fileOutputStream);
                } catch (Throwable th2) {
                    th = th2;
                    Utils.P(objectOutputStream, fileOutputStream);
                    throw th;
                }
            } catch (Throwable th3) {
                th = th3;
                objectOutputStream = null;
            }
        } catch (Throwable th4) {
            fileOutputStream = null;
            th = th4;
            objectOutputStream = null;
        }
    }

    public boolean U() {
        return this.L;
    }

    public Ta.b V() {
        Ta.b j;
        int i = C0005a.a[W().ordinal()];
        if (i == 1) {
            j = Pa.i.j();
        } else if (i == 2) {
            j = Pa.c.f();
        } else {
            if (i != 3) {
                throw new IncompatibleClassChangeError();
            }
            j = Pa.d.g();
        }
        j.c(this);
        return j;
    }

    public EnumC0825j W() {
        return this.Z;
    }

    public int X() {
        return this.M;
    }

    public int Y() {
        return this.W;
    }

    public final boolean Z(byte[] bArr) {
        try {
            byte[] d = d(bArr, this.K == null ? Ta.e.Logon : Ta.e.Client);
            this.b0 = d;
            this.C = l(d);
            return true;
        } catch (Exception e) {
            j.d(" *** RPL: Error importing server key. *** ", e);
            return false;
        }
    }

    @Override
    public int a() {
        return this.H;
    }

    public final void a0() {
        Arrays.fill(this.x, (byte) 0);
    }

    @Override
    public List b() {
        return this.v;
    }

    @Override
    public int c() {
        return this.P;
    }

    public final void c0() {
        this.z = new byte[16];
        this.y = new byte[16];
        int i = 0;
        while (true) {
            byte[] bArr = this.z;
            if (i >= bArr.length) {
                return;
            }
            boolean z = this.E;
            bArr[i] = (byte) (z ? i + 1 : 0);
            this.y[i] = (byte) (z ? i + 1 : 0);
            i++;
        }
    }

    @Override
    public byte[] d(byte[] bArr, Ta.e eVar) {
        if (eVar == Ta.e.DbCertificate) {
            return null;
        }
        SecretKeySpec h = h(eVar);
        byte[] g = g(eVar);
        if (h == null) {
            throw new SecurityException("Criptography error. Key material was not initialized, cannot complete operation.");
        }
        IvParameterSpec ivParameterSpec = new IvParameterSpec(g);
        try {
            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
            cipher.init(2, h, ivParameterSpec);
            return cipher.doFinal(bArr);
        } catch (InvalidAlgorithmParameterException | InvalidKeyException | NoSuchAlgorithmException | BadPaddingException | IllegalBlockSizeException | NoSuchPaddingException e) {
            throw AbstractC0751f.e(e);
        }
    }

    public boolean d0() {
        return this.G;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public synchronized boolean e() {
        j.a(" *** RPL: Logon started.");
        try {
            Va.b P0 = P0(new Va.b(100).k(this));
            if (P0 == null) {
                j.b(" *** RPL IDENT failed. *** ");
                return false;
            }
            if (P0.h() != 0) {
                j.b(" *** RPL IDENT failed. *** " + P0.i());
                return false;
            }
            String e = P0.e("server");
            this.E = false;
            if (!e.startsWith("win.net")) {
                if (!e.startsWith("java")) {
                    j.b(" *** RPL Server platform is not supported. *** ");
                    return false;
                }
                this.E = true;
            }
            this.F = P0.e("charset");
            this.G = t.l(P0.e("allow-tuid-array"), false);
            if (t.l(P0.e("kex"), false)) {
                this.K = K0();
            }
            n();
            if (TextUtils.isEmpty(this.m)) {
                j.f(" *** RPL: Application is not provisioned with a license. Checking on remote server. *** ");
                String J0 = J0();
                M0(J0);
                if (TextUtils.isEmpty(J0)) {
                    j.b(" *** RPL: Logon failed, device is not registered on remote server. *** ");
                    return false;
                }
                S0();
            }
            j.a(" *** RPL: sending logon: " + this.m);
            Va.b bVar = new Va.b(20);
            bVar.p("lic", this.m.substring(0, 8));
            bVar.p(XoneNFCRuntime.TAG_ID_FIELD, this.m);
            bVar.p("bcmp", "1");
            bVar.p("blockver", "2");
            bVar.p("alg", "AES");
            if (this.t) {
                String L = L();
                if (TextUtils.isEmpty(L)) {
                    j.b(" *** RPL: Cannot obtain push token from firebase. *** ");
                } else {
                    bVar.p("push-cookie", L);
                    j.a(" *** RPL: Push token: " + L);
                }
            }
            if (d0()) {
                j.f(" *** RPL: Server supports multiple device id login.");
                Set Y1 = Utils.Y1(this.I);
                StringBuilder sb2 = new StringBuilder();
                Iterator it = Y1.iterator();
                while (it.hasNext()) {
                    sb2.append((String) it.next());
                    sb2.append(',');
                }
                String sb3 = sb2.toString();
                if (sb3.endsWith(",")) {
                    sb3 = sb3.substring(0, sb3.lastIndexOf(","));
                }
                bVar.p("tuid-array", sb3);
            } else {
                bVar.p("tuid", Utils.Y0(this.I));
            }
            byte[] f = f(this.D, this.K == null ? Ta.e.Logon : Ta.e.DbCertificate);
            if (f == null) {
                throw new NullPointerException("key == null");
            }
            bVar.o("key", f);
            if (this.K != null) {
                bVar.p("kex", "1");
            }
            Va.b P02 = P0(bVar.k(this));
            if (P02 == null || P02.h() != 0) {
                j.c(" *** RPL: Logon failed.", P02);
                G0();
                return false;
            }
            byte[] d = P02.d(XoneNFCRuntime.TAG_ID_FIELD);
            if (d == null) {
                throw new NullPointerException("paramSessionId == null");
            }
            System.arraycopy(d, 0, this.x, 0, 16);
            if (!v0()) {
                j.b(" *** RPL: Logon failed. SID is invalid.");
                return false;
            }
            j.a(" *** RPL: Session ID retrieved successfully.");
            byte[] d2 = P02.d("key");
            if (d2 == null) {
                G0();
                j.b(" *** RPL: Logon failed. No server key retrieved. *** ");
                return false;
            }
            if (Z(d2)) {
                j.a(" *** RPL: Logon completed successfully.");
                Q0();
                return true;
            }
            G0();
            j.b(" *** RPL: Logon failed. Error importing server key from logon command. *** ");
            return false;
        } catch (Exception e2) {
            j.d(" *** RPL IDENT failed with exception. *** ", e2);
            return false;
        }
    }

    public boolean e0() {
        return this.j0;
    }

    @Override
    public byte[] f(byte[] bArr, Ta.e eVar) {
        if (eVar == Ta.e.DbCertificate) {
            try {
                Cipher cipher = Cipher.getInstance("RSA");
                cipher.init(1, this.K.getPublicKey(), OAEPParameterSpec.DEFAULT);
                return cipher.doFinal(bArr);
            } catch (InvalidAlgorithmParameterException | InvalidKeyException | NoSuchAlgorithmException | BadPaddingException | IllegalBlockSizeException | NoSuchPaddingException e) {
                j.d(" *** RPL: Error while trying to encrypt data with client certificate", e);
                return null;
            }
        }
        SecretKeySpec h = h(eVar);
        byte[] g = g(eVar);
        if (h == null) {
            G0();
            throw new SecurityException("Criptography error. Key material was not initialized, cannot complete operation.");
        }
        IvParameterSpec ivParameterSpec = new IvParameterSpec(g);
        try {
            Cipher cipher2 = Cipher.getInstance("AES/CBC/PKCS5Padding");
            cipher2.init(1, h, ivParameterSpec);
            return cipher2.doFinal(bArr);
        } catch (InvalidAlgorithmParameterException | InvalidKeyException | NoSuchAlgorithmException | BadPaddingException | IllegalBlockSizeException | NoSuchPaddingException e2) {
            throw AbstractC0751f.e(e2);
        }
    }

    public boolean f0() {
        return this.V;
    }

    public final byte[] g(Ta.e eVar) {
        int i = C0005a.b[eVar.ordinal()];
        if (i == 1) {
            return this.y;
        }
        if (i == 2 || i == 3) {
            return this.z;
        }
        return null;
    }

    public boolean g0() {
        return this.h0;
    }

    public final SecretKeySpec h(Ta.e eVar) {
        int i = C0005a.b[eVar.ordinal()];
        if (i == 1) {
            return this.A;
        }
        if (i == 2) {
            return this.B;
        }
        if (i != 3) {
            return null;
        }
        return this.C;
    }

    public void i() {
        a0();
        this.b0 = null;
        this.c0 = null;
        Q0();
    }

    public boolean i0() {
        return this.i0;
    }

    public boolean j0() {
        return this.Q;
    }

    public boolean k0() {
        return this.T;
    }

    public final SecretKeySpec l(byte[] bArr) {
        if (bArr == null) {
            return null;
        }
        try {
            int i = this.E ? 16 : 32;
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");
            messageDigest.update(bArr);
            byte[] digest = messageDigest.digest();
            int length = digest.length;
            byte[] bArr2 = new byte[i];
            int i2 = 0;
            if (length >= i) {
                while (i2 < i) {
                    bArr2[i2] = digest[i2];
                    i2++;
                }
                return new SecretKeySpec(bArr2, "AES");
            }
            byte[] bArr3 = new byte[64];
            for (int i3 = 0; i3 < 64; i3++) {
                bArr3[i3] = 54;
            }
            for (int i4 = 0; i4 < length; i4++) {
                bArr3[i4] = (byte) (bArr3[i4] ^ digest[i4]);
            }
            byte[] bArr4 = new byte[64];
            for (int i5 = 0; i5 < 64; i5++) {
                bArr4[i5] = 92;
            }
            for (int i6 = 0; i6 < length; i6++) {
                bArr4[i6] = (byte) (bArr4[i6] ^ digest[i6]);
            }
            messageDigest.reset();
            messageDigest.update(bArr3);
            byte[] digest2 = messageDigest.digest();
            messageDigest.reset();
            messageDigest.update(bArr4);
            byte[] digest3 = messageDigest.digest();
            byte[] bArr5 = new byte[digest2.length + digest3.length];
            for (int i7 = 0; i7 < digest2.length; i7++) {
                bArr5[i7] = digest2[i7];
            }
            for (int i10 = 0; i10 < digest3.length; i10++) {
                bArr5[digest2.length + i10] = digest3[i10];
            }
            while (i2 < i) {
                bArr2[i2] = bArr5[i2];
                i2++;
            }
            return new SecretKeySpec(bArr2, "AES");
        } catch (NoSuchAlgorithmException e) {
            throw AbstractC0751f.e(e);
        }
    }

    public final void n() {
        c0();
        this.A = l(m0);
        byte[] o = o();
        this.D = o;
        this.B = l(o);
        this.c0 = this.D;
    }

    public boolean n0() {
        return this.k0;
    }

    public boolean o0(File file) {
        return Long.parseLong(Utils.r1(new File(file, "license.ini"))) != this.a0;
    }

    public boolean p0() {
        return this.g0;
    }

    public String s() {
        return this.n;
    }

    public boolean s0() {
        return this.J;
    }

    public boolean t0() {
        return this.U;
    }

    public boolean v0() {
        for (byte b2 : this.x) {
            if (b2 != 0) {
                return true;
            }
        }
        return false;
    }

    public String w() {
        return TextUtils.isEmpty(this.F) ? "windows-1252" : this.F;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(this.l);
        parcel.writeString(this.m);
        parcel.writeString(this.n);
        parcel.writeString(this.o);
        parcel.writeString(this.p);
        parcel.writeInt(this.s);
        parcel.writeByte(this.t ? (byte) 1 : (byte) 0);
        parcel.writeString(this.u);
        parcel.writeStringList(this.v);
        parcel.writeString(this.w);
        parcel.writeByteArray(this.x);
        parcel.writeByteArray(this.y);
        parcel.writeByteArray(this.z);
        parcel.writeByteArray(this.D);
        parcel.writeByte(this.E ? (byte) 1 : (byte) 0);
        parcel.writeInt(this.H);
        parcel.writeByte(this.J ? (byte) 1 : (byte) 0);
        parcel.writeByte(this.L ? (byte) 1 : (byte) 0);
        parcel.writeInt(this.M);
        parcel.writeByte(this.N ? (byte) 1 : (byte) 0);
        parcel.writeInt(this.O);
        parcel.writeInt(this.P);
        parcel.writeInt(this.d0);
        parcel.writeInt(this.e0);
        parcel.writeByte(this.Q ? (byte) 1 : (byte) 0);
        parcel.writeInt(this.S);
        parcel.writeByte(this.T ? (byte) 1 : (byte) 0);
        parcel.writeByte(this.V ? (byte) 1 : (byte) 0);
        parcel.writeInt(this.W);
        parcel.writeParcelable(this.X, i);
        parcel.writeString(this.Z.f());
        parcel.writeLong(this.a0);
        parcel.writeParcelable(this.Y, i);
        parcel.writeSerializable((Serializable) this.R);
        parcel.writeString(this.F);
        parcel.writeByte(this.G ? (byte) 1 : (byte) 0);
        parcel.writeByteArray(this.b0);
        parcel.writeByteArray(this.c0);
        parcel.writeString(this.f0.toString());
        parcel.writeByte(this.U ? (byte) 1 : (byte) 0);
        parcel.writeByte(this.g0 ? (byte) 1 : (byte) 0);
        parcel.writeByte(this.h0 ? (byte) 1 : (byte) 0);
        parcel.writeByte(this.i0 ? (byte) 1 : (byte) 0);
        parcel.writeByte(this.j0 ? (byte) 1 : (byte) 0);
        parcel.writeByte(this.k0 ? (byte) 1 : (byte) 0);
    }

    public String x() {
        return this.p;
    }

    public final X509Certificate x0(String str) {
        Throwable th;
        Throwable e;
        try {
            try {
                FileInputStream fileInputStream = new FileInputStream(new File(str));
                try {
                    X509Certificate x509Certificate = X509Certificate.getInstance(fileInputStream);
                    Utils.N(fileInputStream);
                    return x509Certificate;
                } catch (FileNotFoundException e2) {
                    e = e2;
                    throw AbstractC0751f.e(e);
                } catch (CertificateException e3) {
                    e = e3;
                    throw AbstractC0751f.e(e);
                }
            } catch (Throwable th2) {
                th = th2;
                Utils.N(null);
                throw th;
            }
        } catch (FileNotFoundException e4) {
            e = e4;
            e = e;
            throw AbstractC0751f.e(e);
        } catch (CertificateException e5) {
            e = e5;
            e = e;
            throw AbstractC0751f.e(e);
        } catch (Throwable th3) {
            th = th3;
            Utils.N(null);
            throw th;
        }
    }

    public Context y() {
        return this.I;
    }

    public File z() {
        return this.r;
    }

    public final void z0() {
        File file = new File(new File(this.I.getFilesDir().getParentFile(), "app_" + this.n), "files");
        this.r = new File(Environment.getExternalStorageDirectory(), "xone/app_" + this.n + "/files/");
        if (Utils.g3(this.I)) {
            this.q = file;
        } else if ("mounted".equals(Environment.getExternalStorageState())) {
            this.q = this.r;
        }
    }

    public a(Parcel parcel) {
        this.D = null;
        this.l = parcel.readString();
        this.m = parcel.readString();
        this.n = parcel.readString();
        this.o = parcel.readString();
        this.p = parcel.readString();
        this.s = parcel.readInt();
        this.t = parcel.readByte() != 0;
        this.u = parcel.readString();
        ArrayList arrayList = new ArrayList();
        this.v = arrayList;
        parcel.readStringList(arrayList);
        this.w = parcel.readString();
        this.x = parcel.createByteArray();
        this.y = parcel.createByteArray();
        this.z = parcel.createByteArray();
        this.D = parcel.createByteArray();
        this.E = parcel.readByte() != 0;
        this.H = parcel.readInt();
        this.J = parcel.readByte() != 0;
        this.L = parcel.readByte() != 0;
        this.M = parcel.readInt();
        this.N = parcel.readByte() != 0;
        this.O = parcel.readInt();
        this.P = parcel.readInt();
        this.d0 = parcel.readInt();
        this.e0 = parcel.readInt();
        this.Q = parcel.readByte() != 0;
        this.S = parcel.readInt();
        this.T = parcel.readByte() != 0;
        this.V = parcel.readByte() != 0;
        this.W = parcel.readInt();
        this.X = (g) parcel.readParcelable(g.class.getClassLoader());
        this.Z = EnumC0825j.d(parcel.readString());
        this.a0 = parcel.readLong();
        this.Y = (Qa.h) parcel.readParcelable(Qa.h.class.getClassLoader());
        this.R = (LinkedHashSet) parcel.readSerializable();
        this.F = parcel.readString();
        this.G = parcel.readByte() != 0;
        this.b0 = parcel.createByteArray();
        this.c0 = parcel.createByteArray();
        this.f0 = Qa.i.d(parcel.readString());
        this.U = parcel.readByte() != 0;
        this.g0 = parcel.readByte() != 0;
        this.h0 = parcel.readByte() != 0;
        this.i0 = parcel.readByte() != 0;
        this.j0 = parcel.readByte() != 0;
        this.k0 = parcel.readByte() != 0;
    }
}