/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.policy.assertion.Assertion
 *  com.l7tech.policy.assertion.AssertionMetadata
 *  com.l7tech.util.ClassUtils
 *  com.l7tech.util.ExceptionUtils
 */
package com.l7tech.server.policy.module;

import com.l7tech.policy.assertion.Assertion;
import com.l7tech.policy.assertion.AssertionMetadata;
import com.l7tech.server.policy.module.BaseAssertionModule;
import com.l7tech.server.policy.module.h;
import com.l7tech.util.ClassUtils;
import com.l7tech.util.ExceptionUtils;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ModularAssertionModule
extends BaseAssertionModule<h>
implements Closeable {
    private static final Logger f;
    private final JarFile g;
    private final Set<? extends Assertion> h;
    private final Set<String> i;
    private static final String[] k;

    ModularAssertionModule(String string, JarFile jarFile, long l2, String string2, h h2, Set<? extends Assertion> set, Set<String> set2) {
        block10: {
            block9: {
                super(string, l2, string2, h2);
                if (jarFile == null) {
                    String[] stringArray = k;
                    throw new IllegalArgumentException(stringArray[2]);
                }
                try {
                    try {
                        if (set != null && !set.isEmpty()) break block9;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw ModularAssertionModule.b(illegalArgumentException);
                    }
                    throw new IllegalArgumentException(k[9]);
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw ModularAssertionModule.b(illegalArgumentException);
                }
            }
            try {
                try {
                    if (set2 != null && !set2.isEmpty()) break block10;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw ModularAssertionModule.b(illegalArgumentException);
                }
                throw new IllegalArgumentException(k[5]);
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw ModularAssertionModule.b(illegalArgumentException);
            }
        }
        this.g = jarFile;
        this.h = Collections.unmodifiableSet(set);
        this.i = Collections.unmodifiableSet(set2);
    }

    public Set<? extends Assertion> getAssertionPrototypes() {
        return this.h;
    }

    public byte[] getResourceBytes(String string, boolean bl2) throws IOException {
        return ((h)this.getModuleClassLoader()).c(string, bl2);
    }

    public InputStream getResourceStream(String string, boolean bl2) throws IOException {
        return ((h)this.getModuleClassLoader()).b(string, bl2);
    }

    public String[] getClientResources() {
        LinkedHashSet<String> linkedHashSet = new LinkedHashSet<String>();
        for (Assertion assertion : this.getAssertionPrototypes()) {
            int n2;
            String string;
            Collection collection;
            String[] stringArray;
            AssertionMetadata assertionMetadata = assertion.meta();
            try {
                stringArray = k;
                collection = ClassUtils.listResources((Class)assertionMetadata.getAssertionClass(), (String)stringArray[3]);
                for (URL uRL : collection) {
                    string = uRL.getFile();
                    n2 = string.lastIndexOf((stringArray = k)[7]);
                    if (n2 > 0) {
                        string = string.substring(n2 + 8);
                    }
                    linkedHashSet.add(string);
                }
            }
            catch (IOException iOException) {
                stringArray = k;
                f.log(Level.WARNING, stringArray[4] + this.getName() + stringArray[0] + ExceptionUtils.getMessage((Throwable)iOException), ExceptionUtils.getDebugException((Throwable)iOException));
            }
            try {
                stringArray = k;
                collection = ClassUtils.listResources((Class)assertionMetadata.getAssertionClass(), (String)stringArray[8]);
                for (URL uRL : collection) {
                    string = uRL.getFile();
                    n2 = string.lastIndexOf((stringArray = k)[6]);
                    if (n2 > 0) {
                        string = string.substring(n2 + 8);
                    }
                    linkedHashSet.add(string);
                }
            }
            catch (IOException iOException) {
                stringArray = k;
                f.log(Level.WARNING, stringArray[10] + this.getName() + stringArray[1] + ExceptionUtils.getMessage((Throwable)iOException), ExceptionUtils.getDebugException((Throwable)iOException));
            }
        }
        return linkedHashSet.toArray(new String[linkedHashSet.size()]);
    }

    public boolean offersPackage(String string) {
        return this.i.contains(string);
    }

    public boolean offersClass(String string) {
        for (Assertion assertion : this.h) {
            try {
                if (!assertion.getClass().getName().equals(string)) continue;
                return true;
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw ModularAssertionModule.b(illegalArgumentException);
            }
        }
        return false;
    }

    @Override
    public void close() throws IOException {
        try {
            ((h)this.getModuleClassLoader()).close();
        }
        finally {
            this.g.close();
        }
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[11];
                var3_1 = 0;
                var2_2 = "+^\u0002+^\u0010{\u001fJm\u0011_21\f]z\rZ%t\u001a\u0018>?yYUz\u0019WQYx\u000bV%e\u0017WeVZ9u\u001b@*D\u0010Yi\u0014Vwe\u0011\u0018y\u001dR31\u001fKx\u001dA#x\u0011V+\u0011]3t\u0006\u0018m\u0017Aw|\u0011\\~\u0014Vw@a\u001f[`\u0019T2b^U~\u000bGws\u001b\u0018x\bV4x\u0018Qn\u001c\u00136\u007f\u001a\u0018h\u0017]#p\u0017V+\u0019Gw}\u001bYx\f\u00138\u007f\u001b\u0018{\u0019P<p\u0019]+\u0016R:t\bP?j&1}\u0011>\bP?j&1}\u0011>\u0016>?yYUz\u0019WQ[d\u0016@8}\u001b\u0016b\u0016W2i";
                var4_3 = "+^\u0002+^\u0010{\u001fJm\u0011_21\f]z\rZ%t\u001a\u0018>?yYUz\u0019WQYx\u000bV%e\u0017WeVZ9u\u001b@*D\u0010Yi\u0014Vwe\u0011\u0018y\u001dR31\u001fKx\u001dA#x\u0011V+\u0011]3t\u0006\u0018m\u0017Aw|\u0011\\~\u0014Vw@a\u001f[`\u0019T2b^U~\u000bGws\u001b\u0018x\bV4x\u0018Qn\u001c\u00136\u007f\u001a\u0018h\u0017]#p\u0017V+\u0019Gw}\u001bYx\f\u00138\u007f\u001b\u0018{\u0019P<p\u0019]+\u0016R:t\bP?j&1}\u0011>\bP?j&1}\u0011>\u0016>?yYUz\u0019WQ[d\u0016@8}\u001b\u0016b\u0016W2i".length();
                var1_4 = 2;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = ModularAssertionModule.b(v0, ModularAssertionModule.b(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "D9\u007fZ>s\nJ$\\M#s\fQ3|Z?'\u000eP9x\u001f/h\rQ+eQlf\u0017\u0005&i^?sCJ$i\u001f<u\fQ%xF<bCL$\u007fK-i\u0000@(p$m] bCQ%,M)f\u0007\u0005)cQ?h\u000f@jeQ(b\u001b\u0005,cMlj\fA?`Zl";
                    var4_3 = "D9\u007fZ>s\nJ$\\M#s\fQ3|Z?'\u000eP9x\u001f/h\rQ+eQlf\u0017\u0005&i^?sCJ$i\u001f<u\fQ%xF<bCL$\u007fK-i\u0000@(p$m] bCQ%,M)f\u0007\u0005)cQ?h\u000f@jeQ(b\u001b\u0005,cMlj\fA?`Zl".length();
                    var1_4 = 64;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 98;
                        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++] = ModularAssertionModule.b(v0, ModularAssertionModule.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;
            }
        }
        ModularAssertionModule.k = var5;
        ModularAssertionModule.f = Logger.getLogger(ModularAssertionModule.class.getName());
    }

    private static IllegalArgumentException b(IllegalArgumentException illegalArgumentException) {
        return illegalArgumentException;
    }

    private static char[] b(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ '\u0001');
        }
        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 -> 71;
                    case 1 -> 40;
                    case 2 -> 110;
                    case 3 -> 93;
                    case 4 -> 46;
                    case 5 -> 101;
                    default -> 1;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

