/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.Component
 *  com.l7tech.gateway.common.audit.AuditDetailMessage
 *  com.l7tech.gateway.common.audit.AuditRecord
 *  com.l7tech.gateway.common.audit.SystemAuditRecord
 *  com.l7tech.gateway.common.audit.SystemMessages
 *  com.l7tech.gateway.common.cluster.ClusterNodeInfo
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.security.cert.TrustedCert
 *  com.l7tech.util.TimeUnit
 */
package com.l7tech.server.identity.cert;

import com.l7tech.gateway.common.Component;
import com.l7tech.gateway.common.audit.AuditDetailMessage;
import com.l7tech.gateway.common.audit.AuditRecord;
import com.l7tech.gateway.common.audit.SystemAuditRecord;
import com.l7tech.gateway.common.audit.SystemMessages;
import com.l7tech.gateway.common.cluster.ClusterNodeInfo;
import com.l7tech.objectmodel.FindException;
import com.l7tech.security.cert.TrustedCert;
import com.l7tech.server.audit.AuditContextFactory;
import com.l7tech.server.identity.cert.TrustedCertManagerImp;
import com.l7tech.server.identity.cert.b;
import com.l7tech.server.identity.cert.c;
import com.l7tech.server.util.ManagedTimerTask;
import com.l7tech.util.TimeUnit;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Formatter;
import java.util.logging.Level;

