/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.common.http.GenericHttpRequestParams
 *  com.l7tech.common.http.SimpleHttpClient
 *  com.l7tech.common.http.SimpleHttpClient$SimpleHttpResponse
 *  com.l7tech.util.Pair
 *  com.l7tech.util.ResourceUtils
 *  com.l7tech.wsdl.WsdlEntityResolver
 */
package com.l7tech.server.uddi;

import com.l7tech.common.http.GenericHttpRequestParams;
import com.l7tech.common.http.SimpleHttpClient;
import com.l7tech.util.Pair;
import com.l7tech.util.ResourceUtils;
import com.l7tech.wsdl.WsdlEntityResolver;
import java.io.IOException;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.PasswordAuthentication;
import java.net.URL;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

final class e
implements EntityResolver {
    final WsdlEntityResolver a = new WsdlEntityResolver(true);
    final SimpleHttpClient b;
    final Pair<String, Integer> c;
    final PasswordAuthentication d;
    private static final String[] e;

    e(SimpleHttpClient simpleHttpClient, String string) {
        this.b = simpleHttpClient;
        this.d = ResourceUtils.getPasswordAuthentication((String)string);
        this.c = this.d != null ? this.b(string) : null;
    }

    @Override
    public InputSource resolveEntity(String string, String string2) throws SAXException, IOException {
        InputSource inputSource = this.a.resolveEntity(string, string2);
        if (inputSource == null) {
            String string3 = this.a(string2);
            inputSource = new InputSource();
            inputSource.setPublicId(string);
            inputSource.setSystemId(string2);
            inputSource.setCharacterStream(new StringReader(string3));
        }
        return inputSource;
    }

    public String addAuthentication(String string) {
        String string2 = string;
        if (this.c != null && this.c.equals(this.b(string))) {
            string2 = ResourceUtils.addPasswordAuthentication((String)string2, (PasswordAuthentication)this.d);
        }
        return string2;
    }

    private String a(String string) throws IOException {
        String string2;
        block11: {
            SimpleHttpClient.SimpleHttpResponse simpleHttpResponse;
            GenericHttpRequestParams genericHttpRequestParams;
            String[] stringArray;
            block12: {
                string2 = null;
                stringArray = e;
                boolean bl2 = string.toLowerCase().startsWith(stringArray[2]);
                boolean bl3 = string.toLowerCase().startsWith(stringArray[0]);
                try {
                    if (!bl2 && !bl3) break block11;
                }
                catch (IOException iOException) {
                    throw com.l7tech.server.uddi.e.a(iOException);
                }
                URL uRL = new URL(string);
                genericHttpRequestParams = new GenericHttpRequestParams(uRL);
                try {
                    try {
                        if (this.c == null || !this.c.equals(this.b(string))) break block12;
                    }
                    catch (IOException iOException) {
                        throw com.l7tech.server.uddi.e.a(iOException);
                    }
                    genericHttpRequestParams.setPasswordAuthentication(this.d);
                    genericHttpRequestParams.setPreemptiveAuthentication(true);
                }
                catch (IOException iOException) {
                    throw com.l7tech.server.uddi.e.a(iOException);
                }
            }
            if ((simpleHttpResponse = this.b.get(genericHttpRequestParams)).getStatus() == 200) {
                string2 = simpleHttpResponse.getString();
            } else {
                stringArray = e;
                throw new IOException(stringArray[1] + string + stringArray[4] + simpleHttpResponse.getStatus() + ".");
            }
        }
        try {
            if (string2 == null) {
                throw new IOException(e[7] + string + e[6]);
            }
        }
        catch (IOException iOException) {
            throw com.l7tech.server.uddi.e.a(iOException);
        }
        return string2;
    }

    private Pair<String, Integer> b(String string) {
        Pair pair;
        block9: {
            pair = null;
            try {
                int n2;
                String string2;
                block7: {
                    block8: {
                        URL uRL = new URL(string);
                        string2 = uRL.getHost();
                        n2 = uRL.getPort();
                        try {
                            if (n2 != -1) break block7;
                            if (!string.toLowerCase().startsWith(e[3])) break block8;
                        }
                        catch (MalformedURLException malformedURLException) {
                            throw com.l7tech.server.uddi.e.a(malformedURLException);
                        }
                        n2 = 80;
                        break block7;
                    }
                    if (string.toLowerCase().startsWith(e[5])) {
                        n2 = 443;
                    }
                }
                try {
                    if (string2 == null || n2 <= -1) break block9;
                }
                catch (MalformedURLException malformedURLException) {
                    throw com.l7tech.server.uddi.e.a(malformedURLException);
                }
                pair = new Pair((Object)string2.toLowerCase(), (Object)n2);
            }
            catch (MalformedURLException malformedURLException) {
                // empty catch block
            }
        }
        return pair;
    }

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

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[8];
                var3_1 = 0;
                var2_2 = "Ymu;\bL\u001brvt'\u001fVq^m!*\u0018\u0015zBj!9\u001e\u0005pDkb.[Q\u0005Ymu;A\u0005Ymu;A\u000f\u00165!#\u000f\u0002o\u0011ju*\u000f\u0003l\u0011\u0006Ymu;\bL";
                var4_3 = "Ymu;\bL\u001brvt'\u001fVq^m!*\u0018\u0015zBj!9\u001e\u0005pDkb.[Q\u0005Ymu;A\u0005Ymu;A\u000f\u00165!#\u000f\u0002o\u0011ju*\u000f\u0003l\u0011\u0006Ymu;\bL".length();
                var1_4 = 6;
                var0_5 = -1;
lbl7:
                // 2 sources

                while (true) {
                    v0 = 45;
                    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.uddi.e.a(v0, com.l7tech.server.uddi.e.c(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "\u007f^\u001b\u001b\u001f\u001dNv?\u00187\u0004HCq|\u0013+\u0003HPwl\u0019-\u0002\u000bG28";
                    var4_3 = "\u007f^\u001b\u001b\u001f\u001dNv?\u00187\u0004HCq|\u0013+\u0003HPwl\u0019-\u0002\u000bG28".length();
                    var1_4 = 2;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 68;
                        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.uddi.e.a(v0, com.l7tech.server.uddi.e.c(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.uddi.e.e = var5;
    }

    private static char[] c(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x32);
        }
        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 -> 28;
                    case 1 -> 52;
                    case 2 -> 44;
                    case 3 -> 102;
                    case 4 -> 86;
                    case 5 -> 91;
                    default -> 50;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

