Class SftpConfig
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
Durationand several Dropwizard validation annotations in addition to the standard Java Beans Validation annotations, so you will need to ensure the appropriate Dropwizard JAR files are on the class/module path.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionSftpConfig(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. -
Method Summary
Modifier and TypeMethodDescriptionstatic SftpConfig.SftpConfigBuilderbuilder()The local directory to write out any errors if SFTP fails.getHost()The remote host to connect to via SFTP.The path to the known hosts file.The password, only used if password authentication is used.intgetPort()The SFTP port.The comma-separated list of preferred authentication mechanisms.The path to the private key file, only used if public key authentication is used.The root directory of the remote SFTP location, provided as a convenience to store the remote path in the same place as the other SFTP properties.io.dropwizard.util.DurationSFTP connection timeout.getUser()The remote user to connect with via SFTP.booleanProvides option to disable strict host key checking, equivalent to the-o StrictHostKeyChecking=[yes|no]option.voidsetDisableStrictHostChecking(boolean disableStrictHostChecking) Provides option to disable strict host key checking, equivalent to the-o StrictHostKeyChecking=[yes|no]option.voidsetErrorPath(String errorPath) The local directory to write out any errors if SFTP fails.voidThe remote host to connect to via SFTP.voidsetKnownHostsFile(String knownHostsFile) The path to the known hosts file.voidsetPassword(String password) The password, only used if password authentication is used.voidsetPort(int port) The SFTP port.voidsetPreferredAuthentications(String preferredAuthentications) The comma-separated list of preferred authentication mechanisms.voidsetPrivateKeyFilePath(String privateKeyFilePath) The path to the private key file, only used if public key authentication is used.voidsetRemoteBasePath(String remoteBasePath) The root directory of the remote SFTP location, provided as a convenience to store the remote path in the same place as the other SFTP properties.voidsetTimeout(io.dropwizard.util.Duration timeout) SFTP connection timeout.voidThe remote user to connect with via SFTP.
-
Constructor Details
-
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 porthost- the remote hostuser- the SFTP usernamepassword- the SFTP passwordprivateKeyFilePath- path to private key filepreferredAuthentications- comma-separated list of authentications to attemptremoteBasePath- root directory of the remote SFTP locationerrorPath- local directory to write out any errors if SFTP failsknownHostsFile- path to the known hosts filedisableStrictHostChecking- if true, we will setStrictHostKeyChecking=notimeout- the SFTP connection timeout- Implementation Note:
- This is intentionally not using Lombok because using
AllArgsConstructortogether with @Builderresults in an all-args constructor that does not respectBuilder.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.
-
SftpConfig
public SftpConfig()
-
-
Method Details
-
builder
-
getPort
public int getPort()The SFTP port. Default is 22. -
getHost
The remote host to connect to via SFTP. -
getUser
The remote user to connect with via SFTP. -
getPassword
The password, only used if password authentication is used. -
getPrivateKeyFilePath
The path to the private key file, only used if public key authentication is used. -
getPreferredAuthentications
The comma-separated list of preferred authentication mechanisms. Equivalent to the-o PreferredAuthentications=[gssapi-with-mic|hostbased|publickey|keyboard-interactive|password]option.The default is
publickey,passwordwhich differs from the default order in the SFTP command. See thessh_infoman page for details. -
getRemoteBasePath
The root directory of the remote SFTP location, provided as a convenience to store the remote path in the same place as the other SFTP properties.It is not required nor currently used by
SftpConnectororSftpTransfers. -
getErrorPath
The local directory to write out any errors if SFTP fails. -
getKnownHostsFile
The path to the known hosts file. -
isDisableStrictHostChecking
public boolean isDisableStrictHostChecking()Provides option to disable strict host key checking, equivalent to the-o StrictHostKeyChecking=[yes|no]option.The default is false. See the
ssh_infoman page for more details. -
getTimeout
public io.dropwizard.util.Duration getTimeout()SFTP connection timeout. Default is 5 seconds.- Implementation Note:
- The minimum duration annotation of 50 milliseconds is somewhat arbitrary, and is really just intended to ensure a positive value.
-
setPort
public void setPort(int port) The SFTP port. Default is 22. -
setHost
The remote host to connect to via SFTP. -
setUser
The remote user to connect with via SFTP. -
setPassword
The password, only used if password authentication is used. -
setPrivateKeyFilePath
The path to the private key file, only used if public key authentication is used. -
setPreferredAuthentications
The comma-separated list of preferred authentication mechanisms. Equivalent to the-o PreferredAuthentications=[gssapi-with-mic|hostbased|publickey|keyboard-interactive|password]option.The default is
publickey,passwordwhich differs from the default order in the SFTP command. See thessh_infoman page for details. -
setRemoteBasePath
The root directory of the remote SFTP location, provided as a convenience to store the remote path in the same place as the other SFTP properties.It is not required nor currently used by
SftpConnectororSftpTransfers. -
setErrorPath
The local directory to write out any errors if SFTP fails. -
setKnownHostsFile
The path to the known hosts file. -
setDisableStrictHostChecking
public void setDisableStrictHostChecking(boolean disableStrictHostChecking) Provides option to disable strict host key checking, equivalent to the-o StrictHostKeyChecking=[yes|no]option.The default is false. See the
ssh_infoman page for more details. -
setTimeout
public void setTimeout(io.dropwizard.util.Duration timeout) SFTP connection timeout. Default is 5 seconds.- Implementation Note:
- The minimum duration annotation of 50 milliseconds is somewhat arbitrary, and is really just intended to ensure a positive value.
-