/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.jscape.inet.ftp.Ftp
 *  com.jscape.inet.ftp.FtpException
 *  com.jscape.inet.ftp.FtpListener
 *  com.jscape.inet.ftps.Ftps
 *  com.jscape.inet.ftps.FtpsCertificateVerifier
 *  com.l7tech.common.io.PermissiveX509TrustManager
 *  com.l7tech.common.io.SingleCertX509KeyManager
 *  com.l7tech.gateway.common.security.keystore.SsgKeyEntry
 *  com.l7tech.gateway.common.transport.ftp.FtpClientConfig
 *  com.l7tech.gateway.common.transport.ftp.FtpClientConfigImpl
 *  com.l7tech.gateway.common.transport.ftp.FtpCredentialsSource
 *  com.l7tech.gateway.common.transport.ftp.FtpSecurity
 *  com.l7tech.gateway.common.transport.ftp.FtpTestException
 *  com.l7tech.gateway.common.transport.ftp.FtpUtils
 *  com.l7tech.gateway.common.transport.ftp.FtpUtils$FtpUploadSizeListener
 *  com.l7tech.security.prov.JceProvider
 *  com.l7tech.util.ExceptionUtils
 *  com.l7tech.util.HexUtils
 */
package com.l7tech.server.transport.ftp;

import com.jscape.inet.ftp.Ftp;
import com.jscape.inet.ftp.FtpException;
import com.jscape.inet.ftp.FtpListener;
import com.jscape.inet.ftps.Ftps;
import com.jscape.inet.ftps.FtpsCertificateVerifier;
import com.l7tech.common.io.PermissiveX509TrustManager;
import com.l7tech.common.io.SingleCertX509KeyManager;
import com.l7tech.gateway.common.security.keystore.SsgKeyEntry;
import com.l7tech.gateway.common.transport.ftp.FtpClientConfig;
import com.l7tech.gateway.common.transport.ftp.FtpClientConfigImpl;
import com.l7tech.gateway.common.transport.ftp.FtpCredentialsSource;
import com.l7tech.gateway.common.transport.ftp.FtpSecurity;
import com.l7tech.gateway.common.transport.ftp.FtpTestException;
import com.l7tech.gateway.common.transport.ftp.FtpUtils;
import com.l7tech.security.prov.JceProvider;
import com.l7tech.server.DefaultKey;
import com.l7tech.server.transport.ftp.f;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.HexUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.UnknownHostException;
import java.security.GeneralSecurityException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.security.SecureRandom;
import java.security.UnrecoverableKeyException;
import java.util.ArrayList;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

public class FtpClientUtils {
    private static final Logger a;
    private static final Random b;
    private static final SecureRandom c;
    private static final String[] d;

    private FtpClientUtils() {
    }

    public static FtpClientConfig newConfig(String string) {
        return FtpClientConfigImpl.newFtpConfig((String)string);
    }

    public static Ftps newFtpsClient(FtpClientConfig ftpClientConfig) throws FtpException {
        return FtpClientUtils.newFtpsClient(ftpClientConfig, null, null, null);
    }

    public static Ftps newFtpsClient(FtpClientConfig ftpClientConfig, DefaultKey defaultKey) throws FtpException {
        return FtpClientUtils.newFtpsClient(ftpClientConfig, defaultKey, null, null);
    }

    public static Ftps newFtpsClient(FtpClientConfig ftpClientConfig, X509TrustManager x509TrustManager, HostnameVerifier hostnameVerifier) throws FtpException {
        return FtpClientUtils.newFtpsClient(ftpClientConfig, null, x509TrustManager, hostnameVerifier);
    }

