コード例 #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;
 }
コード例 #2
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);
     }
 }
コード例 #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;
 }
コード例 #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);
     }
 }
コード例 #5
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)
 {   }
コード例 #6
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)
 {   }
コード例 #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();
        }
コード例 #10
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 FtpsCommandResponseTimeoutException(string message, FtpsResponse response, Exception innerException)
     :
    base(message, response, innerException)
 {   }
コード例 #11
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)
 {   }
コード例 #12
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)
 {   }
コード例 #13
0
 /// <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)
 {
 }
コード例 #14
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 FtpsCommandResponseTimeoutException(string message, FtpsResponse response, Exception innerException)
     :
     base(message, response, innerException)
 {
 }
コード例 #15
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)
 {   }
コード例 #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;
 }
コード例 #19
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)
 {   }
コード例 #20
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 FtpsItemParsingException(string message, FtpsResponse response, Exception innerException)
     : base(message, response, innerException)
 {
 }
コード例 #21
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)
 {   }
コード例 #22
0
 /// <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)
 {   }
コード例 #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)
 { }
コード例 #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)
 {
 }
コード例 #28
0
 /// <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)
 { }
コード例 #32
0
 /// <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)
 {   }
コード例 #33
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)
 {   }
コード例 #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)
 {
 }
コード例 #35
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)
 {   }
コード例 #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)
 {
 }
コード例 #37
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)
 {   }
コード例 #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;
 }
コード例 #39
0
 /// <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)
 {   }
コード例 #40
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="response">FtpResponse object.</param>
 public FtpsResponseEventArgs(FtpsResponse response)
 {
     _response = response;
 }
コード例 #41
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 FtpsNetworkVersionException(string message, FtpsResponse response, Exception innerException)
     : base(message, response, innerException)
 {
 }
コード例 #42
0
 /// <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)
 {
 }
コード例 #43
0
 /// <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)
 {
 }
コード例 #44
0
 /// <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;
        }
コード例 #51
0
 /// <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)
 {
 }
コード例 #55
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 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)
 {
 }
コード例 #57
0
 /// <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)
 { }
コード例 #58
0
        /// <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)
 {
 }