package com.l7tech.server.transport.ftp;

import com.l7tech.gateway.common.transport.SsgConnector;
import com.l7tech.server.MessageProcessor;
import com.l7tech.server.StashManagerFactory;
import com.l7tech.server.transport.ListenerException;
import com.l7tech.server.util.EventChannel;
import com.l7tech.server.util.SoapFaultManager;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.ThreadPoolExecutor.AbortPolicy;
import org.apache.ftpserver.ConnectionConfig;
import org.springframework.beans.factory.annotation.Autowired;

public class FtpRequestProcessorFactory {
   @Autowired
   private MessageProcessor a;
   @Autowired
   private SoapFaultManager b;
   @Autowired
   private StashManagerFactory c;
   @Autowired
   private EventChannel d;
   private static final String[] e;

   public FtpRequestProcessor create(SsgConnector param1, ConnectionConfig param2) throws ListenerException {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 00: aload 1
      // 01: getstatic com/l7tech/gateway/common/transport/SsgConnector.PROP_SUPPORT_EXTENDED_FTP_COMMANDS Ljava/lang/String;
      // 04: invokevirtual com/l7tech/gateway/common/transport/SsgConnector.getBooleanProperty (Ljava/lang/String;)Z
      // 07: istore 3
      // 08: aload 1
      // 09: getstatic com/l7tech/objectmodel/EntityType.SERVICE Lcom/l7tech/objectmodel/EntityType;
      // 0c: getstatic com/l7tech/gateway/common/transport/SsgConnector.PROP_HARDWIRED_SERVICE_ID Ljava/lang/String;
      // 0f: aconst_null
      // 10: invokevirtual com/l7tech/gateway/common/transport/SsgConnector.getGoidProperty (Lcom/l7tech/objectmodel/EntityType;Ljava/lang/String;Lcom/l7tech/objectmodel/Goid;)Lcom/l7tech/objectmodel/Goid;
      // 13: astore 4
      // 15: aconst_null
      // 16: aload 4
      // 18: if_acmpne 37
      // 1b: iload 3
      // 1c: ifeq 37
      // 1f: goto 26
      // 22: invokestatic com/l7tech/server/transport/ftp/FtpRequestProcessorFactory.a (Ljava/io/IOException;)Ljava/io/IOException;
      // 25: athrow
      // 26: new com/l7tech/server/transport/ListenerException
      // 29: dup
      // 2a: getstatic com/l7tech/server/transport/ftp/FtpRequestProcessorFactory.e [Ljava/lang/String;
      // 2d: bipush 1
      // 2e: aaload
      // 2f: invokespecial com/l7tech/server/transport/ListenerException.<init> (Ljava/lang/String;)V
      // 32: athrow
      // 33: invokestatic com/l7tech/server/transport/ftp/FtpRequestProcessorFactory.a (Ljava/io/IOException;)Ljava/io/IOException;
      // 36: athrow
      // 37: aload 1
      // 38: getstatic com/l7tech/gateway/common/transport/SsgConnector.PROP_OVERRIDE_CONTENT_TYPE Ljava/lang/String;
      // 3b: invokevirtual com/l7tech/gateway/common/transport/SsgConnector.getProperty (Ljava/lang/String;)Ljava/lang/String;
      // 3e: astore 5
      // 40: aconst_null
      // 41: astore 6
      // 43: aload 5
      // 45: ifnull 4f
      // 48: aload 5
      // 4a: invokestatic com/l7tech/common/mime/ContentTypeHeader.parseValue (Ljava/lang/String;)Lcom/l7tech/common/mime/ContentTypeHeader;
      // 4d: astore 6
      // 4f: goto 71
      // 52: astore 7
      // 54: new com/l7tech/server/transport/ListenerException
      // 57: dup
      // 58: aload 5
      // 5a: getstatic com/l7tech/server/transport/ftp/FtpRequestProcessorFactory.e [Ljava/lang/String;
      // 5d: astore 10
      // 5f: aload 10
      // 61: bipush 0
      // 62: aaload
      // 63: swap
      // 64: aload 10
      // 66: bipush 2
      // 67: aaload
      // 68: invokedynamic makeConcatWithConstants (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; bsm=java/lang/invoke/StringConcatFactory.makeConcatWithConstants (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite; args=[ "\u0001\u0001\u0001" ]
      // 6d: invokespecial com/l7tech/server/transport/ListenerException.<init> (Ljava/lang/String;)V
      // 70: athrow
      // 71: aload 0
      // 72: aload 2
      // 73: invokevirtual com/l7tech/server/transport/ftp/FtpRequestProcessorFactory.a (Lorg/apache/ftpserver/ConnectionConfig;)Ljava/util/concurrent/ExecutorService;
      // 76: astore 7
      // 78: aload 1
      // 79: getstatic com/l7tech/gateway/common/transport/SsgConnector.PROP_REQUEST_SIZE_LIMIT Ljava/lang/String;
      // 7c: ldc2_w -1
      // 7f: invokevirtual com/l7tech/gateway/common/transport/SsgConnector.getLongProperty (Ljava/lang/String;J)J
      // 82: lstore 8
      // 84: iload 3
      // 85: ifeq ad
      // 88: new com/l7tech/server/transport/ftp/ExtendedCommandsFtpRequestProcessor
      // 8b: dup
      // 8c: aload 0
      // 8d: getfield com/l7tech/server/transport/ftp/FtpRequestProcessorFactory.a Lcom/l7tech/server/MessageProcessor;
      // 90: aload 0
      // 91: getfield com/l7tech/server/transport/ftp/FtpRequestProcessorFactory.b Lcom/l7tech/server/util/SoapFaultManager;
      // 94: aload 0
      // 95: getfield com/l7tech/server/transport/ftp/FtpRequestProcessorFactory.c Lcom/l7tech/server/StashManagerFactory;
      // 98: aload 0
      // 99: getfield com/l7tech/server/transport/ftp/FtpRequestProcessorFactory.d Lcom/l7tech/server/util/EventChannel;
      // 9c: aload 7
      // 9e: aload 6
      // a0: aload 4
      // a2: aload 1
      // a3: lload 8
      // a5: invokespecial com/l7tech/server/transport/ftp/ExtendedCommandsFtpRequestProcessor.<init> (Lcom/l7tech/server/MessageProcessor;Lcom/l7tech/server/util/SoapFaultManager;Lcom/l7tech/server/StashManagerFactory;Lcom/l7tech/server/util/EventChannel;Ljava/util/concurrent/ExecutorService;Lcom/l7tech/common/mime/ContentTypeHeader;Lcom/l7tech/objectmodel/Goid;Lcom/l7tech/gateway/common/transport/SsgConnector;J)V
      // a8: areturn
      // a9: invokestatic com/l7tech/server/transport/ftp/FtpRequestProcessorFactory.a (Ljava/io/IOException;)Ljava/io/IOException;
      // ac: athrow
      // ad: new com/l7tech/server/transport/ftp/UploadOnlyFtpRequestProcessor
      // b0: dup
      // b1: aload 0
      // b2: getfield com/l7tech/server/transport/ftp/FtpRequestProcessorFactory.a Lcom/l7tech/server/MessageProcessor;
      // b5: aload 0
      // b6: getfield com/l7tech/server/transport/ftp/FtpRequestProcessorFactory.b Lcom/l7tech/server/util/SoapFaultManager;
      // b9: aload 0
      // ba: getfield com/l7tech/server/transport/ftp/FtpRequestProcessorFactory.c Lcom/l7tech/server/StashManagerFactory;
      // bd: aload 0
      // be: getfield com/l7tech/server/transport/ftp/FtpRequestProcessorFactory.d Lcom/l7tech/server/util/EventChannel;
      // c1: aload 7
      // c3: aload 6
      // c5: aload 4
      // c7: aload 1
      // c8: lload 8
      // ca: invokespecial com/l7tech/server/transport/ftp/UploadOnlyFtpRequestProcessor.<init> (Lcom/l7tech/server/MessageProcessor;Lcom/l7tech/server/util/SoapFaultManager;Lcom/l7tech/server/StashManagerFactory;Lcom/l7tech/server/util/EventChannel;Ljava/util/concurrent/ExecutorService;Lcom/l7tech/common/mime/ContentTypeHeader;Lcom/l7tech/objectmodel/Goid;Lcom/l7tech/gateway/common/transport/SsgConnector;J)V
      // cd: areturn
      // try (13 -> 25): 25 java/io/IOException
      // try (10 -> 15): 16 java/io/IOException
      // try (33 -> 38): 39 java/io/IOException
      // try (64 -> 83): 83 java/io/IOException
   }

