@Override
    protected SSHClient connect(final ProxyFinder proxy, final HostKeyCallback key, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException {
        final DefaultConfig configuration = new DefaultConfig();
        if("zlib".equals(preferences.getProperty("ssh.compression"))) {
            configuration.setCompressionFactories(Arrays.asList(
                    new JcraftDelayedZlibCompression.Factory(),
                    new JcraftZlibCompression.Factory(),
                    new NoneCompression.Factory()));
        }
        else {
            configuration.setCompressionFactories(Collections.singletonList(new NoneCompression.Factory()));
        }
        configuration.setVersion(new PreferencesUseragentProvider().get());
        final KeepAliveProvider heartbeat;
        if(preferences.getProperty("ssh.heartbeat.provider").equals("keep-alive")) {
            heartbeat = KeepAliveProvider.KEEP_ALIVE;
        }
        else {
            heartbeat = KeepAliveProvider.HEARTBEAT;
        }
        configuration.setKeepAliveProvider(heartbeat);
        configuration.setCipherFactories(this.lowestPriorityForCBC(configuration.getCipherFactories()));
        return this.connect(key, prompt, configuration);
    }
@Test(expected = LoginCanceledException.class)
    public void testConnectNoValidCredentials() throws Exception {
        final Host host = new Host(new SFTPProtocol(), "test.cyberduck.ch", new Credentials("user", "p")) {
            @Override
            public String getProperty(final String key) {
                if("ssh.authentication.agent.enable".equals(key)) {
                    return String.valueOf(false);
                }
                return null;
            }
        };
        final Session session = new SFTPSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
        final LoginConnectionService login = new LoginConnectionService(new DisabledLoginCallback() {
            @Override
            public Credentials prompt(final Host bookmark, String username, String title, String reason, LoginOptions options) throws LoginCanceledException {
                throw new LoginCanceledException();
            }
        }, new DisabledHostKeyCallback(), new DisabledPasswordStore(),
            new DisabledProgressListener());
        login.connect(session, new DisabledCancelCallback());
    }