Class SftpConfig


  • public class SftpConfig
    extends Object
    This (Dropwizard) config class allows for common configuration for SFTP access to remote hosts.

    One note on the password and privateKeyFilePath fields: the SFTP connector will use either the password or the private key but not both. If both are specified, the private key will take precedence. This allows for the greatest flexibility when connecting to different SFTP locations.

    Implementation Note:
    This uses Dropwizard's Duration and several Dropwizard validation annotations in addition to the standard Java Beans Validation annotations, so you will need to ensure the the appropriate Dropwizard JAR files are on the class/module path.
    • Constructor Detail

      • SftpConfig

        @ConstructorProperties({"port","host","user","password","privateKeyFilePath","preferredAuthentications","remoteBasePath","errorPath","knownHostsFile","disableStrictHostChecking","timeout"})
        public SftpConfig​(int port,
                          String host,
                          String user,
                          String password,
                          String privateKeyFilePath,
                          String preferredAuthentications,
                          String remoteBasePath,
                          String errorPath,
                          String knownHostsFile,
                          boolean disableStrictHostChecking,
                          io.dropwizard.util.Duration timeout)
        All-args constructor.
        Parameters:
        port - the remote port
        host - the remote host
        user - the SFTP username
        password - the SFTP password
        privateKeyFilePath - path to private key file
        preferredAuthentications - comma-separated list of authentications to attempt
        remoteBasePath - root directory of the remote SFTP location
        errorPath - local directory to write out any errors if SFTP fails
        knownHostsFile - path to the known hosts file
        disableStrictHostChecking - if true, we will set StrictHostKeyChecking=no
        timeout - the SFTP connection timeout
        Implementation Note:
        This is intentionally not using Lombok because using AllArgsConstructor together with @Builder results in an all-args constructor that does not respect Builder.Default. As a result we need to handle the defaults ourselves. This is intended to be used during deserialization from an external configuration file (e.g. a Dropwizard YAML configuration file, or from JSON). Prefer the builder when constructing programmatically.