    /*
     * Unable to fully structure code
     */
    public static Ftps newFtpsClient(FtpClientConfig var0, DefaultKey var1_1, X509TrustManager var2_2, HostnameVerifier var3_3) throws FtpException {
        block63: {
            block62: {
                block58: {
                    block59: {
                        block57: {
                            try {
                                if (FtpCredentialsSource.SPECIFIED != var0.getCredentialsSource()) {
                                    throw new IllegalStateException(FtpClientUtils.d[1]);
                                }
                            }
                            catch (Exception v0) {
                                throw FtpClientUtils.a(v0);
                            }
                            try {
                                if (FtpSecurity.FTP_UNSECURED == var0.getSecurity()) {
                                    throw new NullPointerException(FtpClientUtils.d[19]);
                                }
                            }
                            catch (Exception v1) {
                                throw FtpClientUtils.a(v1);
                            }
                            if (!var0.isVerifyServerCert()) break block57;
                            try {
                                block65: {
                                    if (var2_2 != null) break block57;
                                    break block65;
                                    catch (Exception v2) {
                                        throw FtpClientUtils.a(v2);
                                    }
                                }
                                throw new NullPointerException(FtpClientUtils.d[10]);
                            }
                            catch (Exception v3) {
                                throw FtpClientUtils.a(v3);
                            }
                        }
                        var4_4 = new Ftps(var0.getHost(), var0.getUser(), var0.getPass(), var0.getPort());
                        try {
                            if (var0.getDebugStream() != null) {
                                var4_4.setDebugStream(var0.getDebugStream());
                                var4_4.setDebug(true);
                            }
                        }
                        catch (Exception v4) {
                            throw FtpClientUtils.a(v4);
                        }
                        var4_4.setTimeout(var0.getTimeout());
                        var5_5 = null;
                        if (var0.isVerifyServerCert()) {
                            var5_5 = new f(var2_2, var3_3, var0.getHost());
                            var4_4.setFtpsCertificateVerifier((FtpsCertificateVerifier)var5_5);
                        }
                        if (!var0.isUseClientCert()) break block58;
                        try {
                            block66: {
                                if (var1_1 != null) break block59;
                                break block66;
                                catch (Exception v5) {
                                    throw FtpClientUtils.a(v5);
                                }
                            }
                            throw new IllegalArgumentException(FtpClientUtils.d[12]);
                        }
                        catch (Exception v6) {
                            throw FtpClientUtils.a(v6);
                        }
                    }
                    try {
                        block61: {
                            block60: {
                                if (var0.getClientCertAlias() == null) {
                                    try {
                                        var8_6 = var1_1.getClientSslInfo();
                                    }
                                    catch (Exception var9_9) {
                                        var8_6 = var1_1.getSslInfo();
                                    }
                                    var7_11 = var8_6;
                                } else {
                                    var7_11 = var1_1.lookupKeyByKeyAlias(var0.getClientCertAlias(), var0.getClientCertId());
                                }
                                var6_17 = var7_11;
                                var8_6 = var6_17.getCertificateChain();
                                var9_10 = var6_17.getPrivateKey();
                                var10_18 = new byte[16];
                                FtpClientUtils.b.nextBytes(var10_18);
                                var11_19 = HexUtils.encodeBase64((byte[])var10_18);
                                var12_20 = JceProvider.getInstance().getProviderFor(JceProvider.SERVICE_KEYSTORE_PKCS12);
                                try {
                                    if (var12_20 != null) break block60;
                                    v7 = KeyStore.getInstance(FtpClientUtils.d[14]);
                                    break block61;
                                }
                                catch (Exception v8) {
                                    throw FtpClientUtils.a(v8);
                                }
                            }
                            var15_21 = FtpClientUtils.d;
                            v7 = KeyStore.getInstance(var15_21[6], var12_20);
                        }
                        var13_23 = v7;
                        var13_23.load(null, null);
                        var15_21 = FtpClientUtils.d;
                        var14_24 = var15_21[3];
                        try {
                            var13_23.setKeyEntry(var15_21[18], var9_10, var11_19.toCharArray(), var8_6);
                            var4_4.setClientCertificates(var13_23, var11_19);
                            if (!FtpClientUtils.a.isLoggable(Level.FINE)) ** GOTO lbl103
                            FtpClientUtils.a.fine(var15_21[9] + var0.getClientCertAlias() + ")");
                        }
                        catch (Exception v9) {
                            throw FtpClientUtils.a(v9);
                        }
                    }
                    catch (Exception var7_12) {
                        var15_22 = FtpClientUtils.d;
                        var8_7 = new StringBuilder(var15_22[20] + var0.getClientCertAlias() + var15_22[15] + var7_12.toString());
                        try {
                            if (var7_12.getCause() != null) {
                                var8_7.append(var15_22[16]).append(var7_12.getCause().toString());
                            }
                        }
                        catch (Exception v10) {
                            throw FtpClientUtils.a(v10);
                        }
                        throw new FtpException(var8_7.toString());
                    }
                }
                var6_17 = null;
lbl103:
                // 3 sources

                try {
                    if (FtpSecurity.FTPS_EXPLICIT != var0.getSecurity()) break block62;
                    FtpClientUtils.a(var4_4, var6_17, var2_2);
                    FtpClientUtils.a(var4_4);
                    break block63;
                }
                catch (IllegalStateException v11) {
                    throw FtpClientUtils.a(v11);
                }
                {
                    catch (FtpException var7_13) {
                        try {
                            if (var7_13.getCause() instanceof UnknownHostException) {
                                throw var7_13;
                            }
                        }
                        catch (Exception v12) {
                            throw FtpClientUtils.a(v12);
                        }
                        try {
                            if (var5_5 != null) {
                                var5_5.throwIfFailed();
                            }
                        }
                        catch (Exception v13) {
                            throw FtpClientUtils.a(v13);
                        }
                        try {
                            if (FtpClientUtils.a.isLoggable(Level.FINE)) {
                                FtpClientUtils.a.fine(FtpClientUtils.d[5]);
                            }
                        }
                        catch (Exception v14) {
                            throw FtpClientUtils.a(v14);
                        }
                        var4_4.setConnectionType(Ftps.AUTH_SSL);
                        FtpClientUtils.a(var4_4);
                        break block63;
                    }
                    catch (GeneralSecurityException var7_14) {
                        var15_21 = FtpClientUtils.d;
                        throw new FtpException(var15_21[22] + ExceptionUtils.getMessage((Throwable)var7_14), (Throwable)var7_14);
                    }
                }
            }
            var4_4.setConnectionType(Ftps.IMPLICIT_SSL);
            try {
                FtpClientUtils.a(var4_4, var6_17, var2_2);
                FtpClientUtils.a(var4_4);
            }
            catch (FtpException var7_15) {
                try {
                    if (var5_5 != null) {
                        var5_5.throwIfFailed();
                    }
                }
                catch (Exception v15) {
                    throw FtpClientUtils.a(v15);
                }
                throw var7_15;
            }
            catch (GeneralSecurityException var7_16) {
                throw new FtpException(FtpClientUtils.d[7] + ExceptionUtils.getMessage((Throwable)var7_16), (Throwable)var7_16);
            }
        }
        var7_11 = var0.getDirectory();
        try {
            block64: {
                if (var7_11 == null) break block64;
                try {
                    block67: {
                        if (var7_11.length() == 0) break block64;
                        break block67;
                        catch (Exception v16) {
                            throw FtpClientUtils.a(v16);
                        }
                    }
                    var4_4.setDir((String)var7_11);
                }
                catch (Exception v17) {
                    throw FtpClientUtils.a(v17);
                }
            }
            var4_4.setAuto(false);
            var4_4.setBinary();
        }
        catch (FtpException var8_8) {
            var4_4.disconnect();
            throw var8_8;
        }
        return var4_4;
    }