   private ExecutorService a(ConnectionConfig var1) {
      int var2 = var1.getMaxThreads();
      return new ThreadPoolExecutor(1, var2, 300L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(var2), new AbortPolicy());
   }

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

   static {
      String[] var5 = new String[3];
      int var3 = 0;
      String var2 = "q >\u0000!#.P!\u007f\u00119'|Pn\u00196\u001dfbM=+\u0007##|\u001en6\f;'bM*\u007f\r;#|V';\u0006((.G!1\u0016((z\u0004:&\u0012(f)@q >\u0000!#.P!\u007f\u00119'|Pn\u00196\u001dfbM=+\u0007##|\u001en1\rm5kV86\u0001(f}T+<\u000b+/k@n9\r?fbM=+\u0007##|\n\u0002\u0003`";
      int var4 = "q >\u0000!#.P!\u007f\u00119'|Pn\u00196\u001dfbM=+\u0007##|\u001en6\f;'bM*\u007f\r;#|V';\u0006((.G!1\u0016((z\u0004:&\u0012(f)@q >\u0000!#.P!\u007f\u00119'|Pn\u00196\u001dfbM=+\u0007##|\u001en1\rm5kV86\u0001(f}T+<\u000b+/k@n9\r?fbM=+\u0007##|\n\u0002\u0003`"
         .length();
      char var1 = '?';
      int var0 = -1;

      while (true) {
         String var10002 = a(115, a(var2.substring(++var0, var0 + var1)));
         byte var10001 = -1;
         var5[var3++] = var10002;
         if ((var0 += var1) >= var4) {
            e = var5;
            return;
         }

         var1 = var2.charAt(var0);
      }
   }

   private static char[] a(String var0) {
      char[] var10000 = var0.toCharArray();
      if (var10000.length < 2) {
         var10000[0] = (char)(var10000[0] ^ 125);
      }

      return var10000;
   }

   private static String a(int var0, char[] var1) {
      int var10003 = var1.length;
      int var10002 = var0;
      char[] var10001 = var1;
      int var10000 = var10003;

      for (int var2 = 0; var10000 > var2; var2++) {
         var10001[var2] = (char)(var10001[var2] ^ var10002 ^ switch (var2 % 7) {
            case 0 -> 87;
            case 1 -> 61;
            case 2 -> 44;
            case 3 -> 17;
            case 4 -> 62;
            case 5 -> 53;
            default -> 125;
         });
      }

      return new String(var10001).intern();
   }
}
