From b54ce7f1b1ef6297973e8db0afd324144c19de19 Mon Sep 17 00:00:00 2001 From: Mark McKinnon Date: Mon, 19 Feb 2018 11:59:03 -0800 Subject: [PATCH] Add URL to report and Launch when opened Ability to add a URL to a report. When the report is opened then launch a browser to open the URL report. --- .../sleuthkit/autopsy/casemodule/Case.java | 6 +++++- .../directorytree/ExternalViewerAction.java | 19 +++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index 804e224a70..e2809dbb03 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -1529,7 +1529,11 @@ public class Case { public void addReport(String localPath, String srcModuleName, String reportName) throws TskCoreException { String normalizedLocalPath; try { - normalizedLocalPath = Paths.get(localPath).normalize().toString(); + if (localPath.toLowerCase().contains("http:")) { + normalizedLocalPath = localPath; + } else { + normalizedLocalPath = Paths.get(localPath).normalize().toString(); + } } catch (InvalidPathException ex) { String errorMsg = "Invalid local path provided: " + localPath; // NON-NLS throw new TskCoreException(errorMsg, ex); diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java b/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java index e79840fd20..84d71c1f42 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java @@ -22,6 +22,8 @@ import java.awt.Desktop; import java.awt.event.ActionEvent; import java.io.File; import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; import java.util.logging.Level; import javax.swing.AbstractAction; import javax.swing.JOptionPane; @@ -112,7 +114,8 @@ public class ExternalViewerAction extends AbstractAction { "ExternalViewerAction.actionPerformed.failure.IO.message=There is no associated editor for files of this type or the associated application failed to launch.", "ExternalViewerAction.actionPerformed.failure.support.message=This platform (operating system) does not support opening a file in an editor this way.", "ExternalViewerAction.actionPerformed.failure.missingFile.message=The file no longer exists.", - "ExternalViewerAction.actionPerformed.failure.permission.message=Permission to open the file was denied."}) + "ExternalViewerAction.actionPerformed.failure.permission.message=Permission to open the file was denied.", + "ExternalViewerAction.actionPerformed.failure.open.url=Cannot open URL"}) public static void openFile(String mimeType, String ext, File file) { /** * Check if the file MIME type or extension exists in the user defined @@ -133,7 +136,13 @@ public class ExternalViewerAction extends AbstractAction { } } else { try { - Desktop.getDesktop().open(file); + if (file.getPath().toLowerCase().contains("http")) { + String url_path = file.getPath().replaceAll("\\\\","/"); + Desktop.getDesktop().browse(new URI(url_path.replaceFirst("/","//"))); + } else { + Desktop.getDesktop().open(file); + } + } catch (IOException ex) { logger.log(Level.WARNING, "Could not find a viewer for the given file: " + file.getName(), ex); //NON-NLS JOptionPane.showMessageDialog(null, @@ -158,6 +167,12 @@ public class ExternalViewerAction extends AbstractAction { Bundle.ExternalViewerAction_actionPerformed_failure_permission_message(), Bundle.ExternalViewerAction_actionPerformed_failure_title(), JOptionPane.ERROR_MESSAGE); + } catch (URISyntaxException ex) { + logger.log(Level.WARNING, "Could not open URL provided: " + file.getPath(), ex); + JOptionPane.showMessageDialog(null, + Bundle.ExternalViewerAction_actionPerformed_failure_open_url(), + Bundle.ExternalViewerAction_actionPerformed_failure_title(), + JOptionPane.ERROR_MESSAGE); } } }