class j
extends ManagedTimerTask {
    final TrustedCertManagerImp this$0;
    private static final String[] c;

    private j(TrustedCertManagerImp trustedCertManagerImp) {
        this.this$0 = trustedCertManagerImp;
    }

    @Override
    protected void doRun() {
        boolean bl2;
        X509Certificate x509Certificate;
        Object object2;
        Collection collection;
        long l2 = System.currentTimeMillis();
        String[] stringArray = c;
        AuditContextFactory auditContextFactory = (AuditContextFactory)TrustedCertManagerImp.access$000(this.this$0).getBean(stringArray[3], AuditContextFactory.class);
        ClusterNodeInfo clusterNodeInfo = this.this$0.t.getSelfNodeInf();
        long l3 = TimeUnit.parse((String)this.this$0.s.getProperty(stringArray[1]));
        long l4 = TimeUnit.parse((String)this.this$0.s.getProperty(stringArray[2]));
        long l5 = TimeUnit.parse((String)this.this$0.s.getProperty(stringArray[0]));
        try {
            collection = this.this$0.findAll();
        }
        catch (FindException findException) {
            this.this$0.n.logAndAudit((AuditDetailMessage)SystemMessages.CERT_EXPIRY_CANT_FIND, null, findException);
            return;
        }
        ArrayList<b> arrayList = new ArrayList<b>();
        Level level = Level.FINEST;
        for (Object object2 : collection) {
            x509Certificate = object2.getCertificate();
            long l6 = x509Certificate.getNotAfter().getTime();
            long l7 = l6 - l2;
            try {
                if (l7 > l3) {
                    continue;
                }
            }
            catch (FindException findException) {
                throw j.a(findException);
            }
            long l8 = Math.abs(l7);
            TimeUnit timeUnit = l8 <= TrustedCertManagerImp.q ? TimeUnit.MINUTES : (l8 <= TrustedCertManagerImp.p ? TimeUnit.HOURS : TimeUnit.DAYS);
            stringArray = c;
            String string = new Formatter().format(stringArray[4], (double)l8 / (double)timeUnit.getMultiplier(), timeUnit.getName()).toString();
            b b10 = null;
            if (l7 <= 0L) {
                b10 = new b((AuditDetailMessage)SystemMessages.CERT_EXPIRED, (TrustedCert)object2, string);
            } else if (l7 <= l5) {
                b10 = new b((AuditDetailMessage)SystemMessages.CERT_EXPIRING_WARNING, (TrustedCert)object2, string);
            } else if (l7 <= l4) {
                b10 = new b((AuditDetailMessage)SystemMessages.CERT_EXPIRING_INFO, (TrustedCert)object2, string);
            } else if (l7 <= l3) {
                b10 = new b((AuditDetailMessage)SystemMessages.CERT_EXPIRING_FINE, (TrustedCert)object2, string);
            }
            try {
                if (b10 == null) continue;
                arrayList.add(b10);
                if (b10.b.intValue() <= level.intValue()) continue;
            }
            catch (FindException findException) {
                throw j.a(findException);
            }
            level = b10.b;
        }
        try {
            bl2 = !arrayList.isEmpty();
        }
        catch (FindException findException) {
            throw j.a(findException);
        }
        boolean bl3 = bl2;
        object2 = level;
        stringArray = c;
        x509Certificate = new SystemAuditRecord((Level)object2, clusterNodeInfo.getNodeIdentifier(), Component.GW_TRUST_STORE, stringArray[5], bl3, null, null, null, stringArray[6], clusterNodeInfo.getAddress());
        auditContextFactory.doWithNewAuditContext((AuditRecord)x509Certificate, new c(this, arrayList));
    }

    private static FindException a(FindException findException) {
        return findException;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[7];
                var3_1 = 0;
                var2_2 = ";\u0003Q\u0011C=\u0016\f\u0014V\u0016\u0019=\n?\u0018V\u001b`9\u0000!\u0018J\u0005v?\u0017\u0019;\u0003Q\u0011C=\u0016\f\u0014V\u0016\u0019=\n?\u0018V\u001bq1\u001c*0C\u0007\u0019;\u0003Q\u0011C=\u0016\f\u0014V\u0016\u0019=\n?\u0018V\u001b~6\u0014 0C\u0007\u0013.\u0004@\u000bC\u001b\u001d!\u0005A\u001aC\u001e\u0013,\u0005K\u0010N\u0007j_\u0015\u0004\u0017}\u0001";
                var4_3 = ";\u0003Q\u0011C=\u0016\f\u0014V\u0016\u0019=\n?\u0018V\u001b`9\u0000!\u0018J\u0005v?\u0017\u0019;\u0003Q\u0011C=\u0016\f\u0014V\u0016\u0019=\n?\u0018V\u001bq1\u001c*0C\u0007\u0019;\u0003Q\u0011C=\u0016\f\u0014V\u0016\u0019=\n?\u0018V\u001b~6\u0014 0C\u0007\u0013.\u0004@\u000bC\u001b\u001d!\u0005A\u001aC\u001e\u0013,\u0005K\u0010N\u0007j_\u0015\u0004\u0017}\u0001".length();
                var1_4 = 28;
                var0_5 = -1;
lbl7:
                // 2 sources

                while (true) {
                    v0 = 43;
                    v1 = ++var0_5;
                    v2 = var2_2.substring(v1, v1 + var1_4);
                    v3 = -1;
                    break block9;
                    break;
                }
lbl13:
                // 1 sources

                while (true) {
                    var5[var3_1++] = j.b(v0, j.b(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "A^\u0000\u0003\u0019k\u0013c_\u0017FVmA{C\u0011F\u00129PkB\u0011J\u0010pPoD\u0000PVqR}\u0010\u0000[\u0006pAkTEL\u00049Z}\u0010\u0000[\u0006pAg^\u0002\u0003\u0005v\\`\bMX\u0000@\u001dp]i";
                    var4_3 = "A^\u0000\u0003\u0019k\u0013c_\u0017FVmA{C\u0011F\u00129PkB\u0011J\u0010pPoD\u0000PVqR}\u0010\u0000[\u0006pAkTEL\u00049Z}\u0010\u0000[\u0006pAg^\u0002\u0003\u0005v\\`\bMX\u0000@\u001dp]i".length();
                    var1_4 = 64;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 106;
                        v4 = ++var0_5;
                        v2 = var2_2.substring(v4, v4 + var1_4);
                        v3 = 0;
                        break block9;
                        break;
                    }
                    break;
                }
lbl28:
                // 1 sources

                while (true) {
                    var5[var3_1++] = j.b(v0, j.b(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    break block10;
                    break;
                }
            }
            switch (v3) {
                default: {
                    ** continue;
                }
                ** case 0:
lbl39:
                // 1 sources

                ** continue;
            }
        }
        j.c = var5;
    }

    private static char[] b(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x59);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String b(int n2, char[] cArray) {
        char[] cArray2;
        block11: {
            int n3;
            int n4;
            int n5;
            block10: {
                n5 = n2;
                cArray2 = cArray;
                n4 = cArray.length;
                n3 = 0;
                if (!true) break block10;
                n4 = n4;
                if (n4 <= n3) break block11;
            }
            do {
                n5 = n5;
                cArray2 = cArray2;
                int n6 = n3;
                cArray2[n6] = (char)(cArray2[n6] ^ (n5 ^ (switch (n3 % 7) {
                    case 0 -> 100;
                    case 1 -> 90;
                    case 2 -> 15;
                    case 3 -> 73;
                    case 4 -> 28;
                    case 5 -> 115;
                    default -> 89;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

