Ejemplo n.º 1
0
        public ICommand CreateCommand(IFtpMessage ftpMessage, IExecutorState executorState)
        {
            if (ftpMessage == null)
            {
                return(new WelcomeCommand(executorState));
            }

            switch (ftpMessage.CommandName)
            {
            case ProcessingClientCommand.Auth:
                return(new AuthCommand(executorState, ftpMessage));

            case ProcessingClientCommand.User:
                return(new UserCommand(executorState, ftpMessage, _commandArgsResolver));

            case ProcessingClientCommand.Pass:
                return(new PassCommand(executorState,
                                       ftpMessage,
                                       _userChecker,
                                       _commandArgsResolver,
                                       _serverConnectionBuilder,
                                       _remoteCommandFactory));

            default:
                return(new UnauthorizedCommand(executorState, ftpMessage));
            }
        }
Ejemplo n.º 2
0
        protected Command(IExecutorState executorState, IFtpMessage ftpMessage)
        {
            ExecutorState = executorState;
            FtpMessage    = ftpMessage;

            _errors = new List <string>();
        }
Ejemplo n.º 3
0
 public UserCommand(IExecutorState executorState,
                    IFtpMessage ftpMessage,
                    ICommandArgsResolver commandArgsResolver)
     : base(executorState, ftpMessage)
 {
     _commandArgsResolver = commandArgsResolver;
 }
Ejemplo n.º 4
0
        public ICommand CreateCommand(IFtpMessage ftpMessage, IExecutorState executorState)
        {
            switch (ftpMessage.CommandName)
            {
            case ProcessingClientCommand.Prot:
                return(new ProtCommand(executorState, ftpMessage));

            case ProcessingClientCommand.Pbsz:
                return(new PbszCommand(executorState, ftpMessage));

            case ProcessingClientCommand.Rein:     // Блок недоступных команд
                return(new UnavailableCommand(executorState, ftpMessage));

            case ProcessingClientCommand.Port:
            case ProcessingClientCommand.Eprt:
                return(new ActiveDataConnectionCommand(executorState, ftpMessage, _connectionFactory,
                                                       _commandExecutorHelper));

            case ProcessingClientCommand.Pasv:
            case ProcessingClientCommand.Epsv:
                return(new PassiveDataConnectionCommand(executorState, ftpMessage, _connectionFactory,
                                                        _commandExecutorHelper));
            }
            return(new OtherCommand(executorState, ftpMessage, _dataOperationExecutor));
        }
Ejemplo n.º 5
0
 public PassCommand(IExecutorState executorState, IFtpMessage ftpMessage, IUserChecker userChecker, ICommandArgsResolver commandArgsResolver, IServerConnectionBuilder serverConnectionBuilder, ICommandFactory remoteCommandFactory) : base(executorState, ftpMessage)
 {
     _userChecker             = userChecker;
     _commandArgsResolver     = commandArgsResolver;
     _serverConnectionBuilder = serverConnectionBuilder;
     _remoteCommandFactory    = remoteCommandFactory;
 }
Ejemplo n.º 6
0
        public virtual ICommand GetNextCommand(IExecutorState executorState)
        {
            IFtpMessage ftpMessage = executorState.ClientConnection.GetMessage();

            return(ftpMessage != null
                ? executorState.CommandFactory.CreateCommand(ftpMessage, executorState)
                : null);
        }
Ejemplo n.º 7
0
        public Executor(IConnection clientConnection)
        {
            UnityContainer      container           = DependencyResolver.Container;
            LocalCommandFactory localCommandFactory = container.Resolve <LocalCommandFactory>();

            State = new ExecutorState
            {
                ClientConnection = clientConnection,
                CommandFactory   = localCommandFactory
            };
            clientConnection.ConnectionClosed += State.CloseConnections;
            _executingCommand = GetFirstCommand();
            _isExecuting      = true;
        }
Ejemplo n.º 8
0
 public void StartExecuting(object obj)
 {
     do
     {
         try
         {
             _executingCommand.Execute();
         }
         catch (Exception ex)
         {
             Logger.Log.Error(ex.Message, ex);
         }
         State = _executingCommand.GetExecutorState();
     } while ((_executingCommand = _executingCommand.GetNextCommand(State)) != null && _isExecuting);
 }
Ejemplo n.º 9
0
 public UnauthorizedCommand(IExecutorState executorState, IFtpMessage ftpMessage)
     : base(executorState, ftpMessage)
 {
 }
Ejemplo n.º 10
0
 public UnavailableCommand(IExecutorState executorState, IFtpMessage ftpMessage) : base(executorState, ftpMessage)
 {
 }
Ejemplo n.º 11
0
 public OtherCommand(IExecutorState executorState, IFtpMessage clientFtpMessage, IDataOperationExecutor dataOperationExecutor)
     : base(executorState, clientFtpMessage)
 {
     _dataOperationExecutor = dataOperationExecutor;
 }
Ejemplo n.º 12
0
 public WelcomeCommand(IExecutorState executorState) : base(executorState, null)
 {
 }
Ejemplo n.º 13
0
 public ActiveDataConnectionCommand(IExecutorState executorState, IFtpMessage ftpMessage, IConnectionFactory connectionFactory, ICommandExecutorHelper commandExecutorHelper) : base(executorState, ftpMessage)
 {
     _connectionFactory     = connectionFactory;
     _commandExecutorHelper = commandExecutorHelper;
 }
Ejemplo n.º 14
0
 public PbszCommand(IExecutorState executorState, IFtpMessage ftpMessage) : base(executorState, ftpMessage)
 {
 }