Merge branch 'develop' of https://github.com/sleuthkit/autopsy into 7852-CleanUpScoCrChanges

This commit is contained in:
William Schaefer 2021-09-01 14:56:36 -04:00
commit c3880f11dc
42 changed files with 564 additions and 1461 deletions

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2017 Basis Technology Corp. * Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -43,6 +43,7 @@ import org.sleuthkit.autopsy.core.UserPreferences;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.ModuleSettings;
import org.sleuthkit.autopsy.coreutils.Version; import org.sleuthkit.autopsy.coreutils.Version;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
/** /**
* The action associated with the Case/Open Case menu item via the layer.xml * The action associated with the Case/Open Case menu item via the layer.xml
@ -64,6 +65,8 @@ public final class CaseOpenAction extends CallableSystemAction implements Action
private static final Logger LOGGER = Logger.getLogger(CaseOpenAction.class.getName()); private static final Logger LOGGER = Logger.getLogger(CaseOpenAction.class.getName());
private final FileFilter caseMetadataFileFilter; private final FileFilter caseMetadataFileFilter;
private final JFileChooserFactory fileChooserHelper;
/** /**
* Constructs the action associated with the Case/Open Case menu item via * Constructs the action associated with the Case/Open Case menu item via
* the layer.xml file, a toolbar button, and the Open Case button of the * the layer.xml file, a toolbar button, and the Open Case button of the
@ -72,6 +75,7 @@ public final class CaseOpenAction extends CallableSystemAction implements Action
*/ */
public CaseOpenAction() { public CaseOpenAction() {
caseMetadataFileFilter = new FileNameExtensionFilter(NbBundle.getMessage(CaseOpenAction.class, "CaseOpenAction.autFilter.title", Version.getName(), CaseMetadata.getFileExtension()), CaseMetadata.getFileExtension().substring(1)); caseMetadataFileFilter = new FileNameExtensionFilter(NbBundle.getMessage(CaseOpenAction.class, "CaseOpenAction.autFilter.title", Version.getName(), CaseMetadata.getFileExtension()), CaseMetadata.getFileExtension().substring(1));
fileChooserHelper = new JFileChooserFactory();
} }
/** /**
@ -80,7 +84,7 @@ public final class CaseOpenAction extends CallableSystemAction implements Action
* to open the case described by the file. * to open the case described by the file.
*/ */
void openCaseSelectionWindow() { void openCaseSelectionWindow() {
JFileChooser fileChooser = new JFileChooser(); JFileChooser fileChooser = fileChooserHelper.getChooser();
fileChooser.setDragEnabled(false); fileChooser.setDragEnabled(false);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setMultiSelectionEnabled(false); fileChooser.setMultiSelectionEnabled(false);

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2018 Basis Technology Corp. * Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -35,6 +35,7 @@ import org.sleuthkit.autopsy.coreutils.DriveUtils;
import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.ModuleSettings;
import org.sleuthkit.autopsy.coreutils.PathValidator; import org.sleuthkit.autopsy.coreutils.PathValidator;
import org.sleuthkit.autopsy.coreutils.TimeZoneUtils; import org.sleuthkit.autopsy.coreutils.TimeZoneUtils;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
import org.sleuthkit.datamodel.HashUtility; import org.sleuthkit.datamodel.HashUtility;
/** /**
@ -48,8 +49,10 @@ public class ImageFilePanel extends JPanel implements DocumentListener {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final String PROP_LASTIMAGE_PATH = "LBL_LastImage_PATH"; //NON-NLS private static final String PROP_LASTIMAGE_PATH = "LBL_LastImage_PATH"; //NON-NLS
private static final String[] SECTOR_SIZE_CHOICES = {"Auto Detect", "512", "1024", "2048", "4096"}; private static final String[] SECTOR_SIZE_CHOICES = {"Auto Detect", "512", "1024", "2048", "4096"};
private final JFileChooser fileChooser = new JFileChooser(); private final JFileChooserFactory fileChooserHelper = new JFileChooserFactory();
private JFileChooser fileChooser;
private final String contextName; private final String contextName;
private final List<FileFilter> fileChooserFilters;
/** /**
* Creates new form ImageFilePanel * Creates new form ImageFilePanel
@ -73,14 +76,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener {
sectorSizeComboBox.setSelectedIndex(0); sectorSizeComboBox.setSelectedIndex(0);
errorLabel.setVisible(false); errorLabel.setVisible(false);
this.fileChooserFilters = fileChooserFilters;
fileChooser.setDragEnabled(false);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setMultiSelectionEnabled(false);
fileChooserFilters.forEach(fileChooser::addChoosableFileFilter);
if (fileChooserFilters.isEmpty() == false) {
fileChooser.setFileFilter(fileChooserFilters.get(0));
}
} }
/** /**
@ -132,6 +128,21 @@ public class ImageFilePanel extends JPanel implements DocumentListener {
private JTextField getSha256TextField() { private JTextField getSha256TextField() {
return sha256HashTextField; return sha256HashTextField;
} }
private JFileChooser getChooser() {
if(fileChooser == null) {
fileChooser = fileChooserHelper.getChooser();
fileChooser.setDragEnabled(false);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setMultiSelectionEnabled(false);
fileChooserFilters.forEach(fileChooser::addChoosableFileFilter);
if (fileChooserFilters.isEmpty() == false) {
fileChooser.setFileFilter(fileChooserFilters.get(0));
}
}
return fileChooser;
}
/** /**
* This method is called from within the constructor to initialize the form. * This method is called from within the constructor to initialize the form.
@ -298,12 +309,13 @@ public class ImageFilePanel extends JPanel implements DocumentListener {
String oldText = getContentPaths(); String oldText = getContentPaths();
// set the current directory of the FileChooser if the ImagePath Field is valid // set the current directory of the FileChooser if the ImagePath Field is valid
File currentDir = new File(oldText); File currentDir = new File(oldText);
JFileChooser chooser = getChooser();
if (currentDir.exists()) { if (currentDir.exists()) {
fileChooser.setCurrentDirectory(currentDir); chooser.setCurrentDirectory(currentDir);
} }
if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
String path = fileChooser.getSelectedFile().getPath(); String path = chooser.getSelectedFile().getPath();
if (path.endsWith(".001")) { if (path.endsWith(".001")) {
String zeroX3_path = StringUtils.removeEnd(path, ".001") + ".000"; String zeroX3_path = StringUtils.removeEnd(path, ".001") + ".000";
if (new File(zeroX3_path).exists()) { if (new File(zeroX3_path).exists()) {

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2018 Basis Technology Corp. * Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -32,6 +32,7 @@ import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.coreutils.PlatformUtil;
import org.sleuthkit.autopsy.coreutils.TimeZoneUtils; import org.sleuthkit.autopsy.coreutils.TimeZoneUtils;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
import org.sleuthkit.autopsy.imagewriter.ImageWriterSettings; import org.sleuthkit.autopsy.imagewriter.ImageWriterSettings;
/** /**
@ -58,7 +59,8 @@ final class LocalDiskPanel extends JPanel {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private LocalDisk localDisk; private LocalDisk localDisk;
private boolean enableNext = false; private boolean enableNext = false;
private final JFileChooser fc = new JFileChooser(); private JFileChooser fc;
private final JFileChooserFactory chooserHelper;
/** /**
* Creates new form LocalDiskPanel * Creates new form LocalDiskPanel
@ -68,6 +70,7 @@ final class LocalDiskPanel extends JPanel {
customInit(); customInit();
createTimeZoneList(); createTimeZoneList();
createSectorSizeList(); createSectorSizeList();
chooserHelper = new JFileChooserFactory();
} }
/** /**
@ -261,6 +264,7 @@ final class LocalDiskPanel extends JPanel {
}//GEN-LAST:event_pathTextFieldKeyReleased }//GEN-LAST:event_pathTextFieldKeyReleased
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
fc = chooserHelper.getChooser();
String oldText = pathTextField.getText(); String oldText = pathTextField.getText();
// set the current directory of the FileChooser if the ImagePath Field is valid // set the current directory of the FileChooser if the ImagePath Field is valid
File currentFile = new File(oldText); File currentFile = new File(oldText);

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2012-2018 Basis Technology Corp. * Copyright 2012-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -32,6 +32,7 @@ import org.openide.util.NbBundle;
import org.openide.windows.WindowManager; import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.coreutils.DriveUtils; import org.sleuthkit.autopsy.coreutils.DriveUtils;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.SleuthkitCase;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
@ -45,7 +46,8 @@ class MissingImageDialog extends javax.swing.JDialog {
long obj_id; long obj_id;
SleuthkitCase db; SleuthkitCase db;
private final JFileChooser fileChooser = new JFileChooser(); private JFileChooser fileChooser;
private final JFileChooserFactory chooserHelper;
/** /**
* Instantiate a MissingImageDialog. * Instantiate a MissingImageDialog.
@ -58,17 +60,8 @@ class MissingImageDialog extends javax.swing.JDialog {
this.obj_id = obj_id; this.obj_id = obj_id;
this.db = db; this.db = db;
initComponents(); initComponents();
fileChooser.setDragEnabled(false); chooserHelper = new JFileChooserFactory();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setMultiSelectionEnabled(false);
List<FileFilter> fileFiltersList = ImageDSProcessor.getFileFiltersList();
for (FileFilter fileFilter : fileFiltersList) {
fileChooser.addChoosableFileFilter(fileFilter);
}
fileChooser.setFileFilter(fileFiltersList.get(0));
selectButton.setEnabled(false); selectButton.setEnabled(false);
} }
@ -270,6 +263,19 @@ class MissingImageDialog extends javax.swing.JDialog {
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
if(fileChooser == null) {
fileChooser = chooserHelper.getChooser();
fileChooser.setDragEnabled(false);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setMultiSelectionEnabled(false);
List<FileFilter> fileFiltersList = ImageDSProcessor.getFileFiltersList();
for (FileFilter fileFilter : fileFiltersList) {
fileChooser.addChoosableFileFilter(fileFilter);
}
fileChooser.setFileFilter(fileFiltersList.get(0));
}
String oldText = pathNameTextField.getText(); String oldText = pathNameTextField.getText();
lbWarning.setText(""); lbWarning.setText("");
// set the current directory of the FileChooser if the ImagePath Field is valid // set the current directory of the FileChooser if the ImagePath Field is valid

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2020 Basis Technology Corp. * Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -30,6 +30,7 @@ import javax.swing.event.DocumentListener;
import org.sleuthkit.autopsy.casemodule.Case.CaseType; import org.sleuthkit.autopsy.casemodule.Case.CaseType;
import org.sleuthkit.autopsy.coreutils.PathValidator; import org.sleuthkit.autopsy.coreutils.PathValidator;
import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.coreutils.PlatformUtil;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
/** /**
* The JPanel for the first page of the new case wizard. * The JPanel for the first page of the new case wizard.
@ -37,7 +38,7 @@ import org.sleuthkit.autopsy.coreutils.PlatformUtil;
@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { final class NewCaseVisualPanel1 extends JPanel implements DocumentListener {
private final JFileChooser fileChooser = new JFileChooser(); private final JFileChooserFactory fileChooserHelper = new JFileChooserFactory();
private final NewCaseWizardPanel1 wizPanel; private final NewCaseWizardPanel1 wizPanel;
/** /**
@ -353,8 +354,9 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener {
* @param evt the action event * @param evt the action event
*/ */
private void caseDirBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_caseDirBrowseButtonActionPerformed private void caseDirBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_caseDirBrowseButtonActionPerformed
JFileChooser fileChooser = fileChooserHelper.getChooser();
fileChooser.setDragEnabled(false); fileChooser.setDragEnabled(false);
if (!caseParentDirTextField.getText().trim().equals("")) { if (!caseParentDirTextField.getText().trim().isEmpty()) {
fileChooser.setCurrentDirectory(new File(caseParentDirTextField.getText())); fileChooser.setCurrentDirectory(new File(caseParentDirTextField.getText()));
} }
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2019 Basis Technology Corp. * Copyright 2019-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,8 +1,9 @@
CommandLineIngestSettingPanel_empty_report_name_mgs=Report profile name was empty, no profile created. CommandLineIngestSettingPanel_empty_report_name_mgs=Report profile name was empty, no profile created.
CommandLineIngestSettingPanel_existing_report_name_mgs=Report profile name was already exists, no profile created. CommandLineIngestSettingPanel_existing_report_name_mgs=Report profile name was already exists, no profile created.
CommandLineIngestSettingPanel_invalid_report_name_mgs=Report profile name contained illegal characters, no profile created.
CommandListIngestSettingsPanel_Default_Report_DisplayName=Default CommandListIngestSettingsPanel_Default_Report_DisplayName=Default
CommandListIngestSettingsPanel_Make_Config=Make new profile... CommandListIngestSettingsPanel_Make_Config=Make new profile...
CommandListIngestSettingsPanel_Report_Name_Msg=Please supply a report profile name (commas not allowed): CommandListIngestSettingsPanel_Report_Name_Msg=Please supply a report profile name (letters, digits, and underscore characters only):
OpenIDE-Module-Name=CommandLineAutopsy OpenIDE-Module-Name=CommandLineAutopsy
OptionsCategory_Keywords_Command_Line_Ingest_Settings=Command Line Ingest Settings OptionsCategory_Keywords_Command_Line_Ingest_Settings=Command Line Ingest Settings
OptionsCategory_Keywords_General=Options OptionsCategory_Keywords_General=Options

View File

@ -280,18 +280,15 @@ public class CommandLineIngestSettingsPanel extends javax.swing.JPanel {
add(nodePanel, java.awt.BorderLayout.CENTER); add(nodePanel, java.awt.BorderLayout.CENTER);
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
@Messages({ @Messages({
"CommandListIngestSettingsPanel_Report_Name_Msg=Please supply a report profile name (commas not allowed):", "CommandListIngestSettingsPanel_Report_Name_Msg=Please supply a report profile name (letters, digits, and underscore characters only):",
"CommandLineIngestSettingPanel_empty_report_name_mgs=Report profile name was empty, no profile created.", "CommandLineIngestSettingPanel_empty_report_name_mgs=Report profile name was empty, no profile created.",
"CommandLineIngestSettingPanel_existing_report_name_mgs=Report profile name was already exists, no profile created." "CommandLineIngestSettingPanel_existing_report_name_mgs=Report profile name was already exists, no profile created.",
"CommandLineIngestSettingPanel_invalid_report_name_mgs=Report profile name contained illegal characters, no profile created."
}) })
private void bnEditReportSettingsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnEditReportSettingsActionPerformed private void bnEditReportSettingsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnEditReportSettingsActionPerformed
String reportName = getReportName(); String reportName = getReportName();
if (reportName.equals(Bundle.CommandListIngestSettingsPanel_Make_Config())) { if (reportName.equals(Bundle.CommandListIngestSettingsPanel_Make_Config())) {
reportName = JOptionPane.showInputDialog(this, Bundle.CommandListIngestSettingsPanel_Report_Name_Msg()); reportName = JOptionPane.showInputDialog(this, Bundle.CommandListIngestSettingsPanel_Report_Name_Msg());
// sanitize report name. Remove all commas because in CommandLineOptionProcessor we use commas
// to separate multiple report names
reportName = reportName.replaceAll(",", "");
// User hit cancel // User hit cancel
if (reportName == null) { if (reportName == null) {
@ -302,6 +299,15 @@ public class CommandLineIngestSettingsPanel extends javax.swing.JPanel {
} else if (doesReportProfileNameExist(reportName)) { } else if (doesReportProfileNameExist(reportName)) {
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), Bundle.CommandLineIngestSettingPanel_existing_report_name_mgs()); JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), Bundle.CommandLineIngestSettingPanel_existing_report_name_mgs());
return; return;
} else {
// sanitize report name
String originalReportName = reportName;
reportName = reportName.replaceAll("[^A-Za-z0-9_]", "");
if (reportName.isEmpty() || (!(originalReportName.equals(reportName)))) {
// report name contained only invalid characters, display error
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), Bundle.CommandLineIngestSettingPanel_invalid_report_name_mgs());
return;
}
} }
} }

