示例#1
0
 /// <summary>
 /// Constructor for FtpResponse.
 /// </summary>
 /// <param name="response">FtpResponse object.</param>
 public FtpsResponse(FtpsResponse response)
 {
     _rawText         = response.RawText;
     _text            = response.Text;
     _code            = response.Code;
     _isInformational = response.IsInformational;
 }
 /// <summary>
 /// Adds an Response object to the end of the FtpResponseQueue.
 /// </summary>
 /// <param name="item">An FtpResponse item.</param>
 public void Enqueue(FtpsResponse item)
 {
     lock (this)
     {
         _queue.Enqueue(item);
     }
 }
 /// <summary>
 /// Constructor for FtpResponse.
 /// </summary>
 /// <param name="response">FtpResponse object.</param>
 public FtpsResponse(FtpsResponse response)
 {
     _rawText = response.RawText;
     _text = response.Text;
     _code = response.Code;
     _isInformational = response.IsInformational;
 }
 /// <summary>
 /// Adds an Response object to the end of the FtpResponseQueue.
 /// </summary>
 /// <param name="item">An FtpResponse item.</param>
 public void Enqueue(FtpsResponse item)
 {
     lock (this)
     {
         _queue.Enqueue(item);
     }
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsConnectionOpenException(string message, FtpsResponse response, Exception innerException)
     :  base(message, response, innerException)
 {   }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsDataCompressionException(string message, FtpsResponse response, Exception innerException)
     :  base(message, response, innerException)
 {   }
示例#7
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsAsynchronousOperationException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
示例#8
0
        private void MonitorCommandConnection()
        {
            byte[] buffer = new byte[_tcpBufferSize];
            StringBuilder response = new StringBuilder();
            bool code421Detected = false;

            while (IsConnected)
            {
                lock (_reponseMonitorLock)
                {
                    Thread.Sleep(WAIT_FOR_COMMAND_RESPONSE_INTERVAL);
                    try
                    {
                        if (_commandConn != null && _commandConn.GetStream().DataAvailable)
                        {
                            int bytes = _commandStream.Read(buffer, 0, _tcpBufferSize);
                            string partial = _encode.GetString(buffer, 0, bytes);
                            response.Append(partial);

                            // write out the debug response
                            Debug.Write("R: " + partial);

                            if (!partial.EndsWith("\n"))
                            {
                                continue;
                            }

                             //  parse out the response code sent back from the server
                            //  in some cases more than one response can be sent with
                            //  each line separated with a crlf pair.
                            string[] responseArray = SplitResponse(response.ToString());
                            for (int i = 0; i < responseArray.Length; i++)
                            {
                                FtpsResponse r = new FtpsResponse(responseArray[i]);
                                _responseQueue.Enqueue(r);
                                // if a 421 response code is detected then the server has closed the connection
                                if (r.Code == FtpsResponseCode.ServiceNotAvailableClosingControlConnection)
                                    code421Detected = true;
                            }

                            response.Remove(0, response.Length);

                            // if code 421 was detected then close the command connection
                            if (code421Detected)
                                CloseCommandConn();
                        }
                    }
                    catch { }
                }
            }

            RaiseConnectionClosedEvent();

        }
示例#9
0
        /// <summary>
        /// Waits until a happy code has been returned by the FTP server or times out.
        /// </summary>
        /// <param name="timeout">Maximum time to wait before timing out.</param>
        /// <param name="happyResponseCodes">Server response codes to wait for.</param>
        internal protected  void WaitForHappyCodes(int timeout, params FtpsResponseCode[] happyResponseCodes)
        {
            _responseList.Clear();
            do
            {
                FtpsResponse response = GetNextCommandResponse(timeout);
                _responseList.Add(response);
                RaiseServerResponseEvent(new FtpsResponse(response));

                if (!response.IsInformational)
                {
                    if (IsHappyResponse(response, happyResponseCodes))
                        break;

                    if (IsUnhappyResponse(response))
                    {
                        _response = response;
                        throw new FtpsResponseException("FTP command failed.", response);
                    }
                }
            } while (true);

            _response = _responseList.GetLast();
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsCommandResponseTimeoutException(string message, FtpsResponse response, Exception innerException)
     :
    base(message, response, innerException)
 {   }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsAuthenticationException(string message, FtpsResponse response, Exception innerException)
     :
    base(message, response, innerException)
 {   }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsAuthenticationException(string message, FtpsResponse response)
     : base(message, response)
 {   }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsCommandResponseTimeoutException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsCommandResponseTimeoutException(string message, FtpsResponse response, Exception innerException)
     :
     base(message, response, innerException)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsSecureConnectionException(string message, FtpsResponse response)
     : base(message, response)
 {   }
示例#16
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsSecureConnectionException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
示例#17
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsLoginException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
示例#18
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsException(string message, FtpsResponse response, Exception innerException)
     :
    base(message, innerException)
 {
     _response = response;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsDataTransferException(string message, FtpsResponse response)
     : base(message, response)
 {   }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsItemParsingException(string message, FtpsResponse response, Exception innerException)
     : base(message, response, innerException)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsLoginException(string message, FtpsResponse response)
     : base(message, response)
 {   }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsDataConnectionTimeoutException(string message, FtpsResponse response)
     : base(message, response)
 {   }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsBusyException(string message, FtpsResponse response, Exception innerException)
     : base(message, response, innerException)
 { }
示例#24
0
 private bool IsUnhappyResponse(FtpsResponse response)
 {
     if (
          response.Code == FtpsResponseCode.ServiceNotAvailableClosingControlConnection
         || response.Code == FtpsResponseCode.CannotOpenDataConnection
         || response.Code == FtpsResponseCode.ConnectionClosedSoTransferAborted
         || response.Code == FtpsResponseCode.RequestedFileActionNotTaken
         || response.Code == FtpsResponseCode.RequestedActionAbortedDueToLocalErrorInProcessing
         || response.Code == FtpsResponseCode.RequestedActionNotTakenInsufficientStorage
         || response.Code == FtpsResponseCode.SyntaxErrorCommandUnrecognized
         || response.Code == FtpsResponseCode.SyntaxErrorInParametersOrArguments
         || response.Code == FtpsResponseCode.CommandNotImplemented
         || response.Code == FtpsResponseCode.BadSequenceOfCommands
         || response.Code == FtpsResponseCode.CommandNotImplementedForThatParameter
         || response.Code == FtpsResponseCode.NotLoggedIn
         || response.Code == FtpsResponseCode.NeedAccountForStoringFiles
         || response.Code == FtpsResponseCode.RequestedActionNotTakenFileUnavailable
         || response.Code == FtpsResponseCode.RequestedActionAbortedPageTypeUnknown
         || response.Code == FtpsResponseCode.RequestedFileActionAbortedExceededStorageAllocation
         || response.Code == FtpsResponseCode.RequestedActionNotTakenFileNameNotAllowed)
         return true;
     else
         return false;
 }
示例#25
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsFeatureException(string message, FtpsResponse response, Exception innerException)
     : base(message, response, innerException)
 {
 }
示例#26
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsHashingServerBusyException(string message, FtpsResponse response, Exception innerException)
     : base(message, response, innerException)
 {
 }
示例#27
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsFeatureException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsConnectionBrokenException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
示例#29
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsDataCompressionException(string message, FtpsResponse response, Exception innerException)
     :  base(message, response, innerException)
 {
 }
示例#30
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsAuthenticationException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsHashingInvalidAlgorithmException(string message, FtpsResponse response)
     : base(message, response)
 { }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsConnectionOpenException(string message, FtpsResponse response)
     : base(message, response)
 {   }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsDataCompressionException(string message, FtpsResponse response)
     : base(message, response)
 {   }
示例#34
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsDataCompressionException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsAsynchronousOperationException(string message, FtpsResponse response)
     : base(message, response)
 {   }
示例#36
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsCertificateValidationException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsCertificateValidationException(string message, FtpsResponse response)
     : base(message, response)
 {   }
示例#38
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsException(string message, FtpsResponse response)
     : base(message)
 {
     _response = response;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsHashingException(string message, FtpsResponse response)
     : base(message, response)
 {   }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="response">FtpResponse object.</param>
 public FtpsResponseEventArgs(FtpsResponse response)
 {
     _response = response;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsNetworkVersionException(string message, FtpsResponse response, Exception innerException)
     : base(message, response, innerException)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsItemParsingException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsNetworkVersionException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsCommandResponseTimeoutException(string message, FtpsResponse response)
     : base(message, response)
 {   }
示例#45
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsDataTransferException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsHashingInvalidAlgorithmException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
示例#47
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsException(string message, FtpsResponse response, Exception innerException)
     :
     base(message, innerException)
 {
     _response = response;
 }
示例#48
0
 private void RaiseServerResponseEvent(FtpsResponse response)
 {
     if (ServerResponse != null)
         ServerResponse(this, new FtpsResponseEventArgs(response));
 }
示例#49
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsException(string message, FtpsResponse response)
     : base(message)
 {
     _response = response;
 }
示例#50
0
        private bool IsHappyResponse(FtpsResponse response, FtpsResponseCode[] happyResponseCodes)
        {
            // always return true if there are no responses to validate
            if (happyResponseCodes.Length == 0)
                return true;

            for (int j = 0; j < happyResponseCodes.Length; j++)
            {
                if (happyResponseCodes[j] == response.Code)
                    return true;
            }
            return false;
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsDataConnectionTimeoutException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
示例#52
0
        private void DontWaitForHappyCodes()
        {
            if (_responseQueue.Count == 0)
                return;

            _responseList.Clear();
            while (_responseQueue.Count > 0)
            {
                FtpsResponse response = _responseQueue.Dequeue();
                _responseList.Add(response);
                RaiseServerResponseEvent(new FtpsResponse(response));
            }
            _response = _responseList.GetLast();
        }
示例#53
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsCommandNotSupportedException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
示例#54
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsHashingServerBusyException(string message, FtpsResponse response)
     : base(message, response)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsItemParsingException(string message, FtpsResponse response, Exception innerException)
     : base(message, response, innerException)
 { }
示例#56
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsConnectionOpenException(string message, FtpsResponse response, Exception innerException)
     :  base(message, response, innerException)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 public FtpsItemParsingException(string message, FtpsResponse response)
     : base(message, response)
 { }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="response">FtpResponse object.</param>
        public FtpsResponseEventArgs(FtpsResponse response)
		{
			_response = response;
		}
示例#59
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message">Exception message text.</param>
 /// <param name="response">Ftp response object.</param>
 /// <param name="innerException">The inner exception object.</param>
 public FtpsAuthenticationException(string message, FtpsResponse response, Exception innerException)
     :
     base(message, response, innerException)
 {
 }