    private static void a(Ftps ftps, SsgKeyEntry ssgKeyEntry, TrustManager trustManager) throws NoSuchAlgorithmException, UnrecoverableKeyException, KeyManagementException {
        ArrayList<TrustManager> arrayList;
        ArrayList<SingleCertX509KeyManager> arrayList2;
        SSLContext sSLContext;
        block8: {
            block7: {
                SSLContext sSLContext2;
                Provider provider = JceProvider.getInstance().getProviderFor(JceProvider.SERVICE_TLS10);
                try {
                    sSLContext2 = provider == null ? SSLContext.getInstance(d[2]) : SSLContext.getInstance(d[17], provider);
                }
                catch (NoSuchAlgorithmException noSuchAlgorithmException) {
                    throw FtpClientUtils.a(noSuchAlgorithmException);
                }
                sSLContext = sSLContext2;
                arrayList2 = new ArrayList<SingleCertX509KeyManager>();
                try {
                    if (ssgKeyEntry != null) {
                        arrayList2.add(new SingleCertX509KeyManager(ssgKeyEntry.getCertificateChain(), ssgKeyEntry.getPrivateKey()));
                    }
                }
                catch (NoSuchAlgorithmException noSuchAlgorithmException) {
                    throw FtpClientUtils.a(noSuchAlgorithmException);
                }
                arrayList = new ArrayList<TrustManager>();
                try {
                    if (trustManager == null) break block7;
                    arrayList.add(trustManager);
                    break block8;
                }
                catch (NoSuchAlgorithmException noSuchAlgorithmException) {
                    throw FtpClientUtils.a(noSuchAlgorithmException);
                }
            }
            arrayList.add((TrustManager)new PermissiveX509TrustManager());
        }
        sSLContext.init(arrayList2.toArray(new KeyManager[arrayList2.size()]), arrayList.toArray(new TrustManager[arrayList.size()]), c);
        ftps.setContext(sSLContext);
    }

