}
private JobService connect(String host, String user, String password, boolean showMessageDialog) {
try {
Registry registry = LocateRegistry.getRegistry(host, JdcpUtil.DEFAULT_PORT);
AuthenticationService authService = (AuthenticationService) registry.lookup("AuthenticationService");
return authService.authenticate(user, password, JdcpUtil.PROTOCOL_VERSION_ID);
} catch (LoginException e) {
logger.error("Authentication failed.", e);
JOptionPane.showMessageDialog(this, "Authentication failed. Please check your user name and password.", "Connection Failed", JOptionPane.WARNING_MESSAGE);
} catch (RemoteException e) {
logger.error("Could not connect to remote host.", e);