use of ch.cyberduck.core.ftp.list.FTPListService in project cyberduck by iterate-ch.
the class FTPSession method login.
@Override
public void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException {
try {
if (client.login(host.getCredentials().getUsername(), host.getCredentials().getPassword())) {
if (host.getProtocol().isSecure()) {
client.execPBSZ(0);
// Negotiate data connection security
client.execPROT(preferences.getProperty("ftp.tls.datachannel"));
}
if (StandardCharsets.UTF_8.name().equals(host.getEncoding())) {
if (client.hasFeature("UTF8")) {
if (!FTPReply.isPositiveCompletion(client.sendCommand("OPTS UTF8 ON"))) {
log.warn(String.format("Failed to negotiate UTF-8 charset %s", client.getReplyString()));
}
}
}
final TimeZone zone = host.getTimezone();
if (log.isInfoEnabled()) {
log.info(String.format("Reset parser to timezone %s", zone));
}
// Unknown
String system = StringUtils.EMPTY;
try {
system = client.getSystemType();
if (system.toUpperCase(Locale.ROOT).contains(FTPClientConfig.SYST_NT)) {
casesensitivity = Protocol.Case.insensitive;
}
} catch (IOException e) {
log.warn(String.format("SYST command failed %s", e.getMessage()));
}
listService = new FTPListService(this, system, zone);
if (client.hasFeature(FTPCmd.MFMT.getCommand())) {
timestamp = new FTPMFMTTimestampFeature(this);
} else {
timestamp = new FTPUTIMETimestampFeature(this);
}
if (system.toUpperCase(Locale.ROOT).contains(FTPClientConfig.SYST_NT)) {
permission = null;
} else {
permission = new FTPUnixPermissionFeature(this);
}
if (client.hasFeature("SITE", "SYMLINK")) {
symlink = new FTPSymlinkFeature(this);
}
} else {
throw new FTPExceptionMappingService().map(new FTPException(this.getClient().getReplyCode(), this.getClient().getReplyString()));
}
} catch (IOException e) {
throw new FTPExceptionMappingService().map(e);
}
}
Aggregations