@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
    @Ignore
    public void testUsernameChangeReconnect() throws Exception {
        final Host host = new Host(new SFTPProtocol(), "test.cyberduck.ch", new Credentials("u1", "p1"));
        final Session session = new SFTPSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
        final AtomicBoolean change = new AtomicBoolean();
        final LoginConnectionService login = new LoginConnectionService(new DisabledLoginCallback() {
            @Override
            public Local select(final Local identity) throws LoginCanceledException {
                return new NullLocal("k");
            }

            @Override
            public Credentials prompt(final Host bookmark, String username, String title, String reason, LoginOptions options) {
                if(change.get()) {
                    assertEquals("Change of username or service not allowed: (u1,ssh-connection) -> (jenkins,ssh-connection). Please contact your web hosting service provider for assistance.", reason);
                    return null;
                }
                else {
                    assertEquals("Login failed", title);
//                    assertEquals("Too many authentication failures for u1. Please contact your web hosting service provider for assistance.", reason);
//                    assertEquals("Exhausted available authentication methods. Please contact your web hosting service provider for assistance.", reason);
                    change.set(true);
                    return new Credentials(System.getProperties().getProperty("sftp.user"), System.getProperties().getProperty("sftp.password"));
                }
            }
        }, new DisabledHostKeyCallback(), new DisabledPasswordStore(),
                new DisabledProgressListener());
        login.connect(session, new DisabledCancelCallback());
        assertTrue(change.get());
    }