Esempio n. 1
0
        public IUserCheckerResult Check(string userLogin, string userPass, string siteKey)
        {
            IUserCheckerResult checkerResult = CheckUser(userLogin, userPass, siteKey);

            _accessLogger.LogAssess(userLogin, checkerResult != null, siteKey, "FtpUser");
            return(checkerResult);
        }
Esempio n. 2
0
        public override void Execute()
        {
            FtpMessage responce = new FtpMessage("230 успешная авторизация", ClientConnection.Encoding);

            ClientConnection.Password =
                _commandArgsResolver.ResolvePassword(FtpMessage.Args);

            if (String.IsNullOrEmpty(ClientConnection.UserLogin) ||
                String.IsNullOrEmpty(ClientConnection.Password) ||
                String.IsNullOrEmpty(ClientConnection.RemoteServerIdentifier))
            {
                //TODO ctor
                SendToClient(new FtpMessage("530 неверная последовательность команд", ClientConnection.Encoding));
                return;
            }

            IUserCheckerResult checkerResult = _userChecker.Check(ClientConnection.UserLogin,
                                                                  ClientConnection.Password,
                                                                  ClientConnection.RemoteServerIdentifier);

            if (checkerResult == null)
            {
                SendToClient(new FtpMessage("530 Неверная комбинация логин-пароль", ClientConnection.Encoding));
                return;
            }
            try
            {
                _serverConnectionBuilder.BuildRemoteConnection(checkerResult.UrlAddress, checkerResult.Port);
            }
            catch (AuthenticationException)
            {
                Logger.Log.Error(String.Format("remote server anavailable: {0}| USER: {1}", checkerResult.UrlAddress,
                                               ClientConnection.UserLogin));
                SendToClient(new FtpMessage("434 remote server anavailable", ClientConnection.Encoding));
                return;
            }

            try
            {
                _serverConnectionBuilder.BuildConnectionSecurity();
            }
            catch (AuthenticationException e)
            {
                Logger.Log.Error(String.Format("BuildConnectionSecurity: {0}, Host: {1}, User: {2}", e.Message,
                                               checkerResult.UrlAddress, ClientConnection.UserLogin));
            }

            try
            {
                _serverConnectionBuilder.BuildUser(checkerResult.Login);
                _serverConnectionBuilder.BuildPass(checkerResult.Pass);
            }
            catch (AuthenticationException e)
            {
                Logger.Log.Error(String.Format("BuildUserPass: {0}; Host: {1}, User: {2}", e.Message,
                                               checkerResult.UrlAddress, ClientConnection.UserLogin));
                SendToClient(new FtpMessage("425 incorrect remote server auth data. Please contact the administrator",
                                            ClientConnection.Encoding));
                return;
            }
            SendToClient(responce);
        }