@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 testLoginFailureTooManyAuthenticationFailures() throws Exception {
        final Host host = new Host(new SFTPProtocol(), "test.cyberduck.ch", new Credentials(
                "jenkins", "p"
        )) {
            @Override
            public String getProperty(final String key) {
                if("ssh.authentication.agent.enable".equals(key)) {
                    return String.valueOf(false);
                }
                return null;
            }
        };
        final SFTPSession session = new SFTPSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
        final AtomicBoolean fail = new AtomicBoolean();
        final LoginConnectionService login = new LoginConnectionService(new DisabledLoginCallback() {
            @Override
            public Credentials prompt(final Host bookmark, String username,
                                      String title, String reason, LoginOptions options) throws LoginCanceledException {
                assertEquals("Login test.cyberduck.ch", title);
                assertEquals("Exhausted available authentication methods. Please contact your web hosting service provider for assistance.", reason);
                fail.set(true);
                throw new LoginCanceledException();
            }
        }, new DisabledHostKeyCallback(), new DisabledPasswordStore(),
                new DisabledProgressListener());
        try {
            login.connect(session, new DisabledCancelCallback());
        }
        catch(LoginCanceledException e) {
            assertTrue(fail.get());
            throw e;
        }
    }