    private static void a(Ftps ftps) throws FtpException {
        try {
            ftps.connect();
        }
        catch (FtpException ftpException) {
            FtpException ftpException2;
            Throwable throwable = ftpException.getCause();
            if (throwable instanceof UnknownHostException) {
                ftpException2 = new FtpException(d[23] + ftps.getHostname(), throwable);
            }
            throw ftpException2;
        }
    }

    /*
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    public static void testFtpsConnection(FtpClientConfig ftpClientConfig, DefaultKey defaultKey, X509TrustManager x509TrustManager, HostnameVerifier hostnameVerifier) throws FtpTestException {
        ByteArrayOutputStream byteArrayOutputStream = null;
        if (ftpClientConfig.getDebugStream() == null) {
            byteArrayOutputStream = new ByteArrayOutputStream();
            ftpClientConfig.setDebugStream(new PrintStream(byteArrayOutputStream));
        }
        Ftps ftps = null;
        try {
            ftps = FtpClientUtils.newFtpsClient(ftpClientConfig, defaultKey, x509TrustManager, hostnameVerifier);
        }
        catch (FtpException ftpException) {
            try {
                String string;
                String string2;
                FtpTestException ftpTestException;
                FtpTestException ftpTestException2;
                try {
                    FtpTestException ftpTestException3;
                    ftpTestException2 = ftpTestException3;
                    ftpTestException = ftpTestException3;
                    string2 = ftpException.getMessage();
                    string = byteArrayOutputStream != null ? byteArrayOutputStream.toString() : null;
                }
                catch (FtpException ftpException2) {
                    throw FtpClientUtils.a((Exception)((Object)ftpException2));
                }
                ftpTestException2(string2, string);
                throw ftpTestException;
            }
            catch (Throwable throwable) {
                try {
                    if (ftps != null) {
                        ftps.disconnect();
                    }
                }
                catch (FtpException ftpException3) {
                    throw FtpClientUtils.a((Exception)((Object)ftpException3));
                }
                try {
                    if (byteArrayOutputStream == null) throw throwable;
                    ftpClientConfig.getDebugStream().close();
                    ftpClientConfig.setDebugStream(null);
                    throw throwable;
                }
                catch (FtpException ftpException4) {
                    throw FtpClientUtils.a((Exception)((Object)ftpException4));
                }
            }
        }
        try {
            if (ftps != null) {
                ftps.disconnect();
            }
        }
        catch (FtpException ftpException) {
            throw FtpClientUtils.a((Exception)((Object)ftpException));
        }
        try {
            if (byteArrayOutputStream == null) return;
            ftpClientConfig.getDebugStream().close();
            ftpClientConfig.setDebugStream(null);
            return;
        }
        catch (FtpException ftpException) {
            throw FtpClientUtils.a((Exception)((Object)ftpException));
        }
    }

    public static void upload(FtpClientConfig ftpClientConfig, InputStream inputStream, long l2, String string) throws FtpException {
        FtpClientUtils.upload(ftpClientConfig, inputStream, l2, string, null, null, null);
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public static void upload(FtpClientConfig ftpClientConfig, InputStream inputStream, long l2, String string, DefaultKey defaultKey, X509TrustManager x509TrustManager, HostnameVerifier hostnameVerifier) throws FtpException {
        block10: {
            block9: {
                try {
                    if (FtpSecurity.FTP_UNSECURED != ftpClientConfig.getSecurity()) break block9;
                    FtpUtils.upload((FtpClientConfig)ftpClientConfig, (InputStream)inputStream, (long)l2, (String)string);
                    break block10;
                }
                catch (FtpException ftpException) {
                    throw FtpClientUtils.a((Exception)((Object)ftpException));
                }
            }
            Ftps ftps = FtpClientUtils.newFtpsClient(ftpClientConfig, defaultKey, x509TrustManager, hostnameVerifier);
            FtpUtils.FtpUploadSizeListener ftpUploadSizeListener = new FtpUtils.FtpUploadSizeListener();
            try {
                ftps.addFtpListener((FtpListener)ftpUploadSizeListener);
                ftps.upload(inputStream, string);
            }
            finally {
                ftps.disconnect();
            }
            try {
                if (ftpUploadSizeListener.isError()) {
                    throw new FtpException(d[11] + string + d[21] + ftpUploadSizeListener.getError() + d[4]);
                }
            }
            catch (FtpException ftpException) {
                throw FtpClientUtils.a((Exception)((Object)ftpException));
            }
            if (ftpUploadSizeListener.getSize() < l2) {
                long l3 = ftpUploadSizeListener.getSize();
                String string2 = string;
                String[] stringArray = d;
                throw new FtpException(stringArray[0] + string2 + stringArray[13] + l3 + stringArray[8]);
            }
        }
    }

    public static OutputStream getUploadOutputStream(FtpClientConfig ftpClientConfig, String string) throws FtpException {
        return FtpClientUtils.getUploadOutputStream(ftpClientConfig, string, null, null, null);
    }

    public static OutputStream getUploadOutputStream(FtpClientConfig ftpClientConfig, String string, DefaultKey defaultKey, X509TrustManager x509TrustManager, HostnameVerifier hostnameVerifier) throws FtpException {
        if (FtpSecurity.FTP_UNSECURED == ftpClientConfig.getSecurity()) {
            Ftp ftp = FtpUtils.newFtpClient((FtpClientConfig)ftpClientConfig);
            return ftp.getOutputStream(string, 0L, false);
        }
        Ftps ftps = FtpClientUtils.newFtpsClient(ftpClientConfig, defaultKey, x509TrustManager, hostnameVerifier);
        try {
            return ftps.getOutputStream(string, 0L, false);
        }
        catch (IOException iOException) {
            throw new FtpException(d[24], (Throwable)iOException);
        }
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[25];
                var3_1 = 0;
                var2_2 = "53_M:v>0;]Fu%\b\u0010(VIn4\b5\u000ec\by>F\u001d?P\\s>FS3U\by#M\u0017?]\\s0D\u0000zRZ\u007fqF\u001c.\u0013[j4K\u001a<ZM~\u007f\u0003'\u0016`\u0003\u0015.C\u0002Tt>&4RJv4\b\u00075\u0013Ku?F\u00169G\bo\"A\u001d=\u0013nN\u0001{S\u001bf|Rq|?\t\u001d\bH4\\\u0001#ZF}q_\u001a.[\b[\u0004|;z`{V\u007f\u0006#\u0011p{+c%&4RJv4\b\u00075\u0013At8\\\u001a;_A`4\b'\u0016`\bI\u0002d05]\\\u007f)\\Iz\u0007S8J\\\u007f\"\u0006P2)@A}?M\u0017zCZs'I\u0007?\u0013C\u007f(\b\u00124W\by4Z\u00073UAy0\\\u0016zUGhqn'\n`\by=A\u00164G\b{$\\\u001b?]\\s2I\u00073\\F4q\u0000\u0018?J\b{=A\u0012)\u000eV ?A^\u007f#\b\u0010?A\\s7A\u0010;GM:<I\u001d;TMhqK\u00124]GnqJ\u0016z]]v=\b\u001a<\u0013[\u007f'M\u0001zPMh%A\u00153PIn4\b\u0005;_A~0\\\u001a5]\bs\"\b\u0001?B]s#M\u0017t\u000653_M:v\\2/G@\u007f?\\\u001a9R\\s>FS-Z\\rqK\u001f3VFnqK\u0016(GA|8K\u0012.V\bh4Y\u0006?@\\\u007f5\u0004S8F\\:yL\u0016<R]v%\u0001S1VQ:7A\u001d>VZ:&I\u0000z]GnqX\u00015EA~4L]\u0016TzFXv>I\u0017zGZo?K\u0012.VL:%GS\u0006#\u0011p{+c\u0016ZzUGhqI\u0006.[Mt%A\u0010;GAu?\u0012S\u0002Iz\u0003'\u0016`\u0003\u0015.CE0;]Fu%\b\u0014?]Mh0\\\u0016zu|J\u0002\b\u00105]F\u007f2\\\u001a5]\b|>ZS.[M:2G\u001d<ZOo#M\u0017zu|JqK\u001c4UA}$Z\u0012.ZGt\u007f30;]Fu%\b\u0010(VIn4\b\u0018?J[n>Z\u0016zUZu<\b\u0003(Z^{%MS1VQ:yC\u0016#\u0013Iv8I\u0000g\u0010TzFXv>I\u0017zVZh>ZS}%&4RJv4\b\u00075\u0013At8\\\u001a;_A`4\b'\u0016`\bI\u0002d05]\\\u007f)\\Iz";
                var4_3 = "53_M:v>0;]Fu%\b\u0010(VIn4\b5\u000ec\by>F\u001d?P\\s>FS3U\by#M\u0017?]\\s0D\u0000zRZ\u007fqF\u001c.\u0013[j4K\u001a<ZM~\u007f\u0003'\u0016`\u0003\u0015.C\u0002Tt>&4RJv4\b\u00075\u0013Ku?F\u00169G\bo\"A\u001d=\u0013nN\u0001{S\u001bf|Rq|?\t\u001d\bH4\\\u0001#ZF}q_\u001a.[\b[\u0004|;z`{V\u007f\u0006#\u0011p{+c%&4RJv4\b\u00075\u0013At8\\\u001a;_A`4\b'\u0016`\bI\u0002d05]\\\u007f)\\Iz\u0007S8J\\\u007f\"\u0006P2)@A}?M\u0017zCZs'I\u0007?\u0013C\u007f(\b\u00124W\by4Z\u00073UAy0\\\u0016zUGhqn'\n`\by=A\u00164G\b{$\\\u001b?]\\s2I\u00073\\F4q\u0000\u0018?J\b{=A\u0012)\u000eV ?A^\u007f#\b\u0010?A\\s7A\u0010;GM:<I\u001d;TMhqK\u00124]GnqJ\u0016z]]v=\b\u001a<\u0013[\u007f'M\u0001zPMh%A\u00153PIn4\b\u0005;_A~0\\\u001a5]\bs\"\b\u0001?B]s#M\u0017t\u000653_M:v\\2/G@\u007f?\\\u001a9R\\s>FS-Z\\rqK\u001f3VFnqK\u0016(GA|8K\u0012.V\bh4Y\u0006?@\\\u007f5\u0004S8F\\:yL\u0016<R]v%\u0001S1VQ:7A\u001d>VZ:&I\u0000z]GnqX\u00015EA~4L]\u0016TzFXv>I\u0017zGZo?K\u0012.VL:%GS\u0006#\u0011p{+c\u0016ZzUGhqI\u0006.[Mt%A\u0010;GAu?\u0012S\u0002Iz\u0003'\u0016`\u0003\u0015.CE0;]Fu%\b\u0014?]Mh0\\\u0016zu|J\u0002\b\u00105]F\u007f2\\\u001a5]\b|>ZS.[M:2G\u001d<ZOo#M\u0017zu|JqK\u001c4UA}$Z\u0012.ZGt\u007f30;]Fu%\b\u0010(VIn4\b\u0018?J[n>Z\u0016zUZu<\b\u0003(Z^{%MS1VQ:yC\u0016#\u0013Iv8I\u0000g\u0010TzFXv>I\u0017zVZh>ZS}%&4RJv4\b\u00075\u0013At8\\\u001a;_A`4\b'\u0016`\bI\u0002d05]\\\u007f)\\Iz".length();
                var1_4 = 6;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = FtpClientUtils.a(v0, FtpClientUtils.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "UG+5\u0006U5 A/(\u001d\u0018{#E[24\u001b\u0002<e]42\u0007E{uY,4\bF{o\\4+\u001cV{s]2>\bOu";
                    var4_3 = "UG+5\u0006U5 A/(\u001d\u0018{#E[24\u001b\u0002<e]42\u0007E{uY,4\bF{o\\4+\u001cV{s]2>\bOu".length();
                    var1_4 = 14;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 5;
                        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++] = FtpClientUtils.a(v0, FtpClientUtils.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;
            }
        }
        FtpClientUtils.d = var5;
        FtpClientUtils.a = Logger.getLogger(FtpClientUtils.class.getName());
        FtpClientUtils.b = new Random(System.currentTimeMillis());
        FtpClientUtils.c = new SecureRandom();
    }

    private static Exception a(Exception exception) {
        return exception;
    }

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

