Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback method for opening external browser #1509

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,32 @@ public void openBrowser(String ssoUrl) throws SFException {
}
if (java.awt.Desktop.isDesktopSupported()) {
URI uri = new URI(ssoUrl);
java.awt.Desktop.getDesktop().browse(uri);
} else {
Runtime runtime = Runtime.getRuntime();
Constants.OS os = Constants.getOS();
if (os == Constants.OS.MAC) {
runtime.exec("open " + ssoUrl);
} else {
// linux?
runtime.exec("xdg-open " + ssoUrl);
try {
java.awt.Desktop.getDesktop().browse(uri);
}
catch (UnsupportedOperationException e) {
openBrowserOSFallback(ssoUrl);
}
} else {
openBrowserOSFallback(ssoUrl);
}
} catch (URISyntaxException | IOException ex) {
throw new SFException(ex, ErrorCode.NETWORK_ERROR, ex.getMessage());
}
}

private void openBrowserOSFallback(String ssoUrl) throws IOException {
Runtime runtime = Runtime.getRuntime();
Constants.OS os = Constants.getOS();

if (os == Constants.OS.MAC) {
runtime.exec("open " + ssoUrl);
} else {
// linux?
runtime.exec("xdg-open " + ssoUrl);
}
}

@Override
public void output(String msg) {
System.out.println(msg);
Expand Down
Loading