/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.util.Config
 *  com.l7tech.util.ResourceUtils
 *  com.l7tech.util.SyspropUtil
 *  org.springframework.beans.factory.InitializingBean
 */
package com.l7tech.server;

import com.l7tech.util.Config;
import com.l7tech.util.ResourceUtils;
import com.l7tech.util.SyspropUtil;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.springframework.beans.factory.InitializingBean;

public class SystemProperties
implements InitializingBean {
    private static final Logger a;
    private static final String b;
    private static final String c;
    protected static final String DISKLESS_CONFIG_SYSTEM_PROP;
    protected final Config config;
    private static final String[] d;

    public SystemProperties(Config config) {
        this.config = config;
    }

    public void afterPropertiesSet() throws Exception {
        this.a(this.config);
    }

    private void a(Config config) throws IOException {
        Properties properties = this.getDefaultProperties();
        Properties properties2 = this.b(config);
        for (Object object : properties2.keySet()) {
            properties.remove(object);
        }
        this.setSystemProperties(properties, null, false);
        this.setSystemProperties(properties2, null, true);
    }

    public Properties getDefaultProperties() throws IOException {
        Properties properties = new Properties();
        InputStream inputStream = null;
        try {
            inputStream = SystemProperties.class.getResourceAsStream(d[8]);
            try {
                if (inputStream != null) {
                    properties.load(inputStream);
                }
            }
            catch (IOException iOException) {
                throw SystemProperties.a(iOException);
            }
        }
        catch (Throwable throwable) {
            ResourceUtils.closeQuietly(inputStream);
            throw throwable;
        }
        ResourceUtils.closeQuietly((Closeable)inputStream);
        return properties;
    }

    public Properties getUserDefinedProperties() throws IOException {
        return this.b(this.config);
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    private Properties b(Config config) throws IOException {
        String[] stringArray = d;
        String string = config.getProperty(stringArray[5]);
        File file = new File(string);
        Properties properties = new Properties();
        InputStream inputStream = null;
        try {
            inputStream = file.exists() ? new FileInputStream(file) : SystemProperties.class.getResourceAsStream(d[3]);
            try {
                if (inputStream != null) {
                    properties.load(inputStream);
                }
            }
            catch (IOException iOException) {
                throw SystemProperties.a(iOException);
            }
        }
        catch (Throwable throwable) {
            ResourceUtils.closeQuietly(inputStream);
            throw throwable;
        }
        ResourceUtils.closeQuietly((Closeable)inputStream);
        return properties;
    }

    public void setSystemProperties(Properties properties, String string, boolean bl2) {
        String string2 = string == null ? "" : (string.endsWith(".") ? string : string + ".");
        String[] stringArray = d;
        String string3 = stringArray[0].replace(string2, "");
        boolean bl3 = SyspropUtil.getBoolean((String)stringArray[1]) || Boolean.parseBoolean(properties.getProperty(string3));
        for (String string4 : properties.stringPropertyNames()) {
            String string5 = properties.getProperty(string4);
            String string6 = string2 + string4;
            if (bl3 || SyspropUtil.getProperty((String)string6) == null) {
                if (bl2) {
                    stringArray = d;
                    a.log(Level.CONFIG, stringArray[4], new Object[]{string6, string5});
                }
                SyspropUtil.setProperty((String)string6, (String)string5);
                continue;
            }
            if (!bl2) continue;
            a.log(Level.FINE, d[7], string6);
        }
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[9];
                var3_1 = 0;
                var2_2 = "VlP\u0011\bSTP`U\u0011\u0017\u0001RCfO\u0011\u0014\u0016OVfNL'\u000bNAqRS\b\u0001ReqXL\u0001\nT*VlP\u0011\bSTP`U\u0011\u0017\u0001RCfO\u0011\u0014\u0016OVfNL'\u000bNAqRS\b\u0001ReqXL\u0001\nT\u0019VlP\u0011\bSTP`U\u0011\u0000\rS^oXL\u0017'O[eTX\u0011FzNK\u0001\t\u000eEqRO\u0001\u0016T\\fN\u001fffIK\r\nG\u0015pDL\u0010\u0001M\u0015sOP\u0014\u0001RAz\u001dDT\u0019\u001dN2@\u0014FzNK\u0001\tpGlMZ\u0016\u0010IPpm^\u0010\f\u001bGfNP\u0011\u0016CPp\u0012L\u001d\u0017TPn\u0013O\u0016\u000bPPqIV\u0001\u0017";
                var4_3 = "VlP\u0011\bSTP`U\u0011\u0017\u0001RCfO\u0011\u0014\u0016OVfNL'\u000bNAqRS\b\u0001ReqXL\u0001\nT*VlP\u0011\bSTP`U\u0011\u0017\u0001RCfO\u0011\u0014\u0016OVfNL'\u000bNAqRS\b\u0001ReqXL\u0001\nT\u0019VlP\u0011\bSTP`U\u0011\u0000\rS^oXL\u0017'O[eTX\u0011FzNK\u0001\t\u000eEqRO\u0001\u0016T\\fN\u001fffIK\r\nG\u0015pDL\u0010\u0001M\u0015sOP\u0014\u0001RAz\u001dDT\u0019\u001dN2@\u0014FzNK\u0001\tpGlMZ\u0016\u0010IPpm^\u0010\f\u001bGfNP\u0011\u0016CPp\u0012L\u001d\u0017TPn\u0013O\u0016\u000bPPqIV\u0001\u0017".length();
                var1_4 = 42;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = SystemProperties.a(v0, SystemProperties.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "\u0005\u00127ai\u007f*?\u0014-&:i'8\t&,:j,$\r&3nc~0M>ax\u007f=*\b0$:s*k\u0015\"2:{29\u0018\"%c:<.\u0018-ai\u007f*\u001b9\u00180.oh=.\u000el2ci*.\u0010m1hu..\u000f7(\u007fi";
                    var4_3 = "\u0005\u00127ai\u007f*?\u0014-&:i'8\t&,:j,$\r&3nc~0M>ax\u007f=*\b0$:s*k\u0015\"2:{29\u0018\"%c:<.\u0018-ai\u007f*\u001b9\u00180.oh=.\u000el2ci*.\u0010m1hu..\u000f7(\u007fi".length();
                    var1_4 = 63;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 93;
                        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++] = SystemProperties.a(v0, SystemProperties.a(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;
            }
        }
        SystemProperties.d = var5;
        SystemProperties.b = SystemProperties.d[6];
        SystemProperties.c = SystemProperties.d[1];
        SystemProperties.DISKLESS_CONFIG_SYSTEM_PROP = SystemProperties.d[2];
        SystemProperties.a = Logger.getLogger(SystemProperties.class.getName());
    }

    private static IOException a(IOException iOException) {
        return iOException;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 3);
        }
        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 -> 22;
                    case 1 -> 32;
                    case 2 -> 30;
                    case 3 -> 28;
                    case 4 -> 71;
                    case 5 -> 71;
                    default -> 3;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

