/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.custom.CustomAssertionDescriptor
 *  com.l7tech.policy.assertion.CustomAssertionHolder
 *  com.l7tech.policy.assertion.ext.Category
 *  com.l7tech.policy.assertion.ext.CustomAssertionUI
 *  com.l7tech.policy.assertion.ext.action.CustomTaskActionUI
 *  com.l7tech.policy.assertion.ext.entity.CustomEntitySerializer
 */
package com.l7tech.server.policy.custom;

import com.l7tech.gateway.common.custom.CustomAssertionDescriptor;
import com.l7tech.policy.assertion.CustomAssertionHolder;
import com.l7tech.policy.assertion.ext.Category;
import com.l7tech.policy.assertion.ext.CustomAssertionUI;
import com.l7tech.policy.assertion.ext.action.CustomTaskActionUI;
import com.l7tech.policy.assertion.ext.entity.CustomEntitySerializer;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;

class a {
    static Logger a;
    private static Map<String, CustomAssertionDescriptor> b;
    private static final String[] c;

    private a() {
    }

    static void a(CustomAssertionDescriptor customAssertionDescriptor) {
        try {
            a.fine(c[2] + String.valueOf(customAssertionDescriptor));
            if (b.put(customAssertionDescriptor.getName(), customAssertionDescriptor) != null) {
                a.log(Level.WARNING, c[1] + customAssertionDescriptor.getName() + c[3]);
            }
        }
        catch (RuntimeException runtimeException) {
            throw com.l7tech.server.policy.custom.a.a(runtimeException);
        }
    }

    static CustomAssertionDescriptor b(CustomAssertionDescriptor customAssertionDescriptor) {
        a.fine(c[0] + String.valueOf(customAssertionDescriptor));
        return b.remove(customAssertionDescriptor.getName());
    }

    static CustomAssertionDescriptor a(Class clazz) {
        for (CustomAssertionDescriptor customAssertionDescriptor : b.values()) {
            try {
                if (!clazz.equals(customAssertionDescriptor.getAssertion())) continue;
                return customAssertionDescriptor;
            }
            catch (RuntimeException runtimeException) {
                throw com.l7tech.server.policy.custom.a.a(runtimeException);
            }
        }
        return null;
    }

    static CustomAssertionUI a(String string) {
        for (CustomAssertionDescriptor customAssertionDescriptor : b.values()) {
            if (!string.equals(customAssertionDescriptor.getAssertion().getName())) continue;
            try {
                Class clazz = customAssertionDescriptor.getUiClass();
                if (clazz == null) {
                    return null;
                }
                return (CustomAssertionUI)clazz.newInstance();
            }
            catch (Exception exception) {
                throw new RuntimeException(exception);
            }
        }
        return null;
    }

    static CustomTaskActionUI b(String string) {
        for (CustomAssertionDescriptor customAssertionDescriptor : b.values()) {
            if (!string.equals(customAssertionDescriptor.getAssertion().getName())) continue;
            try {
                Class clazz = customAssertionDescriptor.getTakActionUiClass();
                if (clazz == null) {
                    return null;
                }
                return (CustomTaskActionUI)clazz.newInstance();
            }
            catch (Exception exception) {
                throw new RuntimeException(exception);
            }
        }
        return null;
    }

    static Set<CustomAssertionDescriptor> a() {
        HashSet<CustomAssertionDescriptor> hashSet = new HashSet<CustomAssertionDescriptor>();
        for (CustomAssertionDescriptor customAssertionDescriptor : b.values()) {
            hashSet.add(customAssertionDescriptor);
        }
        return hashSet;
    }

    static Set<CustomAssertionDescriptor> b() {
        HashSet<CustomAssertionDescriptor> hashSet = new HashSet<CustomAssertionDescriptor>();
        hashSet.addAll(b.values());
        return hashSet;
    }

    static Set<CustomAssertionDescriptor> a(Category category) {
        HashSet<CustomAssertionDescriptor> hashSet = new HashSet<CustomAssertionDescriptor>();
        for (CustomAssertionDescriptor customAssertionDescriptor : b.values()) {
            try {
                if (!customAssertionDescriptor.hasCategory(category)) continue;
                hashSet.add(customAssertionDescriptor);
            }
            catch (RuntimeException runtimeException) {
                throw com.l7tech.server.policy.custom.a.a(runtimeException);
            }
        }
        return hashSet;
    }

    static CustomAssertionDescriptor c(String string) {
        for (CustomAssertionDescriptor customAssertionDescriptor : b.values()) {
            try {
                if (!customAssertionDescriptor.getAssertion().getName().equals(string)) continue;
                return customAssertionDescriptor;
            }
            catch (RuntimeException runtimeException) {
                throw com.l7tech.server.policy.custom.a.a(runtimeException);
            }
        }
        return null;
    }

    static CustomAssertionDescriptor d(String string) {
        return b.get(CustomAssertionHolder.getLocalExternalName((String)string));
    }

    static Class b(Class clazz) {
        for (CustomAssertionDescriptor customAssertionDescriptor : b.values()) {
            try {
                if (!clazz.equals(customAssertionDescriptor.getAssertion())) continue;
                return customAssertionDescriptor.getServerAssertion();
            }
            catch (RuntimeException runtimeException) {
                throw com.l7tech.server.policy.custom.a.a(runtimeException);
            }
        }
        return null;
    }

