/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.audit.AuditRecordHeader
 *  com.l7tech.gateway.common.audit.AuditSearchCriteria
 *  com.l7tech.gateway.common.audit.AuditSearchCriteria$Builder
 *  com.l7tech.gateway.common.security.rbac.OperationType
 *  com.l7tech.identity.User
 *  com.l7tech.objectmodel.FindException
 */
package com.l7tech.server.audit;

import com.l7tech.gateway.common.audit.AuditRecordHeader;
import com.l7tech.gateway.common.audit.AuditSearchCriteria;
import com.l7tech.gateway.common.security.rbac.OperationType;
import com.l7tech.identity.User;
import com.l7tech.objectmodel.FindException;
import com.l7tech.server.audit.AuditAdminImpl;
import com.l7tech.server.util.JaasUtils;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.logging.Level;

class e
implements Callable<Long> {
    final Date val$date;
    final Level val$level;
    final AuditAdminImpl this$0;
    private static final String[] a;

    /*
     * Ignored method signature, as it can't be verified against descriptor
     */
    e(AuditAdminImpl auditAdminImpl, Date date, Level level) {
        this.this$0 = auditAdminImpl;
        this.val$date = date;
        this.val$level = level;
    }

    @Override
    public Long call() throws Exception {
        AuditSearchCriteria auditSearchCriteria = new AuditSearchCriteria.Builder().fromTime(this.val$date).fromLevel(this.val$level).maxRecords(1).build();
        long l2 = 0L;
        User user = JaasUtils.getCurrentUser();
        if (user != null) {
            try {
                List<AuditRecordHeader> list = this.this$0.n.findHeaders(auditSearchCriteria);
                list = this.this$0.p.filter(list, user, OperationType.READ, null);
                if (list.size() > 0) {
                    l2 = ((AuditRecordHeader)list.iterator().next()).getTimestamp();
                } else {
                    list = this.this$0.o.findHeaders(auditSearchCriteria);
                    if ((list = this.this$0.p.filter(list, user, OperationType.READ, null)).size() > 0) {
                        l2 = ((AuditRecordHeader)list.iterator().next()).getTimestamp();
                    }
                }
            }
            catch (FindException findException) {
                String[] stringArray = a;
                AuditAdminImpl.e.fine(stringArray[2] + this.val$date.toString() + stringArray[1] + this.val$level.toString());
            }
        } else {
            AuditAdminImpl.e.fine(a[0]);
        }
        return l2;
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[3];
        int n2 = 0;
        String string = "f\fy)j(sG_z4?(x\u0013\bt>$f\u007f[\u001a\u007f0#({\u0013\u0019s)j(yD_}../h@Q\f\u0013\bu/\"fpV\ty7j#u\u001eu7/\"<G\u0010<=#(x\u0013\u0011y,j'iW\u0016h(j sA_x:>#<";
        int n3 = "f\fy)j(sG_z4?(x\u0013\bt>$f\u007f[\u001a\u007f0#({\u0013\u0019s)j(yD_}../h@Q\f\u0013\bu/\"fpV\ty7j#u\u001eu7/\"<G\u0010<=#(x\u0013\u0011y,j'iW\u0016h(j sA_x:>#<".length();
        int n4 = 44;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = e.a(67, e.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                a = stringArray;
                return;
            }
            n4 = string.charAt(n5);
        }
    }

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

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String a(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 -> 112;
                    case 1 -> 60;
                    case 2 -> 95;
                    case 3 -> 24;
                    case 4 -> 9;
                    case 5 -> 5;
                    default -> 95;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

