@Override
    public Boolean authenticate(final Host bookmark, final LoginCallback callback, final CancelCallback cancel)
            throws BackgroundException {
        final Credentials credentials = bookmark.getCredentials();
        if(StringUtils.isBlank(credentials.getPassword())) {
            final Credentials input = callback.prompt(bookmark, credentials.getUsername(),
                    String.format("%s %s", LocaleFactory.localizedString("Login", "Login"), bookmark.getHostname()),
                    MessageFormat.format(LocaleFactory.localizedString(
                            "Login {0} with username and password", "Credentials"), BookmarkNameProvider.toString(bookmark)),
                    // Change of username or service not allowed
                    new LoginOptions(bookmark.getProtocol()).user(false));
            if(input.isPublicKeyAuthentication()) {
                credentials.setIdentity(input.getIdentity());
                return new SFTPPublicKeyAuthentication(client).authenticate(bookmark, callback, cancel);
            }
            credentials.setSaved(input.isSaved());
            credentials.setPassword(input.getPassword());
        }
        return this.authenticate(bookmark, credentials, callback, cancel);
    }
@Test(expected = LoginFailureException.class)
    public void testAuthenticateFailure() throws Exception {
        // Reconnect
        session.disconnect();
        session.open(new DisabledProxyFinder(), new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
        session.getHost().getCredentials().setPassword("p");
        assertFalse(new SFTPPasswordAuthentication(session.getClient()).authenticate(session.getHost(), new DisabledLoginCallback(), new DisabledCancelCallback()));
    }