Ejemplo n.º 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);
     }
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
 /// <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)
 {   }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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();

        }
Ejemplo n.º 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)
 {   }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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)
 {   }
Ejemplo n.º 23
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 FtpsBusyException(string message, FtpsResponse response, Exception innerException)
     : base(message, response, innerException)
 { }
Ejemplo n.º 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;
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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)
 {   }
Ejemplo n.º 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)
 {   }
Ejemplo n.º 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)
 {   }
Ejemplo n.º 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)
 {   }
Ejemplo n.º 40
0
 /// <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)
 {   }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 48
0
 private void RaiseServerResponseEvent(FtpsResponse response)
 {
     if (ServerResponse != null)
         ServerResponse(this, new FtpsResponseEventArgs(response));
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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)
 { }
Ejemplo n.º 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;
		}
Ejemplo n.º 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)
 {
 }