@Override
public final void authSetup(final ConnectionDescription description, final FileSystemOptions options) throws org.apache.commons.vfs2.FileSystemException {
StaticUserAuthenticator auth = new StaticUserAuthenticator(null, description.getParameter(ConnectionDescription.PARAMETER_USERNAME), description.getSecretParameter(ConnectionDescription.PARAMETER_PASSWORD));
DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth);
SftpFileSystemConfigBuilder cfg = SftpFileSystemConfigBuilder.getInstance();
if (null != sshDirName) {
cfg.setKnownHosts(options, new File(sshDirName, "known_hosts"));
}
logger.debug("SFTP using knownHosts: ", cfg.getKnownHosts(options));
cfg.setUserInfo(options, this);
cfg.setStrictHostKeyChecking(options, "ask");
if ("enabled".equals(description.getParameter("publicKeyAuth"))) {
cfg.setPreferredAuthentications(options, "publickey,password,keyboard-interactive");
}
else {
cfg.setPreferredAuthentications(options, "password,keyboard-interactive");
}
}