    static Set<Class> c() {
        HashSet<Class> hashSet = new HashSet<Class>();
        for (CustomAssertionDescriptor customAssertionDescriptor : b.values()) {
            hashSet.add(customAssertionDescriptor.getAssertion());
        }
        return hashSet;
    }

    static Set<Class> b(Category category) {
        HashSet<Class> hashSet = new HashSet<Class>();
        for (CustomAssertionDescriptor customAssertionDescriptor : b.values()) {
            try {
                if (!customAssertionDescriptor.hasCategory(category)) continue;
                hashSet.add(customAssertionDescriptor.getAssertion());
            }
            catch (RuntimeException runtimeException) {
                throw com.l7tech.server.policy.custom.a.a(runtimeException);
            }
        }
        return hashSet;
    }

    static CustomEntitySerializer e(String string) {
        try {
            for (CustomAssertionDescriptor customAssertionDescriptor : b.values()) {
                for (Class clazz : customAssertionDescriptor.getExternalEntitySerializers()) {
                    if (!clazz.getName().equals(string)) continue;
                    return (CustomEntitySerializer)clazz.newInstance();
                }
            }
        }
        catch (IllegalAccessException | InstantiationException reflectiveOperationException) {
            a.log(Level.WARNING, c[4] + string + "\"");
        }
        return null;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[5];
                var3_1 = 0;
                var2_2 = "\r \u001fHQ?\f\f+\u001fDX1_\u001c;;\u001eYY;_9=\u001eHD\"\u0016\u0017 MZ_\"\u0017X \f@Sv]\f\n+\nDE\"\u001a\n'\u0003J\u0016";
                var4_3 = "\r \u001fHQ?\f\f+\u001fDX1_\u001c;;\u001eYY;_9=\u001eHD\"\u0016\u0017 MZ_\"\u0017X \f@Sv]\f\n+\nDE\"\u001a\n'\u0003J\u0016".length();
                var1_4 = 14;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = com.l7tech.server.policy.custom.a.a(v0, com.l7tech.server.policy.custom.a.f(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "]i\u000bFC4\u0019\u001b0JOI8\u000b\u000b:K\ne9\u001d_&\u0006N\u0011\u0012\r\f=\u0005G\u0011\u0010\u000b\f,\u0018^X>\u0016_-\u000fYR#\u0011\u000f=\u0005X\u0011&\u0011\u0013%JHTq\n\u001a9\u0006KR4\u001c_+\u0013\nE9\u001d_'\u000f]\u0011>\u0016\u001agJ~Y8\u000b_>\u0003F]q\u0015\u0010:\u001e\n]8\u0013\u001a%\u0013\nR0\r\f,JZ^=\u0011\u001c,\u0019\u0006\u0011$\u000b\u0016'\r\nE9\u001d_&\u0006N\u0011\u0012\r\f=\u0005G\u0011\u0010\u000b\f,\u0018^X>\u0016Si\u001eE\u0011\"\f\u00109J]^#\u0013\u0016'\r\u0004>9(\u0003FT5X\u000b&JC_\"\f\u001e'\u001eCP%\u001d_,\u0012^T#\u0016\u001e%JO_%\u0011\u000b0JYT#\u0011\u001e%\u0003PT#X\b \u001eB\u00112\u0014\u001e:\u0019\u0010\u0011s";
                    var4_3 = "]i\u000bFC4\u0019\u001b0JOI8\u000b\u000b:K\ne9\u001d_&\u0006N\u0011\u0012\r\f=\u0005G\u0011\u0010\u000b\f,\u0018^X>\u0016_-\u000fYR#\u0011\u000f=\u0005X\u0011&\u0011\u0013%JHTq\n\u001a9\u0006KR4\u001c_+\u0013\nE9\u001d_'\u000f]\u0011>\u0016\u001agJ~Y8\u000b_>\u0003F]q\u0015\u0010:\u001e\n]8\u0013\u001a%\u0013\nR0\r\f,JZ^=\u0011\u001c,\u0019\u0006\u0011$\u000b\u0016'\r\nE9\u001d_&\u0006N\u0011\u0012\r\f=\u0005G\u0011\u0010\u000b\f,\u0018^X>\u0016Si\u001eE\u0011\"\f\u00109J]^#\u0013\u0016'\r\u0004>9(\u0003FT5X\u000b&JC_\"\f\u001e'\u001eCP%\u001d_,\u0012^T#\u0016\u001e%JO_%\u0011\u000b0JYT#\u0011\u001e%\u0003PT#X\b \u001eB\u00112\u0014\u001e:\u0019\u0010\u0011s".length();
                    var1_4 = 172;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 55;
                        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++] = com.l7tech.server.policy.custom.a.a(v0, com.l7tech.server.policy.custom.a.f(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;
            }
        }
        com.l7tech.server.policy.custom.a.c = var5;
        com.l7tech.server.policy.custom.a.a = Logger.getLogger(a.class.getName());
        com.l7tech.server.policy.custom.a.b = new ConcurrentHashMap<String, CustomAssertionDescriptor>();
    }

    private static RuntimeException a(RuntimeException runtimeException) {
        return runtimeException;
    }

    private static char[] f(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x4F);
        }
        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 -> 72;
                    case 1 -> 126;
                    case 2 -> 93;
                    case 3 -> 29;
                    case 4 -> 6;
                    case 5 -> 102;
                    default -> 79;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

