/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.common.ftp.FtpCommand
 *  com.l7tech.message.FtpRequestKnob
 *  com.l7tech.util.InetAddressUtil
 *  org.apache.ftpserver.ftplet.User
 */
package com.l7tech.server.transport.ftp;

import com.l7tech.common.ftp.FtpCommand;
import com.l7tech.message.FtpRequestKnob;
import com.l7tech.server.transport.ftp.AbstractFtpRequestProcessor;
import com.l7tech.util.InetAddressUtil;
import java.io.IOException;
import java.net.InetAddress;
import java.net.PasswordAuthentication;
import java.security.cert.X509Certificate;
import org.apache.ftpserver.ftplet.User;

class a
implements FtpRequestKnob {
    final int val$port;
    final InetAddress val$clientAddress;
    final InetAddress val$serverAddress;
    final FtpCommand val$command;
    final String val$argument;
    final String val$path;
    final boolean val$secure;
    final boolean val$unique;
    final User val$user;
    private static final String[] a;

    /*
     * Ignored method signature, as it can't be verified against descriptor
     */
    a(AbstractFtpRequestProcessor abstractFtpRequestProcessor, int n2, InetAddress inetAddress, InetAddress inetAddress2, FtpCommand ftpCommand, String string, String string2, boolean bl2, boolean bl3, User user) {
        this.val$port = n2;
        this.val$clientAddress = inetAddress;
        this.val$serverAddress = inetAddress2;
        this.val$command = ftpCommand;
        this.val$argument = string;
        this.val$path = string2;
        this.val$secure = bl2;
        this.val$unique = bl3;
        this.val$user = user;
    }

    public int getLocalPort() {
        return this.getLocalListenerPort();
    }

    public int getLocalListenerPort() {
        return this.val$port;
    }

    public String getRemoteAddress() {
        return this.val$clientAddress.getHostAddress();
    }

    public String getRemoteHost() {
        return this.val$clientAddress.getHostAddress();
    }

    public int getRemotePort() {
        return 0;
    }

    public String getLocalAddress() {
        return this.val$serverAddress.getHostAddress();
    }

    public String getLocalHost() {
        return this.val$serverAddress.getHostAddress();
    }

    public String getCommand() {
        return this.val$command.toString();
    }

    public String getArgument() {
        return this.val$argument;
    }

    public String getPath() {
        return this.val$path;
    }

    public String getRequestUri() {
        return this.val$path;
    }

    public String getRequestUrl() {
        String string;
        StringBuilder stringBuilder = new StringBuilder();
        if (this.val$secure) {
            String[] stringArray = a;
            string = stringArray[1];
        } else {
            String[] stringArray = a;
            string = stringArray[2];
        }
        stringBuilder.append(string);
        stringBuilder.append(a[0]);
        stringBuilder.append(InetAddressUtil.getHostForUrl((String)this.val$serverAddress.getHostAddress()));
        stringBuilder.append(":");
        stringBuilder.append(this.val$port);
        stringBuilder.append(this.val$path);
        if (!this.val$path.endsWith("/")) {
            stringBuilder.append("/");
        }
        stringBuilder.append(this.val$argument);
        return stringBuilder.toString();
    }

    public X509Certificate[] getClientCertificate() throws IOException {
        return null;
    }

    public boolean isSecure() {
        return this.val$secure;
    }

    public boolean isUnique() {
        return this.val$unique;
    }

    public PasswordAuthentication getCredentials() {
        PasswordAuthentication passwordAuthentication = null;
        if (this.val$user.getPassword() != null) {
            passwordAuthentication = new PasswordAuthentication(this.val$user.getName(), this.val$user.getPassword().toCharArray());
        }
        return passwordAuthentication;
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[3];
        int n2 = 0;
        String string = "<t\u0015\u0004`/Js\u0003`/J";
        int n3 = "<t\u0015\u0004`/Js\u0003`/J".length();
        int n4 = 3;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = com.l7tech.server.transport.ftp.a.a(108, com.l7tech.server.transport.ftp.a.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                a = stringArray;
                return;
            }
            n4 = string.charAt(n5);
        }
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x36);
        }
        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 -> 106;
                    case 1 -> 55;
                    case 2 -> 86;
                    case 3 -> 108;
                    case 4 -> 118;
                    case 5 -> 6;
                    default -> 54;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

