Class FtpConnectionImp

All Implemented Interfaces:
AdaptrisComponent, AdaptrisConnection, ComponentLifecycle, ComponentLifecycleExtension, StateManagedComponent
Direct Known Subclasses:
FtpConnection, FtpSslConnection

public abstract class FtpConnectionImp extends FileTransferConnectionUsingPassword
Abstract implementation of FTPConnection both vanilla and SSL.
  • Constructor Details

    • FtpConnectionImp

      public FtpConnectionImp()
      Default Constructor with the following default values.
      • ftpDebug is false
      • defaultControlPort is 21
      See Also:
  • Method Details

    • getTransferType

      public TransferType getTransferType()
      Get the transfer type.
      Returns:
      the transfer type.
      See Also:
    • setTransferType

      public void setTransferType(TransferType s)
      Set the transfer type.
      Parameters:
      s - the transfer type, default is TransferType.BINARY
      See Also:
    • getSocketTimeout

      public Integer getSocketTimeout()
      Returns:
      Returns the socketTimeout.
    • setSocketTimeout

      public void setSocketTimeout(Integer i)
      The socket timeout in milliseconds for connect / read and write operations.
      Parameters:
      i - The socketTimeout to set; default is 60000
    • getServerTimezone

      public String getServerTimezone()
      Returns:
      the serverTimezone
    • setServerTimezone

      public void setServerTimezone(String tz)
      Specify the timezone which the server is in.

      If not explicitly specified then the server Timezone will be assumed to be the same as the client timezone. This might lead to incorrect modification timestamps.

      Parameters:
      tz - any valid java timezone ID
      See Also:
    • initConnection

      protected void initConnection() throws CoreException
      Description copied from class: AdaptrisConnectionImp
      Initialise the underlying connection.
      Overrides:
      initConnection in class FileTransferConnectionUsingPassword
      Throws:
      CoreException - wrapping any exception.
      See Also:
    • createFtpClient

      protected abstract ApacheFtpClientImpl createFtpClient(String remoteHost, int port, int seconds) throws IOException
      Throws:
      IOException
    • create

      Description copied from class: FileTransferConnection
      Create an instance of the FileTransferClient for use with the producer or consumer.
      Specified by:
      create in class FileTransferConnection
      Parameters:
      remoteHost - the remote host.
      port - the port to connect to
      ui - a local UserInfo containing username and password
      Returns:
      a FileTransferClient object
      Throws:
      IOException - wrapping a general comms error.
      FileTransferException - if a protocol specific exception occurred.
      PasswordException
    • getFtpDataMode

      public FtpDataMode getFtpDataMode()
    • setFtpDataMode

      public void setFtpDataMode(FtpDataMode s)
      Set the FTP Data Mode.

      The following chart should help you remember how each FTP mode works:

       
           Active FTP :
             command : client >1023 -> server 21
             data    : client >1023 <- server 20
      
           Passive FTP :
             command : client >1023 -> server 21
             data    : client >1023 -> server >1023
           
           

      Active FTP is beneficial to the FTP server admin, but detrimental to the client side admin. The FTP server attempts to make connections to random high ports on the client, this may not work for the following reasons

      • The client has a firewall
      • The client is connected in conjunction with a NAT device

      Passive FTP is beneficial to the client, but might be considered detrimental to the FTP server admin. The client will make both connections to the server, but one of them will be to a random high port, which would almost certainly be blocked by a firewall on the server side.

      Since admins running FTP servers generally need to make their servers accessible to the greatest number of clients, they will almost certainly need to support passive FTP. Perhaps the FTP Server may be configured to use a limited range of ports for passive transfers (e.g. the ProFTPd PassivePorts directive) which can be added to the firewalls allowed list.

      Parameters:
      s - either ACTIVE or PASSIVE, default is FtpDataMode.PASSIVE
      See Also:
    • getDefaultAccount

      public String getDefaultAccount()
      Returns:
      the defaultAccount
    • setDefaultAccount

      public void setDefaultAccount(String defaultAccount)
      Some FTP Servers force you to have an account which is separate from the username.

      Note that if a positive completion code is returned by the server when you submit the password, then the account is never submitted; so you can still share the same FtpConnection between multiple consumers provided that you have the same account name (or no account name) for each of the connections.

      Parameters:
      defaultAccount - the defaultAccount to set
    • defaultControlPort

      public int defaultControlPort()
      Specified by:
      defaultControlPort in class FileTransferConnection
    • getAdditionalSettings

      public KeyValuePairSet getAdditionalSettings()
    • setAdditionalSettings

      public void setAdditionalSettings(KeyValuePairSet s)
      Set any additional settings that might need to be applied.
      Parameters:
      s - any additional settings.
      See Also: