Search in sources :

Example 6 with FTPListService

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);
    }
}
Also used : TimeZone(java.util.TimeZone) FTPListService(ch.cyberduck.core.ftp.list.FTPListService) IOException(java.io.IOException)

Aggregations

FTPListService (ch.cyberduck.core.ftp.list.FTPListService)6 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)5 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)5 Path (ch.cyberduck.core.Path)5 Delete (ch.cyberduck.core.features.Delete)5 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)5 IntegrationTest (ch.cyberduck.test.IntegrationTest)5 Test (org.junit.Test)5 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)3 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)2 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)2 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)2 PathAttributes (ch.cyberduck.core.PathAttributes)2 CryptoListService (ch.cyberduck.core.cryptomator.features.CryptoListService)2 AbstractFTPTest (ch.cyberduck.core.ftp.AbstractFTPTest)2 FTPDeleteFeature (ch.cyberduck.core.ftp.FTPDeleteFeature)2 FTPWriteFeature (ch.cyberduck.core.ftp.FTPWriteFeature)2 StreamCopier (ch.cyberduck.core.io.StreamCopier)2 DefaultHomeFinderService (ch.cyberduck.core.shared.DefaultHomeFinderService)2 DefaultVaultRegistry (ch.cyberduck.core.vault.DefaultVaultRegistry)2