19 package org.sleuthkit.autopsy.report.taggedhashes;
21 import java.util.ArrayList;
22 import java.util.List;
23 import java.util.logging.Level;
25 import javax.swing.JOptionPane;
26 import javax.swing.JPanel;
27 import org.openide.util.NbBundle.Messages;
28 import org.openide.util.lookup.ServiceProvider;
29 import org.openide.windows.WindowManager;
58 return "Add Tagged Hashes";
63 return "Adds hashes of tagged files to a hash set.";
72 "AddTaggedHashesToHashDb.error.noHashSetsSelected=No hash set selected for export.",
73 "AddTaggedHashesToHashDb.error.noTagsSelected=No tags selected for export."
82 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
"No open Case",
"Exception while getting open case.", JOptionPane.ERROR_MESSAGE);
86 progressPanel.
start();
89 HashDb hashSet = configPanel.getSelectedHashDatabase();
90 if (hashSet == null) {
91 logger.log(Level.WARNING,
"No hash set selected for export.");
101 List<TagName> tagNames = configPanel.getSelectedTagNames();
102 if (tagNames.isEmpty()) {
103 logger.log(Level.WARNING,
"No tags selected for export.");
110 ArrayList<String> failedExports =
new ArrayList<>();
111 for (TagName tagName : tagNames) {
119 for (ContentTag tag : tags) {
121 Content content = tag.getContent();
122 if (content instanceof AbstractFile) {
123 if (null != ((AbstractFile) content).getMd5Hash()) {
126 }
catch (TskCoreException ex) {
128 failedExports.add(tag.getContent().getName());
131 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
"Unable to add the " + (tags.size() > 1 ?
"files" :
"file") +
" to the hash set. Hashes have not been calculated. Please configure and run an appropriate ingest module.",
"Add to Hash Set Error", JOptionPane.ERROR_MESSAGE);
136 }
catch (TskCoreException ex) {
138 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
"Error getting selected tags for case.",
"Hash Export Error", JOptionPane.ERROR_MESSAGE);
141 if (!failedExports.isEmpty()) {
142 StringBuilder errorMessage =
new StringBuilder(
"Failed to export hashes for the following files: ");
143 for (
int i = 0; i < failedExports.size(); ++i) {
144 errorMessage.append(failedExports.get(i));
145 if (failedExports.size() > 1 && i < failedExports.size() - 1) {
146 errorMessage.append(
",");
148 if (i == failedExports.size() - 1) {
149 errorMessage.append(
".");
152 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), errorMessage.toString(),
"Hash Export Error", JOptionPane.ERROR_MESSAGE);
161 configPanel =
new AddTaggedHashesToHashDbConfigPanel();
void complete(ReportStatus reportStatus)
JPanel getConfigurationPanel()
abstract String getHashSetName()
void setIndeterminate(boolean indeterminate)
void generateReport(String reportPath, ReportProgressPanel progressPanel)
TagsManager getTagsManager()
String getRelativeFilePath()
AddTaggedHashesToHashDb()
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
void updateStatusLabel(String statusMessage)
AddTaggedHashesToHashDbConfigPanel configPanel
abstract void addHashes(Content content)
static void error(String message)