View File

@ -24,6 +24,7 @@ import java.awt.KeyboardFocusManager;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.logging.Level; import java.util.logging.Level;
@ -38,6 +39,7 @@ import org.openide.nodes.AbstractNode;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.openide.util.Lookup; import org.openide.util.Lookup;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.communications.ModifiableProxyLookup; import org.sleuthkit.autopsy.communications.ModifiableProxyLookup;
import org.sleuthkit.autopsy.corecomponents.TableFilterNode; import org.sleuthkit.autopsy.corecomponents.TableFilterNode;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
@ -46,8 +48,10 @@ import org.sleuthkit.autopsy.directorytree.DataResultFilterNode;
import org.sleuthkit.datamodel.AbstractContent; import org.sleuthkit.datamodel.AbstractContent;
import org.sleuthkit.datamodel.Account; import org.sleuthkit.datamodel.Account;
import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifact;
import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_ASSOCIATED_OBJECT;
import org.sleuthkit.datamodel.BlackboardAttribute;
import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.SleuthkitCase;
/** /**
* A Panel that shows the media (thumbnails) for the selected account. * A Panel that shows the media (thumbnails) for the selected account.
@ -65,6 +69,7 @@ final class MediaViewer extends JPanel implements RelationshipsViewer, ExplorerM
private final MessageDataContent contentViewer; private final MessageDataContent contentViewer;
private MediaViewerWorker worker; private MediaViewerWorker worker;
private SelectionWorker selectionWorker;
@Messages({ @Messages({
"MediaViewer_Name=Media Attachments" "MediaViewer_Name=Media Attachments"
@ -106,11 +111,15 @@ final class MediaViewer extends JPanel implements RelationshipsViewer, ExplorerM
@Override @Override
public void setSelectionInfo(SelectionInfo info) { public void setSelectionInfo(SelectionInfo info) {
contentViewer.setNode(null); contentViewer.setNode(null);
thumbnailViewer.resetComponent(); thumbnailViewer.setNode(null);
if (worker != null) { if (worker != null) {
worker.cancel(true); worker.cancel(true);
} }
if(selectionWorker != null) {
selectionWorker.cancel(true);
}
worker = new MediaViewerWorker(info); worker = new MediaViewerWorker(info);
@ -181,21 +190,66 @@ final class MediaViewer extends JPanel implements RelationshipsViewer, ExplorerM
*/ */
private void handleNodeSelectionChange() { private void handleNodeSelectionChange() {
final Node[] nodes = tableEM.getSelectedNodes(); final Node[] nodes = tableEM.getSelectedNodes();
contentViewer.setNode(null);
if(selectionWorker != null) {
selectionWorker.cancel(true);
}
if (nodes != null && nodes.length == 1) { if (nodes != null && nodes.length == 1) {
AbstractContent thumbnail = nodes[0].getLookup().lookup(AbstractContent.class); AbstractContent thumbnail = nodes[0].getLookup().lookup(AbstractContent.class);
if (thumbnail != null) { if (thumbnail != null) {
try { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Content parentContent = thumbnail.getParent(); selectionWorker = new SelectionWorker(thumbnail);
if (parentContent != null && parentContent instanceof BlackboardArtifact) { selectionWorker.execute();
contentViewer.setNode(new BlackboardArtifactNode((BlackboardArtifact) parentContent)); }
} }
} catch (TskCoreException ex) { }
logger.log(Level.WARNING, "Unable to get parent Content from AbstraceContent instance.", ex); //NON-NLS
/**
* A SwingWorker to get the artifact associated with the selected thumbnail.
*/
private class SelectionWorker extends SwingWorker<BlackboardArtifact, Void> {
private final AbstractContent thumbnail;
// Construct a SelectionWorker.
SelectionWorker(AbstractContent thumbnail) {
this.thumbnail = thumbnail;
}
@Override
protected BlackboardArtifact doInBackground() throws Exception {
SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase();
List<BlackboardArtifact> artifactsList = skCase.getBlackboardArtifacts(TSK_ASSOCIATED_OBJECT, thumbnail.getId());
for (BlackboardArtifact contextArtifact : artifactsList) {
BlackboardAttribute associatedArtifactAttribute = contextArtifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT));
if (associatedArtifactAttribute != null) {
long artifactId = associatedArtifactAttribute.getValueLong();
return contextArtifact.getSleuthkitCase().getBlackboardArtifact(artifactId);
} }
} }
} else { return null;
contentViewer.setNode(null); }
@Override
protected void done() {
if (isCancelled()) {
return;
}
try {
BlackboardArtifact artifact = get();
if (artifact != null) {
contentViewer.setNode(new BlackboardArtifactNode(artifact));
} else {
contentViewer.setNode(null);
}
} catch (InterruptedException | ExecutionException ex) {
logger.log(Level.SEVERE, "Failed message viewer based on thumbnail selection. thumbnailID = " + thumbnail.getId(), ex);
} finally {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2018-2019 Basis Technology Corp. * Copyright 2018-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -56,6 +56,7 @@ import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -75,6 +76,8 @@ class PListViewer extends javax.swing.JPanel implements FileTypeViewer, Explorer
private ExplorerManager explorerManager; private ExplorerManager explorerManager;
private NSObject rootDict; private NSObject rootDict;
private final JFileChooserFactory fileChooserHelper = new JFileChooserFactory();
/** /**
* Creates new form PListViewer * Creates new form PListViewer
@ -203,7 +206,7 @@ class PListViewer extends javax.swing.JPanel implements FileTypeViewer, Explorer
return; return;
} }
final JFileChooser fileChooser = new JFileChooser(); final JFileChooser fileChooser = fileChooserHelper.getChooser();
fileChooser.setCurrentDirectory(new File(openCase.getExportDirectory())); fileChooser.setCurrentDirectory(new File(openCase.getExportDirectory()));
fileChooser.setFileFilter(new FileNameExtensionFilter("XML file", "xml")); fileChooser.setFileFilter(new FileNameExtensionFilter("XML file", "xml"));

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2018-2019 Basis Technology Corp. * Copyright 2018-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -49,6 +49,7 @@ import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.autopsy.coreutils.SQLiteTableReader; import org.sleuthkit.autopsy.coreutils.SQLiteTableReader;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
/** /**
* A file content viewer for SQLite database files. * A file content viewer for SQLite database files.
@ -74,6 +75,8 @@ class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer {
private int currPage = 0; // curr page of rows being displayed private int currPage = 0; // curr page of rows being displayed
SwingWorker<?, ?> worker; SwingWorker<?, ?> worker;
private final JFileChooserFactory chooserHelper = new JFileChooserFactory();
/** /**
* Constructs a file content viewer for SQLite database files. * Constructs a file content viewer for SQLite database files.
@ -280,7 +283,7 @@ class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer {
private void exportCsvButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportCsvButtonActionPerformed private void exportCsvButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportCsvButtonActionPerformed
Case openCase = Case.getCurrentCase(); Case openCase = Case.getCurrentCase();
File caseDirectory = new File(openCase.getExportDirectory()); File caseDirectory = new File(openCase.getExportDirectory());
JFileChooser fileChooser = new JFileChooser(); JFileChooser fileChooser = chooserHelper.getChooser();
fileChooser.setDragEnabled(false); fileChooser.setDragEnabled(false);
fileChooser.setCurrentDirectory(caseDirectory); fileChooser.setCurrentDirectory(caseDirectory);
//Set a filter to let the filechooser only work for csv files //Set a filter to let the filechooser only work for csv files

View File

@ -40,18 +40,17 @@ import org.sleuthkit.datamodel.TskCoreException;
*/ */
@ServiceProvider(service = DataContentViewer.class, position = 7) @ServiceProvider(service = DataContentViewer.class, position = 7)
public class AnalysisResultsContentViewer implements DataContentViewer { public class AnalysisResultsContentViewer implements DataContentViewer {
private static final Logger logger = Logger.getLogger(AnalysisResultsContentPanel.class.getName()); private static final Logger logger = Logger.getLogger(AnalysisResultsContentPanel.class.getName());
// isPreferred value // isPreferred value
private static final int PREFERRED_VALUE = 3; private static final int PREFERRED_VALUE = 3;
private final AnalysisResultsViewModel viewModel = new AnalysisResultsViewModel(); private final AnalysisResultsViewModel viewModel = new AnalysisResultsViewModel();
private final AnalysisResultsContentPanel panel = new AnalysisResultsContentPanel(); private final AnalysisResultsContentPanel panel = new AnalysisResultsContentPanel();
private SwingWorker<?, ?> worker = null; private SwingWorker<?, ?> worker = null;
@NbBundle.Messages({ @NbBundle.Messages({
"AnalysisResultsContentViewer_title=Analysis Results" "AnalysisResultsContentViewer_title=Analysis Results"
}) })
@ -135,11 +134,11 @@ public class AnalysisResultsContentViewer implements DataContentViewer {
if (content instanceof AnalysisResult) { if (content instanceof AnalysisResult) {
return true; return true;
} }
if (content == null || content instanceof BlackboardArtifact) { if (content == null || content instanceof BlackboardArtifact) {
continue; continue;
} }
try { try {
if (Case.getCurrentCaseThrows().getSleuthkitCase().getBlackboard().hasAnalysisResults(content.getId())) { if (Case.getCurrentCaseThrows().getSleuthkitCase().getBlackboard().hasAnalysisResults(content.getId())) {
return true; return true;
@ -148,7 +147,7 @@ public class AnalysisResultsContentViewer implements DataContentViewer {
logger.log(Level.SEVERE, "Unable to get analysis results for file with obj id " + content.getId(), ex); logger.log(Level.SEVERE, "Unable to get analysis results for file with obj id " + content.getId(), ex);
} }
} }
return false; return false;
} }

View File

@ -252,7 +252,7 @@ public class AnalysisResultsViewModel {
try { try {
nodeContent = Optional.of(content); nodeContent = Optional.of(content);
// get the aggregate score of that content // get the aggregate score of that content
aggregateScore = Optional.ofNullable(content.getAggregateScore()); aggregateScore = Optional.ofNullable(content.getAggregateScore());

View File

@ -55,6 +55,7 @@ import org.sleuthkit.autopsy.machinesettings.UserMachinePreferencesException;
import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.core.UserPreferences;
import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.coreutils.PlatformUtil;
import org.sleuthkit.autopsy.coreutils.Version; import org.sleuthkit.autopsy.coreutils.Version;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
import org.sleuthkit.autopsy.machinesettings.UserMachinePreferences.TempDirChoice; import org.sleuthkit.autopsy.machinesettings.UserMachinePreferences.TempDirChoice;
import org.sleuthkit.autopsy.report.ReportBranding; import org.sleuthkit.autopsy.report.ReportBranding;
@ -82,8 +83,8 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final String DEFAULT_HEAP_DUMP_FILE_FIELD = ""; private static final String DEFAULT_HEAP_DUMP_FILE_FIELD = "";
private final JFileChooser logoFileChooser; private JFileChooser logoFileChooser;
private final JFileChooser tempDirChooser; private JFileChooser tempDirChooser;
private static final String ETC_FOLDER_NAME = "etc"; private static final String ETC_FOLDER_NAME = "etc";
private static final String CONFIG_FILE_EXTENSION = ".conf"; private static final String CONFIG_FILE_EXTENSION = ".conf";
private static final long ONE_BILLION = 1000000000L; //used to roughly convert system memory from bytes to gigabytes private static final long ONE_BILLION = 1000000000L; //used to roughly convert system memory from bytes to gigabytes
@ -94,27 +95,17 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel {
private String initialMemValue = Long.toString(Runtime.getRuntime().maxMemory() / ONE_BILLION); private String initialMemValue = Long.toString(Runtime.getRuntime().maxMemory() / ONE_BILLION);
private final ReportBranding reportBranding; private final ReportBranding reportBranding;
private final JFileChooser heapFileChooser; private JFileChooser heapFileChooser;
private final JFileChooserFactory logoChooserHelper = new JFileChooserFactory();
private final JFileChooserFactory heapChooserHelper = new JFileChooserFactory();
private final JFileChooserFactory tempChooserHelper = new JFileChooserFactory();
/** /**
* Instantiate the Autopsy options panel. * Instantiate the Autopsy options panel.
*/ */
AutopsyOptionsPanel() { AutopsyOptionsPanel() {
initComponents(); initComponents();
logoFileChooser = new JFileChooser();
logoFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
logoFileChooser.setMultiSelectionEnabled(false);
logoFileChooser.setAcceptAllFileFilterUsed(false);
logoFileChooser.setFileFilter(new GeneralFilter(GeneralFilter.GRAPHIC_IMAGE_EXTS, GeneralFilter.GRAPHIC_IMG_DECR));
tempDirChooser = new JFileChooser();
tempDirChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
tempDirChooser.setMultiSelectionEnabled(false);
heapFileChooser = new JFileChooser();
heapFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
heapFileChooser.setMultiSelectionEnabled(false);
if (!isJVMHeapSettingsCapable()) { if (!isJVMHeapSettingsCapable()) {
//32 bit JVM has a max heap size of 1.4 gb to 4 gb depending on OS //32 bit JVM has a max heap size of 1.4 gb to 4 gb depending on OS
//So disabling the setting of heap size when the JVM is not 64 bit //So disabling the setting of heap size when the JVM is not 64 bit
@ -1242,6 +1233,11 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel {
"# {0} - path", "# {0} - path",
"AutopsyOptionsPanel_tempDirectoryBrowseButtonActionPerformed_onInvalidPath_description=Unable to create temporary directory within specified path: {0}",}) "AutopsyOptionsPanel_tempDirectoryBrowseButtonActionPerformed_onInvalidPath_description=Unable to create temporary directory within specified path: {0}",})
private void tempDirectoryBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tempDirectoryBrowseButtonActionPerformed private void tempDirectoryBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tempDirectoryBrowseButtonActionPerformed
if(tempDirChooser == null) {
tempDirChooser = tempChooserHelper.getChooser();
tempDirChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
tempDirChooser.setMultiSelectionEnabled(false);
}
int returnState = tempDirChooser.showOpenDialog(this); int returnState = tempDirChooser.showOpenDialog(this);
if (returnState == JFileChooser.APPROVE_OPTION) { if (returnState == JFileChooser.APPROVE_OPTION) {
String specifiedPath = tempDirChooser.getSelectedFile().getPath(); String specifiedPath = tempDirChooser.getSelectedFile().getPath();
@ -1318,6 +1314,13 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel {
}//GEN-LAST:event_defaultLogoRBActionPerformed }//GEN-LAST:event_defaultLogoRBActionPerformed
private void browseLogosButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseLogosButtonActionPerformed private void browseLogosButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseLogosButtonActionPerformed
if(logoFileChooser == null) {
logoFileChooser = logoChooserHelper.getChooser();
logoFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
logoFileChooser.setMultiSelectionEnabled(false);
logoFileChooser.setAcceptAllFileFilterUsed(false);
logoFileChooser.setFileFilter(new GeneralFilter(GeneralFilter.GRAPHIC_IMAGE_EXTS, GeneralFilter.GRAPHIC_IMG_DECR));
}
String oldLogoPath = agencyLogoPathField.getText(); String oldLogoPath = agencyLogoPathField.getText();
int returnState = logoFileChooser.showOpenDialog(this); int returnState = logoFileChooser.showOpenDialog(this);
if (returnState == JFileChooser.APPROVE_OPTION) { if (returnState == JFileChooser.APPROVE_OPTION) {
@ -1360,6 +1363,11 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel {
"AutopsyOptionsPanel_heapDumpBrowseButtonActionPerformed_fileAlreadyExistsMessage=File already exists. Please select a new location." "AutopsyOptionsPanel_heapDumpBrowseButtonActionPerformed_fileAlreadyExistsMessage=File already exists. Please select a new location."
}) })
private void heapDumpBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_heapDumpBrowseButtonActionPerformed private void heapDumpBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_heapDumpBrowseButtonActionPerformed
if(heapFileChooser == null) {
heapFileChooser = heapChooserHelper.getChooser();
heapFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
heapFileChooser.setMultiSelectionEnabled(false);
}
String oldHeapPath = heapDumpFileField.getText(); String oldHeapPath = heapDumpFileField.getText();
if (!StringUtils.isBlank(oldHeapPath)) { if (!StringUtils.isBlank(oldHeapPath)) {
heapFileChooser.setCurrentDirectory(new File(oldHeapPath)); heapFileChooser.setCurrentDirectory(new File(oldHeapPath));

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2018 Basis Technology Corp. * Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -32,6 +32,7 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.ModuleSettings;
import org.sleuthkit.autopsy.coreutils.PathValidator; import org.sleuthkit.autopsy.coreutils.PathValidator;
import org.sleuthkit.autopsy.coreutils.TimeZoneUtils; import org.sleuthkit.autopsy.coreutils.TimeZoneUtils;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
/** /**
* Allows examiner to supply a raw data source. * Allows examiner to supply a raw data source.
@ -41,7 +42,8 @@ final class RawDSInputPanel extends JPanel implements DocumentListener {
private static final long TWO_GB = 2000000000L; private static final long TWO_GB = 2000000000L;
private static final long serialVersionUID = 1L; //default private static final long serialVersionUID = 1L; //default
private final String PROP_LASTINPUT_PATH = "LBL_LastInputFile_PATH"; private final String PROP_LASTINPUT_PATH = "LBL_LastInputFile_PATH";
private final JFileChooser fc = new JFileChooser(); private JFileChooser fc;
private JFileChooserFactory chooserHelper = new JFileChooserFactory();
// Externally supplied name is used to store settings // Externally supplied name is used to store settings
private final String contextName; private final String contextName;
/** /**
@ -51,11 +53,6 @@ final class RawDSInputPanel extends JPanel implements DocumentListener {
initComponents(); initComponents();
errorLabel.setVisible(false); errorLabel.setVisible(false);
fc.setDragEnabled(false);
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setMultiSelectionEnabled(false);
this.contextName = context; this.contextName = context;
} }
@ -200,18 +197,25 @@ final class RawDSInputPanel extends JPanel implements DocumentListener {
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
String oldText = pathTextField.getText(); if (fc == null) {
// set the current directory of the FileChooser if the ImagePath Field is valid fc = chooserHelper.getChooser();
File currentDir = new File(oldText); fc.setDragEnabled(false);
if (currentDir.exists()) { fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setCurrentDirectory(currentDir); fc.setMultiSelectionEnabled(false);
} }
int retval = fc.showOpenDialog(this); String oldText = pathTextField.getText();
if (retval == JFileChooser.APPROVE_OPTION) { // set the current directory of the FileChooser if the ImagePath Field is valid
String path = fc.getSelectedFile().getPath(); File currentDir = new File(oldText);
pathTextField.setText(path); if (currentDir.exists()) {
} fc.setCurrentDirectory(currentDir);
}
int retval = fc.showOpenDialog(this);
if (retval == JFileChooser.APPROVE_OPTION) {
String path = fc.getSelectedFile().getPath();
pathTextField.setText(path);
}
}//GEN-LAST:event_browseButtonActionPerformed }//GEN-LAST:event_browseButtonActionPerformed
private void j2GBBreakupRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_j2GBBreakupRadioButtonActionPerformed private void j2GBBreakupRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_j2GBBreakupRadioButtonActionPerformed

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2019 Basis Technology Corp. * Copyright 2019-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -30,6 +30,7 @@ import javax.swing.JPanel;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.ModuleSettings;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
/** /**
* Allows an examiner to configure the XRY Data source processor. * Allows an examiner to configure the XRY Data source processor.
@ -49,6 +50,8 @@ final class XRYDataSourceProcessorConfigPanel extends JPanel {
//panel will indicate when it is ready for an update. //panel will indicate when it is ready for an update.
private final PropertyChangeSupport pcs; private final PropertyChangeSupport pcs;
private final JFileChooserFactory chooserHelper = new JFileChooserFactory();
/** /**
* Creates new form XRYDataSourceConfigPanel. * Creates new form XRYDataSourceConfigPanel.
* Prevent direct instantiation. * Prevent direct instantiation.
@ -191,7 +194,7 @@ final class XRYDataSourceProcessorConfigPanel extends JPanel {
* report folder. * report folder.
*/ */
private void fileBrowserButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileBrowserButtonActionPerformed private void fileBrowserButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileBrowserButtonActionPerformed
JFileChooser fileChooser = new JFileChooser(); JFileChooser fileChooser = chooserHelper.getChooser();
fileChooser.setMultiSelectionEnabled(false); fileChooser.setMultiSelectionEnabled(false);
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
Optional<Path> lastUsedPath = getLastUsedPath(); Optional<Path> lastUsedPath = getLastUsedPath();

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2018 Basis Technology Corp. * Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -26,6 +26,7 @@ import javax.swing.event.DocumentListener;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.GeneralFilter; import org.sleuthkit.autopsy.casemodule.GeneralFilter;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector; import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector;
/** /**
@ -35,7 +36,9 @@ import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector;
class AddExternalViewerRulePanel extends javax.swing.JPanel { class AddExternalViewerRulePanel extends javax.swing.JPanel {
private static final Logger logger = Logger.getLogger(AddExternalViewerRulePanel.class.getName()); private static final Logger logger = Logger.getLogger(AddExternalViewerRulePanel.class.getName());
private final JFileChooser fc = new JFileChooser(); private static final long serialVersionUID = 1L;
private JFileChooser fc;
private final JFileChooserFactory chooserHelper = new JFileChooserFactory();
private static final GeneralFilter exeFilter = new GeneralFilter(GeneralFilter.EXECUTABLE_EXTS, GeneralFilter.EXECUTABLE_DESC); private static final GeneralFilter exeFilter = new GeneralFilter(GeneralFilter.EXECUTABLE_EXTS, GeneralFilter.EXECUTABLE_DESC);
enum EVENT { enum EVENT {
@ -47,10 +50,6 @@ class AddExternalViewerRulePanel extends javax.swing.JPanel {
*/ */
AddExternalViewerRulePanel() { AddExternalViewerRulePanel() {
initComponents(); initComponents();
fc.setDragEnabled(false);
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setMultiSelectionEnabled(false);
fc.setFileFilter(exeFilter);
customize(); customize();
} }
@ -260,6 +259,13 @@ class AddExternalViewerRulePanel extends javax.swing.JPanel {
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
if(fc == null) {
fc = chooserHelper.getChooser();
fc.setDragEnabled(false);
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setMultiSelectionEnabled(false);
fc.setFileFilter(exeFilter);
}
int returnState = fc.showOpenDialog(this); int returnState = fc.showOpenDialog(this);
if (returnState == JFileChooser.APPROVE_OPTION) { if (returnState == JFileChooser.APPROVE_OPTION) {
String path = fc.getSelectedFile().getPath(); String path = fc.getSelectedFile().getPath();

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2019 Basis Technology Corp. * Copyright 2019-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -51,6 +51,7 @@ import org.sleuthkit.autopsy.datamodel.AbstractAbstractFileNode.AbstractFileProp
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.openide.nodes.Node.PropertySet; import org.openide.nodes.Node.PropertySet;
import org.openide.nodes.Node.Property; import org.openide.nodes.Node.Property;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
/** /**
* Exports CSV version of result nodes to a location selected by the user. * Exports CSV version of result nodes to a location selected by the user.
@ -68,6 +69,8 @@ public final class ExportCSVAction extends AbstractAction {
// org.openide.nodes.NodeOp.findActions(Node[] nodes) will only pick up an Action if every // org.openide.nodes.NodeOp.findActions(Node[] nodes) will only pick up an Action if every
// node in the array returns a reference to the same action object from Node.getActions(boolean). // node in the array returns a reference to the same action object from Node.getActions(boolean).
private static ExportCSVAction instance; private static ExportCSVAction instance;
private static final JFileChooserFactory chooserHelper = new JFileChooserFactory();
/** /**
* Get an instance of the Action. See above for why * Get an instance of the Action. See above for why
@ -125,7 +128,7 @@ public final class ExportCSVAction extends AbstractAction {
// Set up the file chooser with a default name and either the Export // Set up the file chooser with a default name and either the Export
// folder or the last used folder. // folder or the last used folder.
String fileName = getDefaultOutputFileName(nodesToExport.iterator().next().getParentNode()); String fileName = getDefaultOutputFileName(nodesToExport.iterator().next().getParentNode());
JFileChooser fileChooser = new JFileChooser(); JFileChooser fileChooser = chooserHelper.getChooser();
fileChooser.setCurrentDirectory(new File(getExportDirectory(Case.getCurrentCaseThrows()))); fileChooser.setCurrentDirectory(new File(getExportDirectory(Case.getCurrentCaseThrows())));
fileChooser.setSelectedFile(new File(fileName)); fileChooser.setSelectedFile(new File(fileName));
fileChooser.setFileFilter(new FileNameExtensionFilter("csv file", "csv")); fileChooser.setFileFilter(new FileNameExtensionFilter("csv file", "csv"));

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2018 Basis Technology Corp. * Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -33,6 +33,7 @@ import org.netbeans.spi.options.OptionsPanelController;
import org.sleuthkit.autopsy.casemodule.GeneralFilter; import org.sleuthkit.autopsy.casemodule.GeneralFilter;
import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.core.UserPreferences;
import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.coreutils.PlatformUtil;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
/** /**
* An options panel for the user to create, edit, and delete associations for * An options panel for the user to create, edit, and delete associations for
@ -42,9 +43,13 @@ import org.sleuthkit.autopsy.coreutils.PlatformUtil;
@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
final class ExternalViewerGlobalSettingsPanel extends javax.swing.JPanel implements OptionsPanel { final class ExternalViewerGlobalSettingsPanel extends javax.swing.JPanel implements OptionsPanel {
private ExternalViewerGlobalSettingsTableModel tableModel; private static final long serialVersionUID = 1L;
public ExternalViewerGlobalSettingsPanel() { private ExternalViewerGlobalSettingsTableModel tableModel;
private final JFileChooserFactory chooserHelper = new JFileChooserFactory();
ExternalViewerGlobalSettingsPanel() {
this(new ExternalViewerGlobalSettingsTableModel(new String[] { this(new ExternalViewerGlobalSettingsTableModel(new String[] {
"Mime type/Extension", "Application"})); "Mime type/Extension", "Application"}));
} }
@ -52,7 +57,7 @@ final class ExternalViewerGlobalSettingsPanel extends javax.swing.JPanel impleme
/** /**
* Creates new form ExternalViewerGlobalSettingsPanel * Creates new form ExternalViewerGlobalSettingsPanel
*/ */
public ExternalViewerGlobalSettingsPanel(ExternalViewerGlobalSettingsTableModel tableModel) { ExternalViewerGlobalSettingsPanel(ExternalViewerGlobalSettingsTableModel tableModel) {
initComponents(); initComponents();
this.tableModel = tableModel; this.tableModel = tableModel;
customizeComponents(tableModel); customizeComponents(tableModel);
@ -335,7 +340,7 @@ final class ExternalViewerGlobalSettingsPanel extends javax.swing.JPanel impleme
}//GEN-LAST:event_deleteRuleButtonActionPerformed }//GEN-LAST:event_deleteRuleButtonActionPerformed
private void browseHxDDirectoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseHxDDirectoryActionPerformed private void browseHxDDirectoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseHxDDirectoryActionPerformed
JFileChooser fileWindow = new JFileChooser(); JFileChooser fileWindow = chooserHelper.getChooser();
fileWindow.setFileSelectionMode(JFileChooser.FILES_ONLY); fileWindow.setFileSelectionMode(JFileChooser.FILES_ONLY);
GeneralFilter exeFilter = new GeneralFilter(GeneralFilter.EXECUTABLE_EXTS, GeneralFilter.EXECUTABLE_DESC); GeneralFilter exeFilter = new GeneralFilter(GeneralFilter.EXECUTABLE_EXTS, GeneralFilter.EXECUTABLE_DESC);
File HxDPathFile = new File(HxDPath.getText()); File HxDPathFile = new File(HxDPath.getText());

View File

@ -33,9 +33,6 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import java.util.logging.Level; import java.util.logging.Level;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
@ -50,6 +47,7 @@ import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
import org.sleuthkit.datamodel.AbstractContent; import org.sleuthkit.datamodel.AbstractContent;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.Content;
@ -78,9 +76,7 @@ final class ExtractUnallocAction extends AbstractAction {
private final Volume volume; private final Volume volume;
private final Image image; private final Image image;
private final FutureTask<JFileChooser> futureFileChooser = new FutureTask<>(CustomFileChooser::new); private final JFileChooserFactory chooserFactory;
private JFileChooser fileChooser = null;
/** /**
* Create an instance of ExtractUnallocAction with a volume. * Create an instance of ExtractUnallocAction with a volume.
@ -90,7 +86,7 @@ final class ExtractUnallocAction extends AbstractAction {
*/ */
ExtractUnallocAction(String title, Volume volume) { ExtractUnallocAction(String title, Volume volume) {
this(title, null, volume); this(title, null, volume);
} }
/** /**
@ -110,9 +106,8 @@ final class ExtractUnallocAction extends AbstractAction {
this.volume = null; this.volume = null;
this.image = image; this.image = image;
ExecutorService executor = Executors.newSingleThreadExecutor(); chooserFactory = new JFileChooserFactory(CustomFileChooser.class);
executor.execute(futureFileChooser);
} }
/** /**
@ -138,13 +133,7 @@ final class ExtractUnallocAction extends AbstractAction {
return; return;
} }
if (fileChooser == null) { JFileChooser fileChooser = chooserFactory.getChooser();
try {
fileChooser = futureFileChooser.get();
} catch (InterruptedException | ExecutionException ex) {
fileChooser = new CustomFileChooser();
}
}
fileChooser.setCurrentDirectory(new File(getExportDirectory(openCase))); fileChooser.setCurrentDirectory(new File(getExportDirectory(openCase)));
if (JFileChooser.APPROVE_OPTION != fileChooser.showSaveDialog((Component) event.getSource())) { if (JFileChooser.APPROVE_OPTION != fileChooser.showSaveDialog((Component) event.getSource())) {
@ -753,11 +742,11 @@ final class ExtractUnallocAction extends AbstractAction {
} }
// A Custome JFileChooser for this Action Class. // A Custome JFileChooser for this Action Class.
private class CustomFileChooser extends JFileChooser { public static class CustomFileChooser extends JFileChooser {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
CustomFileChooser() { public CustomFileChooser() {
initalize(); initalize();
} }

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2013-2019 Basis Technology Corp. * Copyright 2013-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -42,6 +42,7 @@ import org.sleuthkit.autopsy.coreutils.FileUtil;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.datamodel.ContentUtils; import org.sleuthkit.autopsy.datamodel.ContentUtils;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
/** /**
@ -51,6 +52,9 @@ public class ExtractActionHelper {
private final Logger logger = Logger.getLogger(ExtractActionHelper.class.getName()); private final Logger logger = Logger.getLogger(ExtractActionHelper.class.getName());
private String userDefinedExportPath; private String userDefinedExportPath;
private final JFileChooserFactory extractFileHelper = new JFileChooserFactory();
private final JFileChooserFactory extractFilesHelper = new JFileChooserFactory();
/** /**
* Extract the specified collection of files with an event specified for * Extract the specified collection of files with an event specified for
@ -89,7 +93,7 @@ public class ExtractActionHelper {
logger.log(Level.INFO, "Exception while getting open case.", ex); //NON-NLS logger.log(Level.INFO, "Exception while getting open case.", ex); //NON-NLS
return; return;
} }
JFileChooser fileChooser = new JFileChooser(); JFileChooser fileChooser = extractFileHelper.getChooser();
fileChooser.setCurrentDirectory(new File(getExportDirectory(openCase))); fileChooser.setCurrentDirectory(new File(getExportDirectory(openCase)));
// If there is an attribute name, change the ":". Otherwise the extracted file will be hidden // If there is an attribute name, change the ":". Otherwise the extracted file will be hidden
fileChooser.setSelectedFile(new File(FileUtil.escapeFileName(selectedFile.getName()))); fileChooser.setSelectedFile(new File(FileUtil.escapeFileName(selectedFile.getName())));
@ -117,7 +121,7 @@ public class ExtractActionHelper {
logger.log(Level.INFO, "Exception while getting open case.", ex); //NON-NLS logger.log(Level.INFO, "Exception while getting open case.", ex); //NON-NLS
return; return;
} }
JFileChooser folderChooser = new JFileChooser(); JFileChooser folderChooser = extractFilesHelper.getChooser();
folderChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); folderChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
folderChooser.setCurrentDirectory(new File(getExportDirectory(openCase))); folderChooser.setCurrentDirectory(new File(getExportDirectory(openCase)));
if (folderChooser.showSaveDialog((Component) event.getSource()) == JFileChooser.APPROVE_OPTION) { if (folderChooser.showSaveDialog((Component) event.getSource()) == JFileChooser.APPROVE_OPTION) {

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2019 Basis Technology Corp. * Copyright 2019-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -35,6 +35,7 @@ import org.sleuthkit.autopsy.casemodule.GeneralFilter;
import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.core.UserPreferences;
import org.sleuthkit.autopsy.corecomponents.OptionsPanel; import org.sleuthkit.autopsy.corecomponents.OptionsPanel;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
/** /**
* A panel to allow the user to set the custom properties of the geolocation * A panel to allow the user to set the custom properties of the geolocation
@ -46,6 +47,8 @@ final class GeolocationSettingsPanel extends javax.swing.JPanel implements Optio
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final Logger logger = Logger.getLogger(GeolocationSettingsPanel.class.getName()); private static final Logger logger = Logger.getLogger(GeolocationSettingsPanel.class.getName());
private static final JFileChooserFactory chooserHelper = new JFileChooserFactory();
/** /**
* Creates new GeolocationSettingsPanel * Creates new GeolocationSettingsPanel
@ -313,7 +316,7 @@ final class GeolocationSettingsPanel extends javax.swing.JPanel implements Optio
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void zipFileBrowseBntActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zipFileBrowseBntActionPerformed private void zipFileBrowseBntActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zipFileBrowseBntActionPerformed
JFileChooser fileWindow = new JFileChooser(); JFileChooser fileWindow = chooserHelper.getChooser();
fileWindow.setFileSelectionMode(JFileChooser.FILES_ONLY); fileWindow.setFileSelectionMode(JFileChooser.FILES_ONLY);
GeneralFilter fileFilter = new GeneralFilter(Arrays.asList(".zip"), "Zips (*.zip)"); //NON-NLS GeneralFilter fileFilter = new GeneralFilter(Arrays.asList(".zip"), "Zips (*.zip)"); //NON-NLS
fileWindow.setDragEnabled(false); fileWindow.setDragEnabled(false);
@ -374,7 +377,7 @@ final class GeolocationSettingsPanel extends javax.swing.JPanel implements Optio
}//GEN-LAST:event_mbtilesRBtnActionPerformed }//GEN-LAST:event_mbtilesRBtnActionPerformed
private void mbtilesBrowseBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mbtilesBrowseBtnActionPerformed private void mbtilesBrowseBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mbtilesBrowseBtnActionPerformed
JFileChooser fileWindow = new JFileChooser(); JFileChooser fileWindow = chooserHelper.getChooser();
fileWindow.setFileSelectionMode(JFileChooser.FILES_ONLY); fileWindow.setFileSelectionMode(JFileChooser.FILES_ONLY);
GeneralFilter fileFilter = new GeneralFilter(Arrays.asList(".mbtiles"), "MBTiles (*.mbtiles)"); //NON-NLS GeneralFilter fileFilter = new GeneralFilter(Arrays.asList(".mbtiles"), "MBTiles (*.mbtiles)"); //NON-NLS
fileWindow.setDragEnabled(false); fileWindow.setDragEnabled(false);

View File

@ -0,0 +1,147 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.guiutils;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.awt.Cursor;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.coreutils.ThreadConfined;
/**
* Factory class for initializing JFileChooser instances in a background thread.
*
* It is a known issue that on Windows a JFileChooser can take an indeterminate
* amount of time to initialize. Therefore when a JFileChooser is initialized on
* the EDT there is the potential for the UI to appear hung while initialization
* is occurring.
*
* Initializing a JFileChooser in a background thread should prevent the UI from
* hanging. Using this Factory class at component construction time should allow
* enough time for the JFileChooser to be initialized in the background before
* the UI user causes an event which will launch the JFileChooser. If the
* JFileChooser is not initialized prior to the event occurring, the EDT will be
* blocked, but the wait cursor will appear.
*
* https://stackoverflow.com/questions/49792375/jfilechooser-is-very-slow-when-using-windows-look-and-feel
*/
public final class JFileChooserFactory {
private static final Logger logger = Logger.getLogger(JFileChooserFactory.class.getName());
private final FutureTask<JFileChooser> futureFileChooser;
private JFileChooser chooser;
private final ExecutorService executor;
/**
* Create a new instance of the factory. The constructor will kick off an
* executor to execute the initializing the JFileChooser task.
*/
public JFileChooserFactory() {
this(null);
}
/**
* Create a new instance of the factory using a class that extends
* JFileChooser. The class default constructor will be called to initialize
* the class.
*
* The passed in Class must be public and its default constructor must be
* public.
*
* @param cls Class type to initialize.
*/
public JFileChooserFactory(Class<? extends JFileChooser> cls) {
if (cls == null) {
futureFileChooser = new FutureTask<>(JFileChooser::new);
} else {
futureFileChooser = new FutureTask<>(new ChooserCallable(cls));
}
executor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("JFileChooser-background-thread").build());
executor.execute(futureFileChooser);
}
/**
* Return and instance of JFileChooser to the caller.
*
* This call may block the EDT if the JFileChooser initialization has not
* completed.
*
* @return
*/
@ThreadConfined(type = ThreadConfined.ThreadType.AWT)
public JFileChooser getChooser() {
if (chooser == null) {
// In case this takes a moment show the wait cursor.
try {
WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
// get() will only return when the initilization of the
// JFileChooser has completed.
chooser = futureFileChooser.get();
} catch (InterruptedException | ExecutionException ex) {
// An exception is generally not expected. On the off chance
// one does occur save the situation by created a new
// instance in the EDT.
logger.log(Level.WARNING, "Failed to initialize JFileChooser in background thread.");
chooser = new JFileChooser();
}
} finally {
WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
executor.shutdown();
}
}
return chooser;
}
/**
* Simple Callable that will initialize any subclass of JFileChooser using
* the default constructor.
*
* Note that the class and default constructor must be public for this to
* work properly.
*/
private class ChooserCallable implements Callable<JFileChooser> {
private final Class<? extends JFileChooser> type;
/**
* Construct a new instance for the given class type.
*
* @param type Class type to initialize.
*/
ChooserCallable(Class<? extends JFileChooser> type) {
this.type = type;
}
@Override
public JFileChooser call() throws Exception {
return type.newInstance();
}
}
}

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2018 Basis Technology Corp. * Copyright 2018-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -61,6 +61,7 @@ import org.sleuthkit.autopsy.core.UserPreferences;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.coreutils.PlatformUtil;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
/** /**
* Dashboard for viewing metrics and controlling the health monitor. * Dashboard for viewing metrics and controlling the health monitor.
@ -86,6 +87,8 @@ public class HealthMonitorDashboard {
private JDialog dialog = null; private JDialog dialog = null;
private final Container parentWindow; private final Container parentWindow;
private final JFileChooserFactory chooserHelper;
/** /**
* Create an instance of the dashboard. * Create an instance of the dashboard.
* Call display() after creation to show the dashboard. * Call display() after creation to show the dashboard.
@ -95,6 +98,7 @@ public class HealthMonitorDashboard {
timingData = new HashMap<>(); timingData = new HashMap<>();
userData = new ArrayList<>(); userData = new ArrayList<>();
parentWindow = parent; parentWindow = parent;
chooserHelper = new JFileChooserFactory();
} }
/** /**
@ -495,7 +499,7 @@ public class HealthMonitorDashboard {
reportButton.addActionListener(new ActionListener() { reportButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {
JFileChooser reportFileChooser = new JFileChooser(); JFileChooser reportFileChooser = chooserHelper.getChooser();
reportFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); reportFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
reportFileChooser.setCurrentDirectory(new File(UserPreferences.getHealthMonitorReportPath())); reportFileChooser.setCurrentDirectory(new File(UserPreferences.getHealthMonitorReportPath()));
final DateFormat csvTimestampFormat = new SimpleDateFormat("yyyyMMdd_HHmmss"); final DateFormat csvTimestampFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");

View File

@ -115,7 +115,7 @@ IngestJobSettingsPanel.jButtonSelectAll.text=Select All
IngestJobSettingsPanel.jButtonDeselectAll.text=Deselect All IngestJobSettingsPanel.jButtonDeselectAll.text=Deselect All
IngestManager.cancellingIngest.msgDlg.text=Cancelling all currently running ingest jobs IngestManager.cancellingIngest.msgDlg.text=Cancelling all currently running ingest jobs
IngestManager.serviceIsDown.msgDlg.text={0} is down IngestManager.serviceIsDown.msgDlg.text={0} is down
ProfilePanel.messages.profileNameContainsIllegalCharacter=Profile name contains an illegal character ProfilePanel.messages.profileNameContainsIllegalCharacter=Profile name contains an illegal character. Only \nletters, digits, and underscore characters are allowed.
ProfilePanel.messages.profilesMustBeNamed=Ingest profile must be named. ProfilePanel.messages.profilesMustBeNamed=Ingest profile must be named.
ProfilePanel.newProfileText=NewEmptyProfile ProfilePanel.newProfileText=NewEmptyProfile
ProfilePanel.profileDescLabel.text=Description: ProfilePanel.profileDescLabel.text=Description:

View File

@ -135,7 +135,6 @@ ModuleTableModel.colName.module=\u30e2\u30b8\u30e5\u30fc\u30eb
OpenIDE-Module-Name=\u30a4\u30f3\u30b8\u30a7\u30b9\u30c8 OpenIDE-Module-Name=\u30a4\u30f3\u30b8\u30a7\u30b9\u30c8
OptionsCategory_Keywords_IngestOptions=\u30a4\u30f3\u30b8\u30a7\u30b9\u30c8 OptionsCategory_Keywords_IngestOptions=\u30a4\u30f3\u30b8\u30a7\u30b9\u30c8
OptionsCategory_Name_IngestOptions=\u30a4\u30f3\u30b8\u30a7\u30b9\u30c8 OptionsCategory_Name_IngestOptions=\u30a4\u30f3\u30b8\u30a7\u30b9\u30c8
ProfilePanel.messages.profileNameContainsIllegalCharacter=\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u540d\u306b\u4e0d\u6b63\u306a\u6587\u5b57\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059
ProfilePanel.messages.profilesMustBeNamed=\u30a4\u30f3\u30b8\u30a7\u30b9\u30c8\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u306b\u540d\u524d\u3092\u4ed8\u3051\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 ProfilePanel.messages.profilesMustBeNamed=\u30a4\u30f3\u30b8\u30a7\u30b9\u30c8\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u306b\u540d\u524d\u3092\u4ed8\u3051\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002
ProfilePanel.newProfileText=NewEmptyProfile ProfilePanel.newProfileText=NewEmptyProfile
ProfilePanel.profileDescLabel.text=\u8aac\u660e\: ProfilePanel.profileDescLabel.text=\u8aac\u660e\:

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2018 Basis Technology Corp. * Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -19,10 +19,6 @@
package org.sleuthkit.autopsy.ingest; package org.sleuthkit.autopsy.ingest;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.openide.DialogDisplayer; import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor; import org.openide.NotifyDescriptor;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
@ -39,13 +35,12 @@ class ProfilePanel extends IngestModuleGlobalSettingsPanel {
"ProfilePanel.profileNameLabel.text=Profile Name:", "ProfilePanel.profileNameLabel.text=Profile Name:",
"ProfilePanel.newProfileText=NewEmptyProfile", "ProfilePanel.newProfileText=NewEmptyProfile",
"ProfilePanel.messages.profilesMustBeNamed=Ingest profile must be named.", "ProfilePanel.messages.profilesMustBeNamed=Ingest profile must be named.",
"ProfilePanel.messages.profileNameContainsIllegalCharacter=Profile name contains an illegal character"}) "ProfilePanel.messages.profileNameContainsIllegalCharacter=Profile name contains an illegal character. Only \nletters, digits, and underscore characters are allowed."})
private final IngestJobSettingsPanel ingestSettingsPanel; private final IngestJobSettingsPanel ingestSettingsPanel;
private final IngestJobSettings settings; private final IngestJobSettings settings;
private IngestProfile profile; private IngestProfile profile;
private final static String NEW_PROFILE_NAME = NbBundle.getMessage(ProfilePanel.class, "ProfilePanel.newProfileText"); private final static String NEW_PROFILE_NAME = NbBundle.getMessage(ProfilePanel.class, "ProfilePanel.newProfileText");
private static final List<String> ILLEGAL_NAME_CHARS = Collections.unmodifiableList(new ArrayList<>(Arrays.asList("\\", "/", ":", "*", "?", "\"", "<", ">")));
/** /**
* Creates new form ProfilePanel * Creates new form ProfilePanel
@ -231,8 +226,12 @@ class ProfilePanel extends IngestModuleGlobalSettingsPanel {
/** /**
* Save a new or edited profile. * Save a new or edited profile.
*/ */
void store() { boolean store() {
if (!isValidDefinition(false)) {
return false;
}
saveSettings(); saveSettings();
return true;
} }
void load() { void load() {
@ -240,41 +239,33 @@ class ProfilePanel extends IngestModuleGlobalSettingsPanel {
/** /**
* Checks that information entered constitutes a valid ingest profile. * Checks that information entered constitutes a valid ingest profile.
*
* @param dispayWarnings boolean flag whether to display warnings if an error occurred.
* *
* @return true for valid, false for invalid. * @return true for valid, false for invalid.
*/ */
boolean isValidDefinition() { boolean isValidDefinition(boolean dispayWarnings) {
if (getProfileName().isEmpty()) { String profileName = getProfileName();
NotifyDescriptor notifyDesc = new NotifyDescriptor.Message( if (profileName.isEmpty()) {
NbBundle.getMessage(ProfilePanel.class, "ProfilePanel.messages.profilesMustBeNamed"), if (dispayWarnings) {
NotifyDescriptor.WARNING_MESSAGE); NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
DialogDisplayer.getDefault().notify(notifyDesc); NbBundle.getMessage(ProfilePanel.class, "ProfilePanel.messages.profilesMustBeNamed"),
return false; NotifyDescriptor.WARNING_MESSAGE);
} DialogDisplayer.getDefault().notify(notifyDesc);
if (!containsOnlyLegalChars(getProfileName(), ILLEGAL_NAME_CHARS)) {
NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
NbBundle.getMessage(ProfilePanel.class, "ProfilePanel.messages.profileNameContainsIllegalCharacter"),
NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(notifyDesc);
return false;
}
return true;
}
/**
* Checks an input string for the use of illegal characters.
*
* @param toBeChecked The input string.
* @param illegalChars The characters deemed to be illegal.
*
* @return True if the string does not contain illegal characters, false
* otherwise.
*/
private static boolean containsOnlyLegalChars(String toBeChecked, List<String> illegalChars) {
for (String illegalChar : illegalChars) {
if (toBeChecked.contains(illegalChar)) {
return false;
} }
return false;
}
// check if the name contains illegal characters
String sanitizedName = profileName.replaceAll("[^A-Za-z0-9_]", "");
if (!(profileName.equals(sanitizedName))) {
if (dispayWarnings) {
NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
NbBundle.getMessage(ProfilePanel.class, "ProfilePanel.messages.profileNameContainsIllegalCharacter"),
NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(notifyDesc);
}
return false;
} }
return true; return true;
} }

View File

@ -416,7 +416,7 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
do { do {
option = JOptionPane.CANCEL_OPTION; option = JOptionPane.CANCEL_OPTION;
dialog.display(panel); dialog.display(panel);
} while (option == JOptionPane.OK_OPTION && !panel.isValidDefinition()); } while (option == JOptionPane.OK_OPTION && !panel.isValidDefinition(true));
if (option == JOptionPane.OK_OPTION) { if (option == JOptionPane.OK_OPTION) {

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy * Autopsy
* *
* Copyright 2019 Basis Technology Corp. * Copyright 2019-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -50,6 +50,7 @@ import org.apache.commons.lang.StringUtils;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
import org.sleuthkit.autopsy.logicalimager.dsp.DriveListUtils; import org.sleuthkit.autopsy.logicalimager.dsp.DriveListUtils;
/** /**
@ -63,6 +64,7 @@ final class ConfigVisualPanel1 extends JPanel {
private static final String DEFAULT_CONFIG_FILE_NAME = "logical-imager-config.json"; private static final String DEFAULT_CONFIG_FILE_NAME = "logical-imager-config.json";
private static final String UPDATE_UI_EVENT_NAME = "UPDATE_UI"; private static final String UPDATE_UI_EVENT_NAME = "UPDATE_UI";
private String configFilename; private String configFilename;
private final JFileChooserFactory chooserHelper;
/** /**
* Creates new form ConfigVisualPanel1 * Creates new form ConfigVisualPanel1
@ -74,6 +76,7 @@ final class ConfigVisualPanel1 extends JPanel {
refreshDriveList(); refreshDriveList();
updateControls(); updateControls();
}); });
chooserHelper = new JFileChooserFactory();
} }
@NbBundle.Messages({ @NbBundle.Messages({
@ -332,7 +335,7 @@ final class ConfigVisualPanel1 extends JPanel {
"ConfigVisualPanel1.configurationError=Configuration error",}) "ConfigVisualPanel1.configurationError=Configuration error",})
private void chooseFile(String title) { private void chooseFile(String title) {
final String jsonExt = ".json"; // NON-NLS final String jsonExt = ".json"; // NON-NLS
JFileChooser fileChooser = new JFileChooser(); JFileChooser fileChooser = chooserHelper.getChooser();
fileChooser.setDialogTitle(title); fileChooser.setDialogTitle(title);
fileChooser.setDragEnabled(false); fileChooser.setDragEnabled(false);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy * Autopsy
* *
* Copyright 2019 Basis Technology Corp. * Copyright 2019-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -44,6 +44,7 @@ import javax.swing.table.TableColumn;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
/** /**
* Panel for adding an logical image file from drive letters. Allows the user to * Panel for adding an logical image file from drive letters. Allows the user to
@ -64,10 +65,10 @@ final class LogicalImagerPanel extends JPanel implements DocumentListener {
private static final int NUMBER_OF_VISIBLE_COLUMNS = 2; private static final int NUMBER_OF_VISIBLE_COLUMNS = 2;
private static final String[] EMPTY_LIST_DATA = {}; private static final String[] EMPTY_LIST_DATA = {};
private final JFileChooser fileChooser = new JFileChooser();
private final Pattern regex = Pattern.compile("Logical_Imager_(.+)_(\\d{4})(\\d{2})(\\d{2})_(\\d{2})_(\\d{2})_(\\d{2})"); private final Pattern regex = Pattern.compile("Logical_Imager_(.+)_(\\d{4})(\\d{2})(\\d{2})_(\\d{2})_(\\d{2})_(\\d{2})");
private Path manualImageDirPath; private Path manualImageDirPath;
private DefaultTableModel imageTableModel; private DefaultTableModel imageTableModel;
private final JFileChooserFactory chooserHelper;
/** /**
* Creates new form LogicalImagerPanel * Creates new form LogicalImagerPanel
@ -80,6 +81,7 @@ final class LogicalImagerPanel extends JPanel implements DocumentListener {
configureImageTable(); configureImageTable();
jScrollPane1.setBorder(null); jScrollPane1.setBorder(null);
clearImageTable(); clearImageTable();
chooserHelper = new JFileChooserFactory();
} }
/** /**
@ -316,6 +318,7 @@ final class LogicalImagerPanel extends JPanel implements DocumentListener {
"LogicalImagerPanel.messageLabel.directoryFormatInvalid=Directory {0} does not match format Logical_Imager_HOSTNAME_yyyymmdd_HH_MM_SS" "LogicalImagerPanel.messageLabel.directoryFormatInvalid=Directory {0} does not match format Logical_Imager_HOSTNAME_yyyymmdd_HH_MM_SS"
}) })
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
JFileChooser fileChooser = chooserHelper.getChooser();
imageTable.clearSelection(); imageTable.clearSelection();
manualImageDirPath = null; manualImageDirPath = null;
setErrorMessage(NO_IMAGE_SELECTED); setErrorMessage(NO_IMAGE_SELECTED);

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2013-2020 Basis Technology Corp. * Copyright 2013-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -45,6 +45,7 @@ import org.sleuthkit.datamodel.TskData;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository;
import org.sleuthkit.autopsy.featureaccess.FeatureAccessUtils; import org.sleuthkit.autopsy.featureaccess.FeatureAccessUtils;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
/** /**
* Instances of this class allow a user to create a new hash database and add it * Instances of this class allow a user to create a new hash database and add it
@ -56,12 +57,14 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog {
private static final String DEFAULT_FILE_NAME = NbBundle private static final String DEFAULT_FILE_NAME = NbBundle
.getMessage(HashDbCreateDatabaseDialog.class, "HashDbCreateDatabaseDialog.defaultFileName"); .getMessage(HashDbCreateDatabaseDialog.class, "HashDbCreateDatabaseDialog.defaultFileName");
private static final long serialVersionUID = 1L;
private JFileChooser fileChooser = null; private JFileChooser fileChooser = null;
private HashDb newHashDb = null; private HashDb newHashDb = null;
private final static String LAST_FILE_PATH_KEY = "HashDbCreate_Path"; private final static String LAST_FILE_PATH_KEY = "HashDbCreate_Path";
private CentralRepoOrganization selectedOrg = null; private CentralRepoOrganization selectedOrg = null;
private List<CentralRepoOrganization> orgs = null; private List<CentralRepoOrganization> orgs = null;
static final String HASH_DATABASE_DIR_NAME = "HashDatabases"; static final String HASH_DATABASE_DIR_NAME = "HashDatabases";
private final JFileChooserFactory chooserFactory;
/** /**
* Displays a dialog that allows a user to create a new hash database and * Displays a dialog that allows a user to create a new hash database and
@ -70,10 +73,11 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog {
*/ */
HashDbCreateDatabaseDialog() { HashDbCreateDatabaseDialog() {
super((JFrame) WindowManager.getDefault().getMainWindow(), NbBundle.getMessage(HashDbCreateDatabaseDialog.class, "HashDbCreateDatabaseDialog.createHashDbMsg"), true); super((JFrame) WindowManager.getDefault().getMainWindow(), NbBundle.getMessage(HashDbCreateDatabaseDialog.class, "HashDbCreateDatabaseDialog.createHashDbMsg"), true);
initFileChooser();
initComponents(); initComponents();
chooserFactory = new JFileChooserFactory(CustomFileChooser.class);
enableComponents(); enableComponents();
display(); display();
} }
/** /**
@ -84,43 +88,7 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog {
HashDb getHashDatabase() { HashDb getHashDatabase() {
return newHashDb; return newHashDb;
} }
private void initFileChooser() {
fileChooser = new JFileChooser() {
@Override
public void approveSelection() {
File selectedFile = getSelectedFile();
if (!FilenameUtils.getExtension(selectedFile.getName()).equalsIgnoreCase(HashDbManager.getHashDatabaseFileExtension())) {
if (JOptionPane.showConfirmDialog(this,
NbBundle.getMessage(this.getClass(),
"HashDbCreateDatabaseDialog.hashDbMustHaveFileExtensionMsg",
HashDbManager.getHashDatabaseFileExtension()),
NbBundle.getMessage(this.getClass(),
"HashDbCreateDatabaseDialog.fileNameErr"),
JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) {
cancelSelection();
}
return;
}
if (selectedFile.exists()) {
if (JOptionPane.showConfirmDialog(this,
NbBundle.getMessage(this.getClass(),
"HashDbCreateDatabaseDialog.fileNameAlreadyExistsMsg"),
NbBundle.getMessage(this.getClass(),
"HashDbCreateDatabaseDialog.fileExistsErr"),
JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) {
cancelSelection();
}
return;
}
super.approveSelection();
}
};
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setDragEnabled(false);
fileChooser.setMultiSelectionEnabled(false);
}
private void display() { private void display() {
setLocationRelativeTo(getOwner()); setLocationRelativeTo(getOwner());
setVisible(true); setVisible(true);
@ -169,6 +137,43 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog {
Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE, "Failure loading organizations", ex); Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE, "Failure loading organizations", ex);
} }
} }
/**
* Customize the JFileChooser.
*/
public static class CustomFileChooser extends JFileChooser {
private static final long serialVersionUID = 1L;
@Override
public void approveSelection() {
File selectedFile = getSelectedFile();
if (!FilenameUtils.getExtension(selectedFile.getName()).equalsIgnoreCase(HashDbManager.getHashDatabaseFileExtension())) {
if (JOptionPane.showConfirmDialog(this,
NbBundle.getMessage(this.getClass(),
"HashDbCreateDatabaseDialog.hashDbMustHaveFileExtensionMsg",
HashDbManager.getHashDatabaseFileExtension()),
NbBundle.getMessage(this.getClass(),
"HashDbCreateDatabaseDialog.fileNameErr"),
JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) {
cancelSelection();
}
return;
}
if (selectedFile.exists()) {
if (JOptionPane.showConfirmDialog(this,
NbBundle.getMessage(this.getClass(),
"HashDbCreateDatabaseDialog.fileNameAlreadyExistsMsg"),
NbBundle.getMessage(this.getClass(),
"HashDbCreateDatabaseDialog.fileExistsErr"),
JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) {
cancelSelection();
}
return;
}
super.approveSelection();
}
}
/** /**
* This method is called from within the constructor to initialize the form. * This method is called from within the constructor to initialize the form.
@ -435,6 +440,16 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog {
path.append(File.separator).append(DEFAULT_FILE_NAME); path.append(File.separator).append(DEFAULT_FILE_NAME);
} }
path.append(".").append(HashDbManager.getHashDatabaseFileExtension()); path.append(".").append(HashDbManager.getHashDatabaseFileExtension());
if(fileChooser == null) {
fileChooser = chooserFactory.getChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setDragEnabled(false);
fileChooser.setMultiSelectionEnabled(false);
}
fileChooser.setSelectedFile(new File(path.toString())); fileChooser.setSelectedFile(new File(path.toString()));
if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
File databaseFile = fileChooser.getSelectedFile(); File databaseFile = fileChooser.getSelectedFile();

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2013-2020 Basis Technology Corp. * Copyright 2013-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -43,6 +43,7 @@ import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDbManagerExc
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb; import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb;
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository;
import org.sleuthkit.autopsy.featureaccess.FeatureAccessUtils; import org.sleuthkit.autopsy.featureaccess.FeatureAccessUtils;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
/** /**
* Instances of this class allow a user to select an existing hash database and * Instances of this class allow a user to select an existing hash database and
@ -52,12 +53,13 @@ import org.sleuthkit.autopsy.featureaccess.FeatureAccessUtils;
@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
final class HashDbImportDatabaseDialog extends javax.swing.JDialog { final class HashDbImportDatabaseDialog extends javax.swing.JDialog {
private final JFileChooser fileChooser; private JFileChooser fileChooser;
private String selectedFilePath = ""; private String selectedFilePath = "";
private HashDb selectedHashDb = null; private HashDb selectedHashDb = null;
private final static String LAST_FILE_PATH_KEY = "HashDbImport_Path"; private final static String LAST_FILE_PATH_KEY = "HashDbImport_Path";
private CentralRepoOrganization selectedOrg = null; private CentralRepoOrganization selectedOrg = null;
private List<CentralRepoOrganization> orgs = null; private List<CentralRepoOrganization> orgs = null;
private final JFileChooserFactory chooserHelper;
/** /**
* Displays a dialog that allows a user to select an existing hash database * Displays a dialog that allows a user to select an existing hash database
@ -68,10 +70,9 @@ final class HashDbImportDatabaseDialog extends javax.swing.JDialog {
super((JFrame) WindowManager.getDefault().getMainWindow(), super((JFrame) WindowManager.getDefault().getMainWindow(),
NbBundle.getMessage(HashDbImportDatabaseDialog.class, "HashDbImportDatabaseDialog.importHashDbMsg"), NbBundle.getMessage(HashDbImportDatabaseDialog.class, "HashDbImportDatabaseDialog.importHashDbMsg"),
true); true);
this.fileChooser = new JFileChooser(); chooserHelper = new JFileChooserFactory();
initComponents(); initComponents();
enableComponents(); enableComponents();
initFileChooser();
display(); display();
} }
@ -84,16 +85,6 @@ final class HashDbImportDatabaseDialog extends javax.swing.JDialog {
return selectedHashDb; return selectedHashDb;
} }
private void initFileChooser() {
fileChooser.setDragEnabled(false);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
String[] EXTENSION = new String[]{"txt", "kdb", "idx", "hash", "Hash", "hsh"}; //NON-NLS
FileNameExtensionFilter filter = new FileNameExtensionFilter(
NbBundle.getMessage(this.getClass(), "HashDbImportDatabaseDialog.fileNameExtFilter.text"), EXTENSION);
fileChooser.setFileFilter(filter);
fileChooser.setMultiSelectionEnabled(false);
}
private void display() { private void display() {
setLocationRelativeTo(WindowManager.getDefault().getMainWindow()); setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
setVisible(true); setVisible(true);
@ -421,6 +412,17 @@ final class HashDbImportDatabaseDialog extends javax.swing.JDialog {
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void openButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openButtonActionPerformed private void openButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openButtonActionPerformed
if(fileChooser == null) {
fileChooser = chooserHelper.getChooser();
fileChooser.setDragEnabled(false);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
String[] EXTENSION = new String[]{"txt", "kdb", "idx", "hash", "Hash", "hsh"}; //NON-NLS
FileNameExtensionFilter filter = new FileNameExtensionFilter(
NbBundle.getMessage(this.getClass(), "HashDbImportDatabaseDialog.fileNameExtFilter.text"), EXTENSION);
fileChooser.setFileFilter(filter);
fileChooser.setMultiSelectionEnabled(false);
}
String lastBaseDirectory = Paths.get(PlatformUtil.getUserConfigDirectory(), HashDbCreateDatabaseDialog.HASH_DATABASE_DIR_NAME).toString(); String lastBaseDirectory = Paths.get(PlatformUtil.getUserConfigDirectory(), HashDbCreateDatabaseDialog.HASH_DATABASE_DIR_NAME).toString();
if (ModuleSettings.settingExists(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY)) { if (ModuleSettings.settingExists(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY)) {
lastBaseDirectory = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY); lastBaseDirectory = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY);

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2018 Basis Technology Corp. * Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -65,6 +65,7 @@ import org.sleuthkit.datamodel.SleuthkitJNI;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.datamodel.TskData; import org.sleuthkit.datamodel.TskData;
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb.KnownFilesType; import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb.KnownFilesType;
/** /**
@ -93,6 +94,8 @@ public class HashDbManager implements PropertyChangeListener {
private static final String DB_NAME_PARAM = "dbName"; private static final String DB_NAME_PARAM = "dbName";
private static final String KNOWN_STATUS_PARAM = "knownStatus"; private static final String KNOWN_STATUS_PARAM = "knownStatus";
private static final Pattern OFFICIAL_FILENAME = Pattern.compile("(?<" + DB_NAME_PARAM + ">.+?)\\.(?<" + KNOWN_STATUS_PARAM + ">.+?)\\." + KDB_EXT); private static final Pattern OFFICIAL_FILENAME = Pattern.compile("(?<" + DB_NAME_PARAM + ">.+?)\\.(?<" + KNOWN_STATUS_PARAM + ">.+?)\\." + KDB_EXT);
private final JFileChooserFactory chooserHelper;
private static final FilenameFilter DEFAULT_KDB_FILTER = new FilenameFilter() { private static final FilenameFilter DEFAULT_KDB_FILTER = new FilenameFilter() {
@Override @Override
@ -136,6 +139,7 @@ public class HashDbManager implements PropertyChangeListener {
} }
private HashDbManager() { private HashDbManager() {
chooserHelper = new JFileChooserFactory();
loadHashsetsConfiguration(); loadHashsetsConfiguration();
} }
@ -870,7 +874,7 @@ public class HashDbManager implements PropertyChangeListener {
private String searchForFile() { private String searchForFile() {
String filePath = null; String filePath = null;
JFileChooser fc = new JFileChooser(); JFileChooser fc = chooserHelper.getChooser();
fc.setDragEnabled(false); fc.setDragEnabled(false);
fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
String[] EXTENSION = new String[]{"txt", "idx", "hash", "Hash", "kdb"}; //NON-NLS String[] EXTENSION = new String[]{"txt", "idx", "hash", "Hash", "kdb"}; //NON-NLS

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2013-2018 Basis Technology Corp. * Copyright 2013-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.report.modules.stix;
import java.io.File; import java.io.File;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import org.sleuthkit.autopsy.guiutils.JFileChooserFactory;
/** /**
* Configuration panel for STIX report generation. * Configuration panel for STIX report generation.
@ -29,6 +30,7 @@ public class STIXReportModuleConfigPanel extends javax.swing.JPanel {
String stixFile = null; String stixFile = null;
boolean showAllResults; boolean showAllResults;
private final JFileChooserFactory chooserHelper;
/** /**
* Creates new form STIXReportModuleConfigPanel * Creates new form STIXReportModuleConfigPanel
@ -37,6 +39,7 @@ public class STIXReportModuleConfigPanel extends javax.swing.JPanel {
initComponents(); initComponents();
showAllResults = false; showAllResults = false;
jCheckBox1.setSelected(false); jCheckBox1.setSelected(false);
chooserHelper = new JFileChooserFactory();
} }
void setConfiguration(STIXReportModuleSettings settings) { void setConfiguration(STIXReportModuleSettings settings) {
@ -138,7 +141,7 @@ public class STIXReportModuleConfigPanel extends javax.swing.JPanel {
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
JFileChooser fileChooser = new JFileChooser(); JFileChooser fileChooser = chooserHelper.getChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
File currentSelection = new File(jStixFileTextField.getText()); File currentSelection = new File(jStixFileTextField.getText());

View File

@ -262,6 +262,7 @@ final class AutoIngestDashboard extends JPanel implements Observer {
* Shut down parts of the AutoIngestDashboard which were initialized * Shut down parts of the AutoIngestDashboard which were initialized
*/ */
void shutDown() { void shutDown() {
scheduledRefreshThreadPoolExecutor.shutdownNow();
if (autoIngestMonitor != null) { if (autoIngestMonitor != null) {
autoIngestMonitor.shutDown(); autoIngestMonitor.shutDown();
} }

View File

@ -70,7 +70,7 @@ final class AutoIngestJobsNode extends AbstractNode {
* refresh events * refresh events
*/ */
AutoIngestJobsNode(AutoIngestMonitor monitor, AutoIngestJobStatus status, EventBus eventBus) { AutoIngestJobsNode(AutoIngestMonitor monitor, AutoIngestJobStatus status, EventBus eventBus) {
super(Children.create(new AutoIngestNodeChildren(monitor, status, eventBus), true)); super(Children.create(new AutoIngestNodeChildren(monitor, status, eventBus), false));
refreshChildrenEventBus = eventBus; refreshChildrenEventBus = eventBus;
} }

View File

@ -30,32 +30,35 @@ import javax.annotation.concurrent.Immutable;
public final class Manifest implements Serializable { public final class Manifest implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final String filePath; private final Path filePath;
private final Date dateFileCreated; private final Date dateFileCreated;
private final String caseName; private final String caseName;
private final String deviceId; private final String deviceId;
private final String dataSourcePath; private final Path dataSourcePath;
private final String dataSourceFileName;
private final Map<String, String> manifestProperties; private final Map<String, String> manifestProperties;
public Manifest(Path manifestFilePath, Date dateFileCreated, String caseName, String deviceId, Path dataSourcePath, Map<String, String> manifestProperties) { public Manifest(Path manifestFilePath, Date dateFileCreated, String caseName, String deviceId, Path dataSourcePath, Map<String, String> manifestProperties) {
this.filePath = manifestFilePath.toString(); this.filePath = Paths.get(manifestFilePath.toString());
this.dateFileCreated = dateFileCreated; this.dateFileCreated = new Date(dateFileCreated.getTime());
this.caseName = caseName; this.caseName = caseName;
this.deviceId = deviceId; this.deviceId = deviceId;
if (null != dataSourcePath) { if (null != dataSourcePath) {
this.dataSourcePath = dataSourcePath.toString(); this.dataSourcePath = Paths.get(dataSourcePath.toString());
dataSourceFileName = dataSourcePath.getFileName().toString();
} else { } else {
this.dataSourcePath = ""; this.dataSourcePath = Paths.get("");
dataSourceFileName = "";
} }
this.manifestProperties = new HashMap<>(manifestProperties); this.manifestProperties = new HashMap<>(manifestProperties);
} }
public Path getFilePath() { public Path getFilePath() {
return Paths.get(this.filePath); return this.filePath;
} }
public Date getDateFileCreated() { public Date getDateFileCreated() {
return new Date(this.dateFileCreated.getTime()); return dateFileCreated;
} }
public String getCaseName() { public String getCaseName() {
@ -67,11 +70,11 @@ public final class Manifest implements Serializable {
} }
public Path getDataSourcePath() { public Path getDataSourcePath() {
return Paths.get(dataSourcePath); return dataSourcePath;
} }
public String getDataSourceFileName() { public String getDataSourceFileName() {
return Paths.get(dataSourcePath).getFileName().toString(); return dataSourceFileName;
} }
public Map<String, String> getManifestProperties() { public Map<String, String> getManifestProperties() {

View File

@ -38,7 +38,7 @@ PROJECT_NAME = "Documentation utilisateur Autopsy"
# could be handy for archiving the generated documentation or if some version # could be handy for archiving the generated documentation or if some version
# control system is used. # control system is used.
PROJECT_NUMBER = 4.19.0 PROJECT_NUMBER = 4.19.1
# Using the PROJECT_BRIEF tag one can provide an optional one line description # Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a # for a project that appears at the top of each page and should give viewer a
@ -1025,7 +1025,7 @@ GENERATE_HTML = YES
# The default directory is: html. # The default directory is: html.
# This tag requires that the tag GENERATE_HTML is set to YES. # This tag requires that the tag GENERATE_HTML is set to YES.
HTML_OUTPUT = 4.19.0 HTML_OUTPUT = 4.19.1
# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each # The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
# generated HTML page (for example: .htm, .php, .asp). # generated HTML page (for example: .htm, .php, .asp).

View File

@ -0,0 +1,2 @@
# Sun Aug 29 15:02:07 2021 +0200
user-docs_fr.lastupdated=4f62b90f652ba12dae1b2286fb3eb065f00e5311

View File

@ -8,6 +8,9 @@ Ceci est le guide de l'utilisateur de la <a href="http://www.sleuthkit.org/autop
Remarque: pour les utilisateurs exécutant Autopsy sur des appareils Mac, les fonctionnalités disponibles via la boîte de dialogue "Tools"->"Options" et décritent dans cette documentation sont accessibles via la barre de menu système sous "Préférences" ou via le raccourci Cmd +, (touche "Cmd" + touche "plus"). Remarque: pour les utilisateurs exécutant Autopsy sur des appareils Mac, les fonctionnalités disponibles via la boîte de dialogue "Tools"->"Options" et décritent dans cette documentation sont accessibles via la barre de menu système sous "Préférences" ou via le raccourci Cmd +, (touche "Cmd" + touche "plus").
Version originale de ce guide:
- <a href="https://sleuthkit.org/autopsy/docs/user-docs/latest">Dernière version à jour</a>
Rubriques d'aide Rubriques d'aide
------- -------
Les rubriques suivantes sont disponibles: Les rubriques suivantes sont disponibles:

View File

@ -16,18 +16,22 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import sys
import subprocess
import os
# import db_diff
sys.path.insert(0, os.path.join(subprocess.getoutput("cygpath -u $TSK_HOME"), "db_diff"))
from tskdbdiff import TskDbDiff, TskDbDiffException, PGSettings from tskdbdiff import TskDbDiff, TskDbDiffException, PGSettings
import codecs import codecs
import datetime import datetime
import logging import logging
import os
import re import re
import shutil import shutil
import socket import socket
import sqlite3 import sqlite3
import subprocess
import sys
from sys import platform as _platform from sys import platform as _platform
import time import time
import traceback import traceback

File diff suppressed because it is too large Load Diff