@Override
    public boolean check(final Session<?> session, final CancelCallback callback) throws BackgroundException {
        final Host bookmark = session.getHost();
        if(bookmark.getProtocol().isHostnameConfigurable() && StringUtils.isBlank(bookmark.getHostname())) {
            throw new ConnectionCanceledException();
        }
        if(session.isConnected()) {
            if(log.isDebugEnabled()) {
                log.debug(String.format("Skip opening connection for session %s", session));
            }
            // Connection already open
            return false;
        }
        // Obtain password from keychain or prompt
        synchronized(login) {
            login.validate(bookmark, prompt, new LoginOptions(bookmark.getProtocol()));
        }
        this.connect(session, callback);
        return true;
    }
@Test(expected = ConnectionCanceledException.class)
    public void testNoHostname() throws Exception {
        final LoginConnectionService s = new LoginConnectionService(new DisabledLoginCallback(), new DisabledHostKeyCallback(), new DisabledPasswordStore(),
            new DisabledProgressListener());
        s.check(new NullSession(new Host(new TestProtocol(), "")), new DisabledCancelCallback());
    }