@Override
    public void login(final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException {
        try {
            final IRODSAccount account = client.getIRODSAccount();
            final Credentials credentials = host.getCredentials();
            account.setUserName(credentials.getUsername());
            account.setPassword(credentials.getPassword());
            final AuthResponse response = client.getIRODSAccessObjectFactory().authenticateIRODSAccount(account);
            if(log.isDebugEnabled()) {
                log.debug(String.format("Connected to %s", response.getStartupResponse()));
            }
            if(!response.isSuccessful()) {
                throw new LoginFailureException(MessageFormat.format(LocaleFactory.localizedString(
                    "Login {0} with username and password", "Credentials"), BookmarkNameProvider.toString(host)));
            }
        }
        catch(JargonException e) {
            throw new IRODSExceptionMappingService().map(e);
        }
    }
@Test(expected = LoginFailureException.class)
    public void testLoginFailure() throws Exception {
        final ProtocolFactory factory = new ProtocolFactory(new HashSet<>(Collections.singleton(new IRODSProtocol())));
        final Profile profile = new ProfilePlistReader(factory).read(
                this.getClass().getResourceAsStream("/iRODS (iPlant Collaborative).cyberduckprofile"));
        final Host host = new Host(profile, profile.getDefaultHostname(), new Credentials("a", "a"));

        final IRODSSession session = new IRODSSession(host);
        assertNotNull(session.open(new DisabledProxyFinder(), new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback()));
        assertTrue(session.isConnected());
        assertNotNull(session.getClient());
        session.login(new DisabledLoginCallback(), new DisabledCancelCallback());
    }