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)); } }
protected Command(IExecutorState executorState, IFtpMessage ftpMessage) { ExecutorState = executorState; FtpMessage = ftpMessage; _errors = new List <string>(); }
public UserCommand(IExecutorState executorState, IFtpMessage ftpMessage, ICommandArgsResolver commandArgsResolver) : base(executorState, ftpMessage) { _commandArgsResolver = commandArgsResolver; }
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)); }
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; }
public virtual ICommand GetNextCommand(IExecutorState executorState) { IFtpMessage ftpMessage = executorState.ClientConnection.GetMessage(); return(ftpMessage != null ? executorState.CommandFactory.CreateCommand(ftpMessage, executorState) : null); }
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; }
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); }
public UnauthorizedCommand(IExecutorState executorState, IFtpMessage ftpMessage) : base(executorState, ftpMessage) { }
public UnavailableCommand(IExecutorState executorState, IFtpMessage ftpMessage) : base(executorState, ftpMessage) { }
public OtherCommand(IExecutorState executorState, IFtpMessage clientFtpMessage, IDataOperationExecutor dataOperationExecutor) : base(executorState, clientFtpMessage) { _dataOperationExecutor = dataOperationExecutor; }
public WelcomeCommand(IExecutorState executorState) : base(executorState, null) { }
public ActiveDataConnectionCommand(IExecutorState executorState, IFtpMessage ftpMessage, IConnectionFactory connectionFactory, ICommandExecutorHelper commandExecutorHelper) : base(executorState, ftpMessage) { _connectionFactory = connectionFactory; _commandExecutorHelper = commandExecutorHelper; }
public PbszCommand(IExecutorState executorState, IFtpMessage ftpMessage) : base(executorState, ftpMessage) { }