From b2d8c2fc504dadfdaf42a9aaed1fa377ea0b7495 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Fri, 15 May 2015 14:56:13 -0400 Subject: [PATCH 01/18] Added WizardPathValidator interface and service provider lookup --- .../AddImageWizardChooseDataSourceVisual.java | 11 ++++ .../WizardPathValidator.java | 52 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/WizardPathValidator.java diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java index b4c15cc0e2..624c38383f 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java @@ -38,6 +38,7 @@ import javax.swing.event.DocumentEvent; import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; +import org.sleuthkit.autopsy.corecomponentinterfaces.WizardPathValidator; import org.sleuthkit.autopsy.coreutils.Logger; /** @@ -55,6 +56,8 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { private Map datasourceProcessorsMap = new HashMap<>(); + List pathValidatorList = new ArrayList<>(); + List coreDSPTypes = new ArrayList<>(); /** @@ -75,6 +78,8 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { typePanel.setLayout(new BorderLayout()); discoverDataSourceProcessors(); + + discoverWizardPathValidators(); // set up the DSP type combobox typeComboBox.removeAllItems(); @@ -128,6 +133,12 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { } } } + + private void discoverWizardPathValidators() { + for (WizardPathValidator pathValidator : Lookup.getDefault().lookupAll(WizardPathValidator.class)) { + pathValidatorList.add(pathValidator); + } + } private void dspSelectionChanged() { // update the current panel to selection diff --git a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/WizardPathValidator.java b/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/WizardPathValidator.java new file mode 100644 index 0000000000..9cebb1411d --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/WizardPathValidator.java @@ -0,0 +1,52 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2011-2014 Basis Technology Corp. + * Contact: carrier sleuthkit 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.corecomponentinterfaces; + +/* + * Defines an interface used by the Add DataSource wizard to validate path for selected + * case and/or data source. + * + * Different Autopsy implementations and modes may have its unique attributes and + * may need to be processed differently. + * + * The WizardPathValidator interface defines a uniform mechanism for the Autopsy UI + * to: + * - Validate path for selected case. + * - Validate path for selected data source. + */ +public interface WizardPathValidator { + + /** + * Validates case path. + * + * @param path Absolute path to case file. + * @return String Error message if path is invalid, empty string otherwise. + * + */ + String validateCasePath(String path); + + /** + * Validates data source path. + * + * @param path Absolute path to data source file. + * @return String Error message if path is invalid, empty string otherwise. + * + */ + String validateDataSourcePath(String path); +} From d3a389498ba145bfe803c538833aeea360811ae5 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Fri, 15 May 2015 16:27:58 -0400 Subject: [PATCH 02/18] Modified add data source wizard to use WizardPathValidator service providers --- .../AddImageWizardChooseDataSourceVisual.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java index 624c38383f..f1b08d9276 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java @@ -311,7 +311,22 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { */ public void updateUI(DocumentEvent e) { // Enable the Next button if the current DSP panel is valid - this.wizPanel.enableNextButton(getCurrentDSProcessor().isPanelValid()); + if (!getCurrentDSProcessor().isPanelValid()) { + return; + } + + // check if the is a WizardPathValidator service provider + if (!pathValidatorList.isEmpty()){ + // call WizardPathValidator service provider + String errorMsg = pathValidatorList.get(0).validateDataSourcePath(""); + if (errorMsg.isEmpty()) { + this.wizPanel.enableNextButton(true); + } else { + // ELTODO - display error message + } + } else { + // validate locally + } } @SuppressWarnings("rawtypes") From c0b55cda80dbc53737913c947806704410c78cdd Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Mon, 18 May 2015 10:35:07 -0400 Subject: [PATCH 03/18] Minor changes --- .../autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java index f1b08d9276..099d777ca9 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java @@ -326,6 +326,7 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { } } else { // validate locally + this.wizPanel.enableNextButton(true); } } From 60b7ef57ee3e1070c95cf40599878c35fe244301 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Wed, 20 May 2015 13:54:12 -0400 Subject: [PATCH 04/18] Added verification for path being on C drive, modified ImageFilePanel --- .../AddImageWizardChooseDataSourceVisual.java | 31 +------ .../autopsy/casemodule/Bundle.properties | 1 + .../autopsy/casemodule/Bundle_ja.properties | 1 + .../autopsy/casemodule/ImageFilePanel.form | 17 +++- .../autopsy/casemodule/ImageFilePanel.java | 87 +++++++++++++++++-- 5 files changed, 101 insertions(+), 36 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java index 099d777ca9..328d307935 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java @@ -38,7 +38,6 @@ import javax.swing.event.DocumentEvent; import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; -import org.sleuthkit.autopsy.corecomponentinterfaces.WizardPathValidator; import org.sleuthkit.autopsy.coreutils.Logger; /** @@ -55,8 +54,6 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { private JPanel currentPanel; private Map datasourceProcessorsMap = new HashMap<>(); - - List pathValidatorList = new ArrayList<>(); List coreDSPTypes = new ArrayList<>(); @@ -78,8 +75,6 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { typePanel.setLayout(new BorderLayout()); discoverDataSourceProcessors(); - - discoverWizardPathValidators(); // set up the DSP type combobox typeComboBox.removeAllItems(); @@ -132,13 +127,7 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { logger.log(Level.SEVERE, "discoverDataSourceProcessors(): A DataSourceProcessor already exists for type = {0}", dsProcessor.getDataSourceType()); //NON-NLS } } - } - - private void discoverWizardPathValidators() { - for (WizardPathValidator pathValidator : Lookup.getDefault().lookupAll(WizardPathValidator.class)) { - pathValidatorList.add(pathValidator); - } - } + } private void dspSelectionChanged() { // update the current panel to selection @@ -311,23 +300,7 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { */ public void updateUI(DocumentEvent e) { // Enable the Next button if the current DSP panel is valid - if (!getCurrentDSProcessor().isPanelValid()) { - return; - } - - // check if the is a WizardPathValidator service provider - if (!pathValidatorList.isEmpty()){ - // call WizardPathValidator service provider - String errorMsg = pathValidatorList.get(0).validateDataSourcePath(""); - if (errorMsg.isEmpty()) { - this.wizPanel.enableNextButton(true); - } else { - // ELTODO - display error message - } - } else { - // validate locally - this.wizPanel.enableNextButton(true); - } + this.wizPanel.enableNextButton(getCurrentDSProcessor().isPanelValid()); } @SuppressWarnings("rawtypes") diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties index cdbed0aa1f..ed71b9c592 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties @@ -230,3 +230,4 @@ AddImageWizardIngestConfigPanel.CANCEL_BUTTON.text=Cancel NewCaseVisualPanel1.rbSingleUserCase.text=Single-user NewCaseVisualPanel1.rbMultiUserCase.text=Multi-user NewCaseVisualPanel1.lbBadMultiUserSettings.text= +ImageFilePanel.errorLabel.text=Error Label diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle_ja.properties b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle_ja.properties index 0d2bd7e942..75be232976 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle_ja.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle_ja.properties @@ -215,3 +215,4 @@ XMLCaseManagement.open.msgDlg.notAutCase.title=\u30a8\u30e9\u30fc ImageFilePanel.noFatOrphansCheckbox.text=FAT\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u30aa\u30fc\u30d5\u30a1\u30f3\u30d5\u30a1\u30a4\u30eb\u306f\u7121\u8996 LocalDiskPanel.noFatOrphansCheckbox.text=FAT\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u30aa\u30fc\u30d5\u30a1\u30f3\u30d5\u30a1\u30a4\u30eb\u306f\u7121\u8996 AddImageWizardIngestConfigPanel.CANCEL_BUTTON.text=\u30ad\u30e3\u30f3\u30bb\u30eb +ImageFilePanel.errorLabel.text=\u30a8\u30e9\u30fc\u30e9\u30d9\u30eb diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.form b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.form index b4dbaafd63..bfccc9bdd9 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.form +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.form @@ -43,6 +43,7 @@ + @@ -57,7 +58,9 @@ - + + + @@ -66,7 +69,7 @@ - + @@ -131,5 +134,15 @@ + + + + + + + + + + diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java index 045fe691a4..c389a30fd6 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java @@ -21,6 +21,7 @@ package org.sleuthkit.autopsy.casemodule; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.File; +import java.util.ArrayList; import java.util.Calendar; import java.util.List; import java.util.SimpleTimeZone; @@ -36,6 +37,11 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import java.util.logging.Level; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.openide.util.Lookup; +import org.sleuthkit.autopsy.casemodule.Case.CaseType; +import org.sleuthkit.autopsy.corecomponentinterfaces.WizardPathValidator; import org.sleuthkit.autopsy.coreutils.Logger; /** @@ -47,6 +53,9 @@ public class ImageFilePanel extends JPanel implements DocumentListener { private static final Logger logger = Logger.getLogger(ImageFilePanel.class.getName()); private PropertyChangeSupport pcs = null; private JFileChooser fc = new JFileChooser(); + + List pathValidatorList = new ArrayList<>(); + private static final Pattern driveLetterPattern = Pattern.compile("^([Cc]):.*$"); // Externally supplied name is used to store settings private String contextName; @@ -62,6 +71,9 @@ public class ImageFilePanel extends JPanel implements DocumentListener { fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setMultiSelectionEnabled(false); + errorLabel.setVisible(false); + discoverWizardPathValidators(); + boolean firstFilter = true; for (FileFilter filter: fileChooserFilters ) { if (firstFilter) { // set the first on the list as the default selection @@ -76,7 +88,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener { this.contextName = context; pcs = new PropertyChangeSupport(this); - createTimeZoneList(); + createTimeZoneList(); } /** @@ -97,7 +109,11 @@ public class ImageFilePanel extends JPanel implements DocumentListener { pathTextField.getDocument().addDocumentListener(this); } - + private void discoverWizardPathValidators() { + for (WizardPathValidator pathValidator : Lookup.getDefault().lookupAll(WizardPathValidator.class)) { + pathValidatorList.add(pathValidator); + } + } /** * This method is called from within the constructor to initialize the form. @@ -115,6 +131,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener { timeZoneComboBox = new javax.swing.JComboBox(); noFatOrphansCheckbox = new javax.swing.JCheckBox(); descLabel = new javax.swing.JLabel(); + errorLabel = new javax.swing.JLabel(); setMinimumSize(new java.awt.Dimension(0, 65)); setPreferredSize(new java.awt.Dimension(403, 65)); @@ -139,6 +156,9 @@ public class ImageFilePanel extends JPanel implements DocumentListener { org.openide.awt.Mnemonics.setLocalizedText(descLabel, org.openide.util.NbBundle.getMessage(ImageFilePanel.class, "ImageFilePanel.descLabel.text")); // NOI18N + errorLabel.setForeground(new java.awt.Color(255, 0, 0)); + org.openide.awt.Mnemonics.setLocalizedText(errorLabel, org.openide.util.NbBundle.getMessage(ImageFilePanel.class, "ImageFilePanel.errorLabel.text")); // NOI18N + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -158,7 +178,8 @@ public class ImageFilePanel extends JPanel implements DocumentListener { .addComponent(noFatOrphansCheckbox) .addGroup(layout.createSequentialGroup() .addGap(21, 21, 21) - .addComponent(descLabel))) + .addComponent(descLabel)) + .addComponent(errorLabel)) .addGap(0, 20, Short.MAX_VALUE)) ); layout.setVerticalGroup( @@ -169,7 +190,9 @@ public class ImageFilePanel extends JPanel implements DocumentListener { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(browseButton) .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(18, 18, 18) + .addGap(3, 3, 3) + .addComponent(errorLabel) + .addGap(1, 1, 1) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(timeZoneLabel) .addComponent(timeZoneComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) @@ -177,7 +200,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener { .addComponent(noFatOrphansCheckbox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(descLabel) - .addContainerGap(13, Short.MAX_VALUE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }// //GEN-END:initComponents @@ -211,6 +234,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener { // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton browseButton; private javax.swing.JLabel descLabel; + private javax.swing.JLabel errorLabel; private javax.swing.JCheckBox noFatOrphansCheckbox; private javax.swing.JLabel pathLabel; private javax.swing.JTextField pathTextField; @@ -263,9 +287,62 @@ public class ImageFilePanel extends JPanel implements DocumentListener { boolean isExist = Case.pathExists(path); boolean isPhysicalDrive = Case.isPhysicalDrive(path); boolean isPartition = Case.isPartition(path); + + if (!isImagePathValid(path)) { + return false; + } return (isExist || isPhysicalDrive || isPartition); } + + + private boolean isImagePathValid(String path){ + + errorLabel.setVisible(false); + String errorString = ""; + boolean valid = false; + + // check if the is a WizardPathValidator service provider + if (!pathValidatorList.isEmpty()) { + // call WizardPathValidator service provider + errorString = pathValidatorList.get(0).validateDataSourcePath(path); + if (errorString.isEmpty()) { + valid = true; + } + } else { + // validate locally + if (Case.getCurrentCase().getCaseType() == CaseType.MULTI_USER_CASE) { + // check that path is not on "C:" drive + if (pathOnCDrive(path)) { + errorString = "Path to data source is on \"C:\" drive"; + } else { + valid = true; + } + } else { + // single user case - no validation + valid = true; + } + } + + // set error string + if (!errorString.isEmpty()){ + errorLabel.setVisible(true); + errorLabel.setText(errorString); + } + + return valid; + } + + /** + * Checks whether a file path contains drive letter defined by pattern. + * + * @param filePath Input file absolute path + * @return true if path matches the pattern, false otherwise. + */ + private boolean pathOnCDrive(String filePath) { + Matcher m = driveLetterPattern.matcher(filePath); + return m.find(); + } public void storeSettings() { From 68fc925a1af44e564544c6129b2aaa6cf692a152 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Wed, 20 May 2015 14:11:00 -0400 Subject: [PATCH 05/18] Using NbBundle for error messages --- .../autopsy/casemodule/Bundle.properties | 1 + .../autopsy/casemodule/ImageFilePanel.java | 16 +++++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties index ed71b9c592..7fc183f612 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties @@ -231,3 +231,4 @@ NewCaseVisualPanel1.rbSingleUserCase.text=Single-user NewCaseVisualPanel1.rbMultiUserCase.text=Multi-user NewCaseVisualPanel1.lbBadMultiUserSettings.text= ImageFilePanel.errorLabel.text=Error Label +ImageFilePanel.DataSourceOnCDriveError.text=Path to data source is on \"C:\" drive \ No newline at end of file diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java index c389a30fd6..c0b81e54e5 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java @@ -300,27 +300,20 @@ public class ImageFilePanel extends JPanel implements DocumentListener { errorLabel.setVisible(false); String errorString = ""; - boolean valid = false; // check if the is a WizardPathValidator service provider if (!pathValidatorList.isEmpty()) { // call WizardPathValidator service provider errorString = pathValidatorList.get(0).validateDataSourcePath(path); - if (errorString.isEmpty()) { - valid = true; - } } else { // validate locally if (Case.getCurrentCase().getCaseType() == CaseType.MULTI_USER_CASE) { // check that path is not on "C:" drive if (pathOnCDrive(path)) { - errorString = "Path to data source is on \"C:\" drive"; - } else { - valid = true; - } + errorString = NbBundle.getMessage(this.getClass(), "ImageFilePanel.DataSourceOnCDriveError.text"); //NON-NLS + } } else { - // single user case - no validation - valid = true; + // single user case - no validation needed } } @@ -328,9 +321,10 @@ public class ImageFilePanel extends JPanel implements DocumentListener { if (!errorString.isEmpty()){ errorLabel.setVisible(true); errorLabel.setText(errorString); + return false; } - return valid; + return true; } /** From 2f7297101e0afe16820b41b3b8bf7c609f6b743b Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Wed, 20 May 2015 16:01:21 -0400 Subject: [PATCH 06/18] Modified local files panel --- .../autopsy/casemodule/Bundle.properties | 2 +- .../autopsy/casemodule/ImageFilePanel.java | 11 +++- .../autopsy/casemodule/LocalDiskPanel.form | 2 +- .../autopsy/casemodule/LocalDiskPanel.java | 64 +++++++++++++++++++ 4 files changed, 74 insertions(+), 5 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties index 7fc183f612..217c9e2e09 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties @@ -231,4 +231,4 @@ NewCaseVisualPanel1.rbSingleUserCase.text=Single-user NewCaseVisualPanel1.rbMultiUserCase.text=Multi-user NewCaseVisualPanel1.lbBadMultiUserSettings.text= ImageFilePanel.errorLabel.text=Error Label -ImageFilePanel.DataSourceOnCDriveError.text=Path to data source is on \"C:\" drive \ No newline at end of file +DataSourceOnCDriveError.text=Path to data source is on \"C:\" drive \ No newline at end of file diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java index c0b81e54e5..29ac4694fd 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java @@ -55,7 +55,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener { private JFileChooser fc = new JFileChooser(); List pathValidatorList = new ArrayList<>(); - private static final Pattern driveLetterPattern = Pattern.compile("^([Cc]):.*$"); + private final Pattern driveLetterPattern = Pattern.compile("^[Cc]:.*$"); // Externally supplied name is used to store settings private String contextName; @@ -295,7 +295,12 @@ public class ImageFilePanel extends JPanel implements DocumentListener { return (isExist || isPhysicalDrive || isPartition); } - + /** + * Validates path to selected data source. Calls WizardPathValidator service provider + * if one is available. Otherwise performs path validation locally. + * @param path Absolute path to the selected data source + * @return true if path is valid, false otherwise. + */ private boolean isImagePathValid(String path){ errorLabel.setVisible(false); @@ -310,7 +315,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener { if (Case.getCurrentCase().getCaseType() == CaseType.MULTI_USER_CASE) { // check that path is not on "C:" drive if (pathOnCDrive(path)) { - errorString = NbBundle.getMessage(this.getClass(), "ImageFilePanel.DataSourceOnCDriveError.text"); //NON-NLS + errorString = NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text"); //NON-NLS } } else { // single user case - no validation needed diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.form b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.form index d71086457c..55707d9f0c 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.form +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.form @@ -61,7 +61,7 @@ - + diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java index 38d067c153..d0b773c4e1 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java @@ -31,6 +31,8 @@ import java.util.SimpleTimeZone; import java.util.TimeZone; import java.util.concurrent.CancellationException; import java.util.logging.Level; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.swing.ComboBoxModel; import javax.swing.JLabel; import javax.swing.JList; @@ -42,6 +44,7 @@ import javax.swing.border.EmptyBorder; import javax.swing.event.ListDataListener; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; +import org.sleuthkit.autopsy.corecomponentinterfaces.WizardPathValidator; import org.sleuthkit.autopsy.coreutils.LocalDisk; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; @@ -64,6 +67,9 @@ final class LocalDiskPanel extends JPanel { private LocalDiskModel model; private boolean enableNext = false; + + List pathValidatorList = new ArrayList<>(); + private final Pattern driveLetterPattern = Pattern.compile("^[Cc]:.*$"); /** * Creates new form LocalDiskPanel @@ -225,8 +231,66 @@ final class LocalDiskPanel extends JPanel { */ //@Override public boolean validatePanel() { + + if (!isImagePathValid(getContentPaths())) { + return false; + } + return enableNext; } + + /** + * Validates path to selected data source. Calls WizardPathValidator service provider + * if one is available. Otherwise performs path validation locally. + * @param path Absolute path to the selected data source + * @return true if path is valid, false otherwise. + */ + private boolean isImagePathValid(String path){ + + errorLabel.setVisible(false); + String errorString = ""; + String newPath = path; + if (path.length() > 4) { + // "Local Disk" panel pre-pends "\\.\" in front of all drive letter and drive names + newPath = path.substring(4, path.length()); + } + + // check if the is a WizardPathValidator service provider + if (!pathValidatorList.isEmpty()) { + // call WizardPathValidator service provider + errorString = pathValidatorList.get(0).validateDataSourcePath(newPath); + } else { + // validate locally + if (Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) { + // check that path is not on "C:" drive + if (pathOnCDrive(newPath)) { + errorString = NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text"); //NON-NLS + } + } else { + // single user case - no validation needed + } + } + + // set error string + if (!errorString.isEmpty()){ + errorLabel.setVisible(true); + errorLabel.setText(errorString); + return false; + } + + return true; + } + + /** + * Checks whether a file path contains drive letter defined by pattern. + * + * @param filePath Input file absolute path + * @return true if path matches the pattern, false otherwise. + */ + private boolean pathOnCDrive(String filePath) { + Matcher m = driveLetterPattern.matcher(filePath); + return m.find(); + } //@Override public void reset() { From 9f603eb11665f05704d157691e6539e88397c373 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Wed, 20 May 2015 16:26:44 -0400 Subject: [PATCH 07/18] Integrated local files panel --- .../autopsy/casemodule/Bundle.properties | 3 +- .../autopsy/casemodule/Bundle_ja.properties | 1 + .../autopsy/casemodule/LocalDiskPanel.java | 5 +- .../autopsy/casemodule/LocalFilesPanel.form | 23 ++++- .../autopsy/casemodule/LocalFilesPanel.java | 93 ++++++++++++++++++- 5 files changed, 113 insertions(+), 12 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties index 217c9e2e09..0e694fe40d 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties @@ -231,4 +231,5 @@ NewCaseVisualPanel1.rbSingleUserCase.text=Single-user NewCaseVisualPanel1.rbMultiUserCase.text=Multi-user NewCaseVisualPanel1.lbBadMultiUserSettings.text= ImageFilePanel.errorLabel.text=Error Label -DataSourceOnCDriveError.text=Path to data source is on \"C:\" drive \ No newline at end of file +DataSourceOnCDriveError.text=Path to data source is on \"C:\" drive +LocalFilesPanel.errorLabel.text=Error Label diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle_ja.properties b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle_ja.properties index 75be232976..07845b238f 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle_ja.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle_ja.properties @@ -216,3 +216,4 @@ ImageFilePanel.noFatOrphansCheckbox.text=FAT\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9 LocalDiskPanel.noFatOrphansCheckbox.text=FAT\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u30aa\u30fc\u30d5\u30a1\u30f3\u30d5\u30a1\u30a4\u30eb\u306f\u7121\u8996 AddImageWizardIngestConfigPanel.CANCEL_BUTTON.text=\u30ad\u30e3\u30f3\u30bb\u30eb ImageFilePanel.errorLabel.text=\u30a8\u30e9\u30fc\u30e9\u30d9\u30eb +LocalFilesPanel.errorLabel.text=\u30a8\u30e9\u30fc\u30e9\u30d9\u30eb diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java index d0b773c4e1..c4d362111e 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java @@ -70,6 +70,7 @@ final class LocalDiskPanel extends JPanel { List pathValidatorList = new ArrayList<>(); private final Pattern driveLetterPattern = Pattern.compile("^[Cc]:.*$"); + private final int prePendedStringLength = 4; // "Local Disk" panel pre-pends "\\.\" in front of all drive letter and drive names /** * Creates new form LocalDiskPanel @@ -250,9 +251,9 @@ final class LocalDiskPanel extends JPanel { errorLabel.setVisible(false); String errorString = ""; String newPath = path; - if (path.length() > 4) { + if (path.length() > prePendedStringLength) { // "Local Disk" panel pre-pends "\\.\" in front of all drive letter and drive names - newPath = path.substring(4, path.length()); + newPath = path.substring(prePendedStringLength, path.length()); } // check if the is a WizardPathValidator service provider diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.form b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.form index cf08c9c38f..eb9d6182bb 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.form +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.form @@ -60,6 +60,10 @@ + + + + @@ -67,15 +71,16 @@ - + + - + - - + + @@ -136,5 +141,15 @@ + + + + + + + + + + diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java index 256276809b..7f4b1da7c1 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java @@ -21,6 +21,9 @@ package org.sleuthkit.autopsy.casemodule; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.Set; import java.util.TreeSet; import javax.swing.JFileChooser; @@ -30,6 +33,9 @@ import org.openide.util.NbBundle; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import java.util.logging.Level; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.sleuthkit.autopsy.corecomponentinterfaces.WizardPathValidator; import org.sleuthkit.autopsy.coreutils.Logger; /** * Add input wizard subpanel for adding local files / dirs to the case @@ -42,6 +48,10 @@ import org.sleuthkit.autopsy.coreutils.Logger; private static LocalFilesPanel instance; public static final String FILES_SEP = ","; private static final Logger logger = Logger.getLogger(LocalFilesPanel.class.getName()); + + List pathValidatorList = new ArrayList<>(); + private final Pattern driveLetterPattern = Pattern.compile("^[Cc]:.*$"); + /** * Creates new form LocalFilesPanel */ @@ -91,8 +101,72 @@ import org.sleuthkit.autopsy.coreutils.Logger; //@Override public boolean validatePanel() { + + if (!isImagePathValid(getContentPaths())) { + return false; + } + return enableNext; } + + /** + * Validates path to selected data source. Calls WizardPathValidator service provider + * if one is available. Otherwise performs path validation locally. + * @param path Absolute path to the selected data source + * @return true if path is valid, false otherwise. + */ + private boolean isImagePathValid(String path){ + + errorLabel.setVisible(false); + String errorString = ""; + + // Path variable for "Local files" module is a coma separated string containg multiple paths + List pathsList = Arrays.asList(path.split(",")); + + for (String currentPath : pathsList) { + // check if the is a WizardPathValidator service provider + if (!pathValidatorList.isEmpty()) { + // call WizardPathValidator service provider + errorString = pathValidatorList.get(0).validateDataSourcePath(currentPath); + if (!errorString.isEmpty()) { + break; + } + } else { + // validate locally + if (Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) { + // check that path is not on "C:" drive + if (pathOnCDrive(currentPath)) { + errorString = NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text"); //NON-NLS + if (!errorString.isEmpty()) { + break; + } + } + } else { + // single user case - no validation needed + } + } + } + + // set error string + if (!errorString.isEmpty()){ + errorLabel.setVisible(true); + errorLabel.setText(errorString); + return false; + } + + return true; + } + + /** + * Checks whether a file path contains drive letter defined by pattern. + * + * @param filePath Input file absolute path + * @return true if path matches the pattern, false otherwise. + */ + private boolean pathOnCDrive(String filePath) { + Matcher m = driveLetterPattern.matcher(filePath); + return m.find(); + } //@Override public void select() { @@ -149,6 +223,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; clearButton = new javax.swing.JButton(); jScrollPane2 = new javax.swing.JScrollPane(); selectedPaths = new javax.swing.JTextArea(); + errorLabel = new javax.swing.JLabel(); localFileChooser.setApproveButtonText(org.openide.util.NbBundle.getMessage(LocalFilesPanel.class, "LocalFilesPanel.localFileChooser.approveButtonText")); // NOI18N localFileChooser.setApproveButtonToolTipText(org.openide.util.NbBundle.getMessage(LocalFilesPanel.class, "LocalFilesPanel.localFileChooser.approveButtonToolTipText")); // NOI18N @@ -184,6 +259,9 @@ import org.sleuthkit.autopsy.coreutils.Logger; selectedPaths.setToolTipText(org.openide.util.NbBundle.getMessage(LocalFilesPanel.class, "LocalFilesPanel.selectedPaths.toolTipText")); // NOI18N jScrollPane2.setViewportView(selectedPaths); + errorLabel.setForeground(new java.awt.Color(255, 0, 0)); + org.openide.awt.Mnemonics.setLocalizedText(errorLabel, org.openide.util.NbBundle.getMessage(LocalFilesPanel.class, "LocalFilesPanel.errorLabel.text")); // NOI18N + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -198,19 +276,23 @@ import org.sleuthkit.autopsy.coreutils.Logger; .addComponent(selectButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(clearButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(2, 2, 2)) + .addGroup(layout.createSequentialGroup() + .addComponent(errorLabel) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(infoLabel) .addGap(5, 5, 5) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addComponent(selectButton) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE) - .addComponent(clearButton)) - .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) - .addGap(0, 0, 0)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(clearButton))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(errorLabel)) ); }// //GEN-END:initComponents @@ -258,6 +340,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton clearButton; + private javax.swing.JLabel errorLabel; private javax.swing.JLabel infoLabel; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; From e22fd06a6456158ef393e2849996a002a40308cf Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Wed, 20 May 2015 17:09:15 -0400 Subject: [PATCH 08/18] Bug fixes --- .../autopsy/casemodule/ImageFilePanel.java | 3 +++ .../autopsy/casemodule/LocalDiskPanel.java | 15 +++++++++++++-- .../autopsy/casemodule/LocalFilesPanel.java | 14 +++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java index 29ac4694fd..0420bce1d8 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java @@ -109,6 +109,9 @@ public class ImageFilePanel extends JPanel implements DocumentListener { pathTextField.getDocument().addDocumentListener(this); } + /** + * Discovers WizardPathValidator service providers + */ private void discoverWizardPathValidators() { for (WizardPathValidator pathValidator : Lookup.getDefault().lookupAll(WizardPathValidator.class)) { pathValidatorList.add(pathValidator); diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java index c4d362111e..9e009a74e3 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java @@ -42,6 +42,7 @@ import javax.swing.ListCellRenderer; import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; import javax.swing.event.ListDataListener; +import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.corecomponentinterfaces.WizardPathValidator; @@ -99,11 +100,21 @@ final class LocalDiskPanel extends JPanel { model = new LocalDiskModel(); diskComboBox.setModel(model); diskComboBox.setRenderer(model); - + + errorLabel.setVisible(false); errorLabel.setText(""); diskComboBox.setEnabled(false); - + discoverWizardPathValidators(); } + + /** + * Discovers WizardPathValidator service providers + */ + private void discoverWizardPathValidators() { + for (WizardPathValidator pathValidator : Lookup.getDefault().lookupAll(WizardPathValidator.class)) { + pathValidatorList.add(pathValidator); + } + } /** * This method is called from within the constructor to initialize the form. diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java index 7f4b1da7c1..21e556bc51 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java @@ -35,6 +35,7 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import java.util.logging.Level; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.openide.util.Lookup; import org.sleuthkit.autopsy.corecomponentinterfaces.WizardPathValidator; import org.sleuthkit.autopsy.coreutils.Logger; /** @@ -69,10 +70,20 @@ import org.sleuthkit.autopsy.coreutils.Logger; private void customInit() { localFileChooser.setMultiSelectionEnabled(true); + discoverWizardPathValidators(); + errorLabel.setVisible(false); selectedPaths.setText(""); - } + /** + * Discovers WizardPathValidator service providers + */ + private void discoverWizardPathValidators() { + for (WizardPathValidator pathValidator : Lookup.getDefault().lookupAll(WizardPathValidator.class)) { + pathValidatorList.add(pathValidator); + } + } + //@Override public String getContentPaths() { //TODO consider interface change to return list of paths instead @@ -178,6 +189,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; currentFiles.clear(); selectedPaths.setText(""); enableNext = false; + errorLabel.setVisible(false); //pcs.firePropertyChange(AddImageWizardChooseDataSourceVisual.EVENT.UPDATE_UI.toString(), false, true); } From 9fcb1a30363882c85d47401a6814cb0336b1f403 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Wed, 20 May 2015 17:29:27 -0400 Subject: [PATCH 09/18] Bug fixes --- .../org/sleuthkit/autopsy/casemodule/ImageFilePanel.java | 4 ++++ .../org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java | 8 +++++++- .../org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java index 0420bce1d8..855077f5f6 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java @@ -309,6 +309,10 @@ public class ImageFilePanel extends JPanel implements DocumentListener { errorLabel.setVisible(false); String errorString = ""; + if (path.isEmpty()) { + return false; // no need for error message as the module sets path to "" at startup + } + // check if the is a WizardPathValidator service provider if (!pathValidatorList.isEmpty()) { // call WizardPathValidator service provider diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java index 9e009a74e3..38e90acee9 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java @@ -261,9 +261,15 @@ final class LocalDiskPanel extends JPanel { errorLabel.setVisible(false); String errorString = ""; + + if (path.isEmpty()) { + return false; // no need for error message as the module sets path to "" at startup + } + String newPath = path; if (path.length() > prePendedStringLength) { - // "Local Disk" panel pre-pends "\\.\" in front of all drive letter and drive names + // "Local Disk" panel pre-pends "\\.\" in front of all drive letter and drive names. + // Path validators expect a "standard" path as input, i.e. one that starts with a drive letter. newPath = path.substring(prePendedStringLength, path.length()); } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java index 21e556bc51..5fe07b097f 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java @@ -131,6 +131,10 @@ import org.sleuthkit.autopsy.coreutils.Logger; errorLabel.setVisible(false); String errorString = ""; + if (path.isEmpty()) { + return false; // no need for error message as the module sets path to "" at startup + } + // Path variable for "Local files" module is a coma separated string containg multiple paths List pathsList = Arrays.asList(path.split(",")); From 3ecab54625bfa059cbaba3ced4e3c4a2f6726302 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Thu, 21 May 2015 09:56:42 -0400 Subject: [PATCH 10/18] Added case type to WizardPathValidator, modified new case panel --- .../autopsy/casemodule/Bundle.properties | 1 + .../autopsy/casemodule/Bundle_ja.properties | 1 + .../autopsy/casemodule/ImageFilePanel.java | 2 +- .../autopsy/casemodule/LocalDiskPanel.java | 2 +- .../autopsy/casemodule/LocalFilesPanel.java | 6 +- .../casemodule/NewCaseVisualPanel1.form | 76 ++++++--- .../casemodule/NewCaseVisualPanel1.java | 151 +++++++++++++++--- .../WizardPathValidator.java | 8 +- 8 files changed, 202 insertions(+), 45 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties index 0e694fe40d..de512b48b3 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties @@ -233,3 +233,4 @@ NewCaseVisualPanel1.lbBadMultiUserSettings.text= ImageFilePanel.errorLabel.text=Error Label DataSourceOnCDriveError.text=Path to data source is on \"C:\" drive LocalFilesPanel.errorLabel.text=Error Label +NewCaseVisualPanel1.errorLabel.text=Error Label diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle_ja.properties b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle_ja.properties index 07845b238f..a3d3832f82 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle_ja.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle_ja.properties @@ -217,3 +217,4 @@ LocalDiskPanel.noFatOrphansCheckbox.text=FAT\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9 AddImageWizardIngestConfigPanel.CANCEL_BUTTON.text=\u30ad\u30e3\u30f3\u30bb\u30eb ImageFilePanel.errorLabel.text=\u30a8\u30e9\u30fc\u30e9\u30d9\u30eb LocalFilesPanel.errorLabel.text=\u30a8\u30e9\u30fc\u30e9\u30d9\u30eb +NewCaseVisualPanel1.errorLabel.text=\u30a8\u30e9\u30fc\u30e9\u30d9\u30eb diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java index 855077f5f6..599182fc41 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java @@ -316,7 +316,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener { // check if the is a WizardPathValidator service provider if (!pathValidatorList.isEmpty()) { // call WizardPathValidator service provider - errorString = pathValidatorList.get(0).validateDataSourcePath(path); + errorString = pathValidatorList.get(0).validateDataSourcePath(path, Case.getCurrentCase().getCaseType()); } else { // validate locally if (Case.getCurrentCase().getCaseType() == CaseType.MULTI_USER_CASE) { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java index 38e90acee9..b10e054785 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java @@ -276,7 +276,7 @@ final class LocalDiskPanel extends JPanel { // check if the is a WizardPathValidator service provider if (!pathValidatorList.isEmpty()) { // call WizardPathValidator service provider - errorString = pathValidatorList.get(0).validateDataSourcePath(newPath); + errorString = pathValidatorList.get(0).validateDataSourcePath(newPath, Case.getCurrentCase().getCaseType()); } else { // validate locally if (Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java index 5fe07b097f..0e52e59563 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java @@ -36,6 +36,7 @@ import java.util.logging.Level; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.openide.util.Lookup; +import org.sleuthkit.autopsy.casemodule.Case.CaseType; import org.sleuthkit.autopsy.corecomponentinterfaces.WizardPathValidator; import org.sleuthkit.autopsy.coreutils.Logger; /** @@ -137,18 +138,19 @@ import org.sleuthkit.autopsy.coreutils.Logger; // Path variable for "Local files" module is a coma separated string containg multiple paths List pathsList = Arrays.asList(path.split(",")); + CaseType currentCaseType = Case.getCurrentCase().getCaseType(); for (String currentPath : pathsList) { // check if the is a WizardPathValidator service provider if (!pathValidatorList.isEmpty()) { // call WizardPathValidator service provider - errorString = pathValidatorList.get(0).validateDataSourcePath(currentPath); + errorString = pathValidatorList.get(0).validateDataSourcePath(currentPath, currentCaseType); if (!errorString.isEmpty()) { break; } } else { // validate locally - if (Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) { + if (currentCaseType == Case.CaseType.MULTI_USER_CASE) { // check that path is not on "C:" drive if (pathOnCDrive(currentPath)) { errorString = NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text"); //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.form b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.form index 37314730b4..dc370e00cd 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.form +++ b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.form @@ -23,33 +23,49 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + - - + - @@ -73,12 +89,14 @@ - + - + + + @@ -158,6 +176,9 @@ + + + @@ -168,6 +189,9 @@ + + + @@ -182,5 +206,15 @@ + + + + + + + + + + diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java index 82584797f1..7ae8a2858c 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java @@ -22,13 +22,18 @@ import org.openide.util.NbBundle; import java.awt.*; import java.io.File; +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.swing.JFileChooser; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import org.openide.util.Lookup; import org.sleuthkit.autopsy.casemodule.Case.CaseType; import org.sleuthkit.autopsy.core.UserPreferences; +import org.sleuthkit.autopsy.corecomponentinterfaces.WizardPathValidator; import org.sleuthkit.datamodel.CaseDbConnectionInfo; import org.sleuthkit.datamodel.TskData.DbType; @@ -41,9 +46,13 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { private JFileChooser fc = new JFileChooser(); private NewCaseWizardPanel1 wizPanel; + java.util.List pathValidatorList = new ArrayList<>(); + private final Pattern driveLetterPattern = Pattern.compile("^[Cc]:.*$"); NewCaseVisualPanel1(NewCaseWizardPanel1 wizPanel) { initComponents(); + discoverWizardPathValidators(); + errorLabel.setVisible(false); lbBadMultiUserSettings.setText(""); this.wizPanel = wizPanel; caseNameTextField.getDocument().addDocumentListener(this); @@ -145,6 +154,7 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { rbSingleUserCase = new javax.swing.JRadioButton(); rbMultiUserCase = new javax.swing.JRadioButton(); lbBadMultiUserSettings = new javax.swing.JLabel(); + errorLabel = new javax.swing.JLabel(); jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class, "NewCaseVisualPanel1.jLabel1.text_1")); // NOI18N @@ -171,14 +181,27 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { caseTypeButtonGroup.add(rbSingleUserCase); org.openide.awt.Mnemonics.setLocalizedText(rbSingleUserCase, org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class, "NewCaseVisualPanel1.rbSingleUserCase.text")); // NOI18N + rbSingleUserCase.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + rbSingleUserCaseActionPerformed(evt); + } + }); caseTypeButtonGroup.add(rbMultiUserCase); org.openide.awt.Mnemonics.setLocalizedText(rbMultiUserCase, org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class, "NewCaseVisualPanel1.rbMultiUserCase.text")); // NOI18N + rbMultiUserCase.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + rbMultiUserCaseActionPerformed(evt); + } + }); lbBadMultiUserSettings.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N lbBadMultiUserSettings.setForeground(new java.awt.Color(255, 0, 0)); org.openide.awt.Mnemonics.setLocalizedText(lbBadMultiUserSettings, org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class, "NewCaseVisualPanel1.lbBadMultiUserSettings.text")); // NOI18N + errorLabel.setForeground(new java.awt.Color(255, 0, 0)); + org.openide.awt.Mnemonics.setLocalizedText(errorLabel, org.openide.util.NbBundle.getMessage(NewCaseVisualPanel1.class, "NewCaseVisualPanel1.errorLabel.text")); // NOI18N + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -186,27 +209,37 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel2) .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) - .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(caseDirTextField, javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 58, Short.MAX_VALUE) + .addComponent(lbBadMultiUserSettings, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addComponent(jLabel1) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addComponent(caseDirLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(caseParentDirTextField)) + .addGroup(layout.createSequentialGroup() + .addComponent(caseNameLabel) + .addGap(26, 26, 26) + .addComponent(caseNameTextField))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(caseDirBrowseButton))) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() .addComponent(rbSingleUserCase) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(rbMultiUserCase)) - .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() - .addComponent(caseDirLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(caseParentDirTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() - .addComponent(caseNameLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(caseNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(caseDirTextField, javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(lbBadMultiUserSettings, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(caseDirBrowseButton))) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(errorLabel)) + .addGap(0, 0, Short.MAX_VALUE)))) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -226,11 +259,13 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(caseDirTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(rbSingleUserCase) .addComponent(rbMultiUserCase)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(errorLabel) + .addGap(1, 1, 1) .addComponent(lbBadMultiUserSettings, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); @@ -261,6 +296,16 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { } }//GEN-LAST:event_caseDirBrowseButtonActionPerformed + private void rbSingleUserCaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbSingleUserCaseActionPerformed + this.wizPanel.fireChangeEvent(); + updateUI(null); // DocumentEvent is not used inside updateUI + }//GEN-LAST:event_rbSingleUserCaseActionPerformed + + private void rbMultiUserCaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbMultiUserCaseActionPerformed + this.wizPanel.fireChangeEvent(); + updateUI(null); // DocumentEvent is not used inside updateUI + }//GEN-LAST:event_rbMultiUserCaseActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton caseDirBrowseButton; private javax.swing.JLabel caseDirLabel; @@ -269,6 +314,7 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { private javax.swing.JTextField caseNameTextField; private javax.swing.JTextField caseParentDirTextField; private javax.swing.ButtonGroup caseTypeButtonGroup; + private javax.swing.JLabel errorLabel; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel lbBadMultiUserSettings; @@ -320,9 +366,17 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { * @param e the document event */ public void updateUI(DocumentEvent e) { + + // Note: DocumentEvent e can be null when called from rbSingleUserCaseActionPerformed() + // and rbMultiUserCaseActionPerformed(). String caseName = getCaseName(); String parentDir = getCaseParentDir(); + + if (!isImagePathValid(parentDir)) { + wizPanel.setIsFinish(false); + return; + } if (!caseName.equals("") && !parentDir.equals("")) { caseDirTextField.setText(parentDir + caseName); @@ -332,4 +386,65 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { wizPanel.setIsFinish(false); } } + + /** + * Validates path to selected data source. Calls WizardPathValidator service provider + * if one is available. Otherwise performs path validation locally. + * @param path Absolute path to the selected data source + * @return true if path is valid, false otherwise. + */ + private boolean isImagePathValid(String path){ + + errorLabel.setVisible(false); + String errorString = ""; + + if (path.isEmpty()) { + return false; // no need for error message as the module sets path to "" at startup + } + + // check if the is a WizardPathValidator service provider + if (!pathValidatorList.isEmpty()) { + // call WizardPathValidator service provider + errorString = pathValidatorList.get(0).validateDataSourcePath(path, getCaseType()); + } else { + // validate locally + if (getCaseType() == Case.CaseType.MULTI_USER_CASE) { + // check that path is not on "C:" drive + if (pathOnCDrive(path)) { + errorString = NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text"); //NON-NLS + } + } else { + // single user case - no validation needed + } + } + + // set error string + if (!errorString.isEmpty()){ + errorLabel.setVisible(true); + errorLabel.setText(errorString); + return false; + } + + return true; + } + + /** + * Checks whether a file path contains drive letter defined by pattern. + * + * @param filePath Input file absolute path + * @return true if path matches the pattern, false otherwise. + */ + private boolean pathOnCDrive(String filePath) { + Matcher m = driveLetterPattern.matcher(filePath); + return m.find(); + } + + /** + * Discovers WizardPathValidator service providers + */ + private void discoverWizardPathValidators() { + for (WizardPathValidator pathValidator : Lookup.getDefault().lookupAll(WizardPathValidator.class)) { + pathValidatorList.add(pathValidator); + } + } } diff --git a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/WizardPathValidator.java b/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/WizardPathValidator.java index 9cebb1411d..045e91198a 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/WizardPathValidator.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/WizardPathValidator.java @@ -18,6 +18,8 @@ */ package org.sleuthkit.autopsy.corecomponentinterfaces; +import org.sleuthkit.autopsy.casemodule.Case; + /* * Defines an interface used by the Add DataSource wizard to validate path for selected * case and/or data source. @@ -36,17 +38,19 @@ public interface WizardPathValidator { * Validates case path. * * @param path Absolute path to case file. + * @param caseType Case type * @return String Error message if path is invalid, empty string otherwise. * */ - String validateCasePath(String path); + String validateCasePath(String path, Case.CaseType caseType); /** * Validates data source path. * * @param path Absolute path to data source file. + * @param caseType Case type * @return String Error message if path is invalid, empty string otherwise. * */ - String validateDataSourcePath(String path); + String validateDataSourcePath(String path, Case.CaseType caseType); } From adfbdf78e71ac9b4343a6b1448fef5537cd44aaa Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Thu, 21 May 2015 10:14:03 -0400 Subject: [PATCH 11/18] Modified error text --- Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties | 3 ++- .../org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties index de512b48b3..35a6d6a7ae 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties @@ -231,6 +231,7 @@ NewCaseVisualPanel1.rbSingleUserCase.text=Single-user NewCaseVisualPanel1.rbMultiUserCase.text=Multi-user NewCaseVisualPanel1.lbBadMultiUserSettings.text= ImageFilePanel.errorLabel.text=Error Label -DataSourceOnCDriveError.text=Path to data source is on \"C:\" drive +DataSourceOnCDriveError.text=Path to multi-user data source is on \"C:\" drive +NewCaseVisualPanel1.CaseFolderOnCDriveError.text=Path to multi-user case folder is on \"C:\" drive LocalFilesPanel.errorLabel.text=Error Label NewCaseVisualPanel1.errorLabel.text=Error Label diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java index 7ae8a2858c..0749da0d5e 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java @@ -411,7 +411,7 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { if (getCaseType() == Case.CaseType.MULTI_USER_CASE) { // check that path is not on "C:" drive if (pathOnCDrive(path)) { - errorString = NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text"); //NON-NLS + errorString = NbBundle.getMessage(this.getClass(), "NewCaseVisualPanel1.CaseFolderOnCDriveError.text"); //NON-NLS } } else { // single user case - no validation needed From e895be0fd708e9cc7a3caf344d087dfa8d592949 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Tue, 26 May 2015 09:50:47 -0400 Subject: [PATCH 12/18] Reworked add data source functionality to not use service provider architecture --- .../autopsy/casemodule/ImageFilePanel.java | 67 ++----------- .../autopsy/casemodule/LocalDiskPanel.java | 70 ++------------ .../autopsy/casemodule/LocalFilesPanel.java | 93 ++++--------------- .../casemodule/NewCaseVisualPanel1.java | 74 +++------------ .../WizardPathValidator.java | 56 ----------- .../coreutils/MultiUserPathValidator.java | 57 ++++++++++++ 6 files changed, 102 insertions(+), 315 deletions(-) delete mode 100644 Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/WizardPathValidator.java create mode 100644 Core/src/org/sleuthkit/autopsy/coreutils/MultiUserPathValidator.java diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java index 599182fc41..c009c6052f 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java @@ -21,7 +21,6 @@ package org.sleuthkit.autopsy.casemodule; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.File; -import java.util.ArrayList; import java.util.Calendar; import java.util.List; import java.util.SimpleTimeZone; @@ -37,12 +36,8 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import java.util.logging.Level; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.openide.util.Lookup; -import org.sleuthkit.autopsy.casemodule.Case.CaseType; -import org.sleuthkit.autopsy.corecomponentinterfaces.WizardPathValidator; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.coreutils.MultiUserPathValidator; /** * ImageTypePanel for adding an image file such as .img, .E0x, .00x, etc. @@ -53,9 +48,6 @@ public class ImageFilePanel extends JPanel implements DocumentListener { private static final Logger logger = Logger.getLogger(ImageFilePanel.class.getName()); private PropertyChangeSupport pcs = null; private JFileChooser fc = new JFileChooser(); - - List pathValidatorList = new ArrayList<>(); - private final Pattern driveLetterPattern = Pattern.compile("^[Cc]:.*$"); // Externally supplied name is used to store settings private String contextName; @@ -72,7 +64,6 @@ public class ImageFilePanel extends JPanel implements DocumentListener { fc.setMultiSelectionEnabled(false); errorLabel.setVisible(false); - discoverWizardPathValidators(); boolean firstFilter = true; for (FileFilter filter: fileChooserFilters ) { @@ -109,14 +100,6 @@ public class ImageFilePanel extends JPanel implements DocumentListener { pathTextField.getDocument().addDocumentListener(this); } - /** - * Discovers WizardPathValidator service providers - */ - private void discoverWizardPathValidators() { - for (WizardPathValidator pathValidator : Lookup.getDefault().lookupAll(WizardPathValidator.class)) { - pathValidatorList.add(pathValidator); - } - } /** * This method is called from within the constructor to initialize the form. @@ -299,58 +282,20 @@ public class ImageFilePanel extends JPanel implements DocumentListener { } /** - * Validates path to selected data source. Calls WizardPathValidator service provider - * if one is available. Otherwise performs path validation locally. + * Validates path to selected data source. * @param path Absolute path to the selected data source * @return true if path is valid, false otherwise. */ - private boolean isImagePathValid(String path){ - - errorLabel.setVisible(false); - String errorString = ""; - - if (path.isEmpty()) { - return false; // no need for error message as the module sets path to "" at startup - } - - // check if the is a WizardPathValidator service provider - if (!pathValidatorList.isEmpty()) { - // call WizardPathValidator service provider - errorString = pathValidatorList.get(0).validateDataSourcePath(path, Case.getCurrentCase().getCaseType()); - } else { - // validate locally - if (Case.getCurrentCase().getCaseType() == CaseType.MULTI_USER_CASE) { - // check that path is not on "C:" drive - if (pathOnCDrive(path)) { - errorString = NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text"); //NON-NLS - } - } else { - // single user case - no validation needed - } - } - - // set error string - if (!errorString.isEmpty()){ + private boolean isImagePathValid(String path){ + errorLabel.setVisible(false); + if (!MultiUserPathValidator.isValid(path, Case.getCurrentCase().getCaseType())) { errorLabel.setVisible(true); - errorLabel.setText(errorString); + errorLabel.setText(NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text")); return false; } - return true; } - /** - * Checks whether a file path contains drive letter defined by pattern. - * - * @param filePath Input file absolute path - * @return true if path matches the pattern, false otherwise. - */ - private boolean pathOnCDrive(String filePath) { - Matcher m = driveLetterPattern.matcher(filePath); - return m.find(); - } - - public void storeSettings() { String imagePathName = getContentPaths(); if (null != imagePathName ) { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java index b10e054785..e109c40cf0 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java @@ -31,8 +31,6 @@ import java.util.SimpleTimeZone; import java.util.TimeZone; import java.util.concurrent.CancellationException; import java.util.logging.Level; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import javax.swing.ComboBoxModel; import javax.swing.JLabel; import javax.swing.JList; @@ -42,13 +40,12 @@ import javax.swing.ListCellRenderer; import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; import javax.swing.event.ListDataListener; -import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; -import org.sleuthkit.autopsy.corecomponentinterfaces.WizardPathValidator; import org.sleuthkit.autopsy.coreutils.LocalDisk; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; +import org.sleuthkit.autopsy.coreutils.MultiUserPathValidator; import org.sleuthkit.autopsy.coreutils.PlatformUtil; /** @@ -69,8 +66,6 @@ final class LocalDiskPanel extends JPanel { private boolean enableNext = false; - List pathValidatorList = new ArrayList<>(); - private final Pattern driveLetterPattern = Pattern.compile("^[Cc]:.*$"); private final int prePendedStringLength = 4; // "Local Disk" panel pre-pends "\\.\" in front of all drive letter and drive names /** @@ -104,17 +99,7 @@ final class LocalDiskPanel extends JPanel { errorLabel.setVisible(false); errorLabel.setText(""); diskComboBox.setEnabled(false); - discoverWizardPathValidators(); - } - - /** - * Discovers WizardPathValidator service providers - */ - private void discoverWizardPathValidators() { - for (WizardPathValidator pathValidator : Lookup.getDefault().lookupAll(WizardPathValidator.class)) { - pathValidatorList.add(pathValidator); - } - } + } /** * This method is called from within the constructor to initialize the form. @@ -252,20 +237,11 @@ final class LocalDiskPanel extends JPanel { } /** - * Validates path to selected data source. Calls WizardPathValidator service provider - * if one is available. Otherwise performs path validation locally. + * Validates path to selected data source. * @param path Absolute path to the selected data source * @return true if path is valid, false otherwise. */ - private boolean isImagePathValid(String path){ - - errorLabel.setVisible(false); - String errorString = ""; - - if (path.isEmpty()) { - return false; // no need for error message as the module sets path to "" at startup - } - + private boolean isImagePathValid(String path){ String newPath = path; if (path.length() > prePendedStringLength) { // "Local Disk" panel pre-pends "\\.\" in front of all drive letter and drive names. @@ -273,42 +249,14 @@ final class LocalDiskPanel extends JPanel { newPath = path.substring(prePendedStringLength, path.length()); } - // check if the is a WizardPathValidator service provider - if (!pathValidatorList.isEmpty()) { - // call WizardPathValidator service provider - errorString = pathValidatorList.get(0).validateDataSourcePath(newPath, Case.getCurrentCase().getCaseType()); - } else { - // validate locally - if (Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) { - // check that path is not on "C:" drive - if (pathOnCDrive(newPath)) { - errorString = NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text"); //NON-NLS - } - } else { - // single user case - no validation needed - } - } - - // set error string - if (!errorString.isEmpty()){ + errorLabel.setVisible(false); + if (!MultiUserPathValidator.isValid(newPath, Case.getCurrentCase().getCaseType())) { errorLabel.setVisible(true); - errorLabel.setText(errorString); + errorLabel.setText(NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text")); return false; - } - + } return true; - } - - /** - * Checks whether a file path contains drive letter defined by pattern. - * - * @param filePath Input file absolute path - * @return true if path matches the pattern, false otherwise. - */ - private boolean pathOnCDrive(String filePath) { - Matcher m = driveLetterPattern.matcher(filePath); - return m.find(); - } + } //@Override public void reset() { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java index 0e52e59563..2caf8dd09b 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java @@ -21,7 +21,6 @@ package org.sleuthkit.autopsy.casemodule; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.File; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Set; @@ -33,12 +32,9 @@ import org.openide.util.NbBundle; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import java.util.logging.Level; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.openide.util.Lookup; import org.sleuthkit.autopsy.casemodule.Case.CaseType; -import org.sleuthkit.autopsy.corecomponentinterfaces.WizardPathValidator; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.coreutils.MultiUserPathValidator; /** * Add input wizard subpanel for adding local files / dirs to the case */ @@ -51,9 +47,6 @@ import org.sleuthkit.autopsy.coreutils.Logger; public static final String FILES_SEP = ","; private static final Logger logger = Logger.getLogger(LocalFilesPanel.class.getName()); - List pathValidatorList = new ArrayList<>(); - private final Pattern driveLetterPattern = Pattern.compile("^[Cc]:.*$"); - /** * Creates new form LocalFilesPanel */ @@ -71,18 +64,8 @@ import org.sleuthkit.autopsy.coreutils.Logger; private void customInit() { localFileChooser.setMultiSelectionEnabled(true); - discoverWizardPathValidators(); errorLabel.setVisible(false); selectedPaths.setText(""); - } - - /** - * Discovers WizardPathValidator service providers - */ - private void discoverWizardPathValidators() { - for (WizardPathValidator pathValidator : Lookup.getDefault().lookupAll(WizardPathValidator.class)) { - pathValidatorList.add(pathValidator); - } } //@Override @@ -122,68 +105,26 @@ import org.sleuthkit.autopsy.coreutils.Logger; } /** - * Validates path to selected data source. Calls WizardPathValidator service provider - * if one is available. Otherwise performs path validation locally. + * Validates path to selected data source. * @param path Absolute path to the selected data source * @return true if path is valid, false otherwise. */ - private boolean isImagePathValid(String path){ - - errorLabel.setVisible(false); - String errorString = ""; - - if (path.isEmpty()) { - return false; // no need for error message as the module sets path to "" at startup - } - - // Path variable for "Local files" module is a coma separated string containg multiple paths - List pathsList = Arrays.asList(path.split(",")); - CaseType currentCaseType = Case.getCurrentCase().getCaseType(); + private boolean isImagePathValid(String path) { + errorLabel.setVisible(false); - for (String currentPath : pathsList) { - // check if the is a WizardPathValidator service provider - if (!pathValidatorList.isEmpty()) { - // call WizardPathValidator service provider - errorString = pathValidatorList.get(0).validateDataSourcePath(currentPath, currentCaseType); - if (!errorString.isEmpty()) { - break; - } - } else { - // validate locally - if (currentCaseType == Case.CaseType.MULTI_USER_CASE) { - // check that path is not on "C:" drive - if (pathOnCDrive(currentPath)) { - errorString = NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text"); //NON-NLS - if (!errorString.isEmpty()) { - break; - } - } - } else { - // single user case - no validation needed - } - } - } - - // set error string - if (!errorString.isEmpty()){ - errorLabel.setVisible(true); - errorLabel.setText(errorString); - return false; - } - - return true; - } - - /** - * Checks whether a file path contains drive letter defined by pattern. - * - * @param filePath Input file absolute path - * @return true if path matches the pattern, false otherwise. - */ - private boolean pathOnCDrive(String filePath) { - Matcher m = driveLetterPattern.matcher(filePath); - return m.find(); - } + // Path variable for "Local files" module is a coma separated string containg multiple paths + List pathsList = Arrays.asList(path.split(",")); + CaseType currentCaseType = Case.getCurrentCase().getCaseType(); + + for (String currentPath : pathsList) { + if (!MultiUserPathValidator.isValid(currentPath, currentCaseType)) { + errorLabel.setVisible(true); + errorLabel.setText(NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text")); + return false; + } + } + return true; + } //@Override public void select() { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java index 0749da0d5e..a98c8694b3 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java @@ -22,18 +22,14 @@ import org.openide.util.NbBundle; import java.awt.*; import java.io.File; -import java.util.ArrayList; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import javax.swing.JFileChooser; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import org.openide.util.Lookup; import org.sleuthkit.autopsy.casemodule.Case.CaseType; import org.sleuthkit.autopsy.core.UserPreferences; -import org.sleuthkit.autopsy.corecomponentinterfaces.WizardPathValidator; +import org.sleuthkit.autopsy.coreutils.MultiUserPathValidator; import org.sleuthkit.datamodel.CaseDbConnectionInfo; import org.sleuthkit.datamodel.TskData.DbType; @@ -45,13 +41,10 @@ import org.sleuthkit.datamodel.TskData.DbType; final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { private JFileChooser fc = new JFileChooser(); - private NewCaseWizardPanel1 wizPanel; - java.util.List pathValidatorList = new ArrayList<>(); - private final Pattern driveLetterPattern = Pattern.compile("^[Cc]:.*$"); + private NewCaseWizardPanel1 wizPanel; NewCaseVisualPanel1(NewCaseWizardPanel1 wizPanel) { initComponents(); - discoverWizardPathValidators(); errorLabel.setVisible(false); lbBadMultiUserSettings.setText(""); this.wizPanel = wizPanel; @@ -373,11 +366,6 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { String caseName = getCaseName(); String parentDir = getCaseParentDir(); - if (!isImagePathValid(parentDir)) { - wizPanel.setIsFinish(false); - return; - } - if (!caseName.equals("") && !parentDir.equals("")) { caseDirTextField.setText(parentDir + caseName); wizPanel.setIsFinish(true); @@ -385,66 +373,30 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { caseDirTextField.setText(""); wizPanel.setIsFinish(false); } + + if (!isImagePathValid(parentDir)) { + wizPanel.setIsFinish(false); + } } /** - * Validates path to selected data source. Calls WizardPathValidator service provider - * if one is available. Otherwise performs path validation locally. + * Validates path to selected data source. + * * @param path Absolute path to the selected data source * @return true if path is valid, false otherwise. */ - private boolean isImagePathValid(String path){ - + private boolean isImagePathValid(String path) { errorLabel.setVisible(false); - String errorString = ""; - + if (path.isEmpty()) { return false; // no need for error message as the module sets path to "" at startup } - // check if the is a WizardPathValidator service provider - if (!pathValidatorList.isEmpty()) { - // call WizardPathValidator service provider - errorString = pathValidatorList.get(0).validateDataSourcePath(path, getCaseType()); - } else { - // validate locally - if (getCaseType() == Case.CaseType.MULTI_USER_CASE) { - // check that path is not on "C:" drive - if (pathOnCDrive(path)) { - errorString = NbBundle.getMessage(this.getClass(), "NewCaseVisualPanel1.CaseFolderOnCDriveError.text"); //NON-NLS - } - } else { - // single user case - no validation needed - } - } - - // set error string - if (!errorString.isEmpty()){ + if (!MultiUserPathValidator.isValid(path, getCaseType())) { errorLabel.setVisible(true); - errorLabel.setText(errorString); + errorLabel.setText(NbBundle.getMessage(this.getClass(), "NewCaseVisualPanel1.CaseFolderOnCDriveError.text")); return false; } - return true; - } - - /** - * Checks whether a file path contains drive letter defined by pattern. - * - * @param filePath Input file absolute path - * @return true if path matches the pattern, false otherwise. - */ - private boolean pathOnCDrive(String filePath) { - Matcher m = driveLetterPattern.matcher(filePath); - return m.find(); - } - - /** - * Discovers WizardPathValidator service providers - */ - private void discoverWizardPathValidators() { - for (WizardPathValidator pathValidator : Lookup.getDefault().lookupAll(WizardPathValidator.class)) { - pathValidatorList.add(pathValidator); - } - } + } } diff --git a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/WizardPathValidator.java b/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/WizardPathValidator.java deleted file mode 100644 index 045e91198a..0000000000 --- a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/WizardPathValidator.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2011-2014 Basis Technology Corp. - * Contact: carrier sleuthkit 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.corecomponentinterfaces; - -import org.sleuthkit.autopsy.casemodule.Case; - -/* - * Defines an interface used by the Add DataSource wizard to validate path for selected - * case and/or data source. - * - * Different Autopsy implementations and modes may have its unique attributes and - * may need to be processed differently. - * - * The WizardPathValidator interface defines a uniform mechanism for the Autopsy UI - * to: - * - Validate path for selected case. - * - Validate path for selected data source. - */ -public interface WizardPathValidator { - - /** - * Validates case path. - * - * @param path Absolute path to case file. - * @param caseType Case type - * @return String Error message if path is invalid, empty string otherwise. - * - */ - String validateCasePath(String path, Case.CaseType caseType); - - /** - * Validates data source path. - * - * @param path Absolute path to data source file. - * @param caseType Case type - * @return String Error message if path is invalid, empty string otherwise. - * - */ - String validateDataSourcePath(String path, Case.CaseType caseType); -} diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/MultiUserPathValidator.java b/Core/src/org/sleuthkit/autopsy/coreutils/MultiUserPathValidator.java new file mode 100644 index 0000000000..3bc4b3f4f7 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/coreutils/MultiUserPathValidator.java @@ -0,0 +1,57 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2013-2014 Basis Technology Corp. + * Contact: carrier sleuthkit 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.coreutils; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.sleuthkit.autopsy.casemodule.Case; + +/** + * Validates absolute path to a data source depending on case type. + */ +public final class MultiUserPathValidator { + + private static final Pattern driveLetterPattern = Pattern.compile("^[Cc]:.*$"); + public static boolean isValid(String path, Case.CaseType caseType) { + + if (caseType == Case.CaseType.MULTI_USER_CASE) { + // check that path is not on "C:" drive + if (pathOnCDrive(path)) { + return false; + } + } else { + // single user case - no validation needed + } + + return true; + } + + + /** + * Checks whether a file path contains drive letter defined by pattern. + * + * @param filePath Input file absolute path + * @return true if path matches the pattern, false otherwise. + */ + private static boolean pathOnCDrive(String filePath) { + Matcher m = driveLetterPattern.matcher(filePath); + return m.find(); + } +} \ No newline at end of file From 3d99f685c1bd5b6fe45b88a77268a4bbd983fee8 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Tue, 26 May 2015 13:35:11 -0400 Subject: [PATCH 13/18] Modified panels to treat C drive path as warning rather than error --- .../sleuthkit/autopsy/casemodule/ImageFilePanel.java | 11 +++++------ .../sleuthkit/autopsy/casemodule/LocalDiskPanel.java | 5 ++--- .../sleuthkit/autopsy/casemodule/LocalFilesPanel.java | 5 ++--- .../autopsy/casemodule/NewCaseVisualPanel1.java | 9 ++++----- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java index c009c6052f..c0a265420e 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java @@ -265,18 +265,18 @@ public class ImageFilePanel extends JPanel implements DocumentListener { * @return true if a proper image has been selected, false otherwise */ public boolean validatePanel() { + errorLabel.setVisible(false); String path = getContentPaths(); if (path == null || path.isEmpty()) { return false; } + // display warning if there is one (but don't disable "next" button) + isImagePathValid(path); + boolean isExist = Case.pathExists(path); boolean isPhysicalDrive = Case.isPhysicalDrive(path); boolean isPartition = Case.isPartition(path); - - if (!isImagePathValid(path)) { - return false; - } return (isExist || isPhysicalDrive || isPartition); } @@ -286,8 +286,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener { * @param path Absolute path to the selected data source * @return true if path is valid, false otherwise. */ - private boolean isImagePathValid(String path){ - errorLabel.setVisible(false); + private boolean isImagePathValid(String path){ if (!MultiUserPathValidator.isValid(path, Case.getCurrentCase().getCaseType())) { errorLabel.setVisible(true); errorLabel.setText(NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text")); diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java index e109c40cf0..206f8087fb 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java @@ -229,9 +229,8 @@ final class LocalDiskPanel extends JPanel { //@Override public boolean validatePanel() { - if (!isImagePathValid(getContentPaths())) { - return false; - } + // display warning if there is one (but don't disable "next" button) + isImagePathValid(getContentPaths()); return enableNext; } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java index 2caf8dd09b..b20bd71bb6 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java @@ -97,9 +97,8 @@ import org.sleuthkit.autopsy.coreutils.MultiUserPathValidator; //@Override public boolean validatePanel() { - if (!isImagePathValid(getContentPaths())) { - return false; - } + // display warning if there is one (but don't disable "next" button) + isImagePathValid(getContentPaths()); return enableNext; } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java index a98c8694b3..0cee4eab00 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java @@ -374,15 +374,14 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { wizPanel.setIsFinish(false); } - if (!isImagePathValid(parentDir)) { - wizPanel.setIsFinish(false); - } + // display warning if there is one (but don't disable "next" button) + isImagePathValid(parentDir); } /** - * Validates path to selected data source. + * Validates path to selected case output folder. * - * @param path Absolute path to the selected data source + * @param path Absolute path to the selected case folder * @return true if path is valid, false otherwise. */ private boolean isImagePathValid(String path) { From 595111175415e0a14a9a24049ded72eb6dcbd778 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Wed, 27 May 2015 11:13:49 -0400 Subject: [PATCH 14/18] Modified panels per review feedback --- .../sleuthkit/autopsy/casemodule/Bundle.properties | 6 +++--- .../sleuthkit/autopsy/casemodule/ImageFilePanel.java | 9 +++------ .../sleuthkit/autopsy/casemodule/LocalDiskPanel.java | 11 ++++------- .../sleuthkit/autopsy/casemodule/LocalFilesPanel.java | 10 ++++------ 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties index 35a6d6a7ae..4f1698b58d 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties @@ -58,7 +58,7 @@ LocalDiskPanel.diskLabel.text=Select a local disk: MissingImageDialog.selectButton.text=Select Image MissingImageDialog.titleLabel.text=Search for missing image MissingImageDialog.cancelButton.text=Cancel -LocalDiskPanel.errorLabel.text=Error Label +LocalDiskPanel.errorLabel.text= LocalFilesPanel.infoLabel.text=Add local files and folders: LocalFilesPanel.selectButton.text=Add LocalFilesPanel.localFileChooser.dialogTitle=Select Local Files or Folders @@ -230,8 +230,8 @@ AddImageWizardIngestConfigPanel.CANCEL_BUTTON.text=Cancel NewCaseVisualPanel1.rbSingleUserCase.text=Single-user NewCaseVisualPanel1.rbMultiUserCase.text=Multi-user NewCaseVisualPanel1.lbBadMultiUserSettings.text= -ImageFilePanel.errorLabel.text=Error Label +ImageFilePanel.errorLabel.text= DataSourceOnCDriveError.text=Path to multi-user data source is on \"C:\" drive NewCaseVisualPanel1.CaseFolderOnCDriveError.text=Path to multi-user case folder is on \"C:\" drive -LocalFilesPanel.errorLabel.text=Error Label +LocalFilesPanel.errorLabel.text= NewCaseVisualPanel1.errorLabel.text=Error Label diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java index c0a265420e..83e02d349d 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java @@ -272,7 +272,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener { } // display warning if there is one (but don't disable "next" button) - isImagePathValid(path); + warnIfPathIsInvalid(path); boolean isExist = Case.pathExists(path); boolean isPhysicalDrive = Case.isPhysicalDrive(path); @@ -282,17 +282,14 @@ public class ImageFilePanel extends JPanel implements DocumentListener { } /** - * Validates path to selected data source. + * Validates path to selected data source and displays warning if it is invalid. * @param path Absolute path to the selected data source - * @return true if path is valid, false otherwise. */ - private boolean isImagePathValid(String path){ + private void warnIfPathIsInvalid(String path){ if (!MultiUserPathValidator.isValid(path, Case.getCurrentCase().getCaseType())) { errorLabel.setVisible(true); errorLabel.setText(NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text")); - return false; } - return true; } public void storeSettings() { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java index 206f8087fb..eb07ddab2d 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java @@ -170,7 +170,7 @@ final class LocalDiskPanel extends JPanel { .addComponent(noFatOrphansCheckbox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(descLabel) - .addContainerGap(21, Short.MAX_VALUE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables @@ -230,17 +230,16 @@ final class LocalDiskPanel extends JPanel { public boolean validatePanel() { // display warning if there is one (but don't disable "next" button) - isImagePathValid(getContentPaths()); + warnIfPathIsInvalid(getContentPaths()); return enableNext; } /** - * Validates path to selected data source. + * Validates path to selected data source and displays warning if it is invalid. * @param path Absolute path to the selected data source - * @return true if path is valid, false otherwise. */ - private boolean isImagePathValid(String path){ + private void warnIfPathIsInvalid(String path){ String newPath = path; if (path.length() > prePendedStringLength) { // "Local Disk" panel pre-pends "\\.\" in front of all drive letter and drive names. @@ -252,9 +251,7 @@ final class LocalDiskPanel extends JPanel { if (!MultiUserPathValidator.isValid(newPath, Case.getCurrentCase().getCaseType())) { errorLabel.setVisible(true); errorLabel.setText(NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text")); - return false; } - return true; } //@Override diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java index b20bd71bb6..efcb4439b0 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java @@ -98,17 +98,16 @@ import org.sleuthkit.autopsy.coreutils.MultiUserPathValidator; public boolean validatePanel() { // display warning if there is one (but don't disable "next" button) - isImagePathValid(getContentPaths()); + warnIfPathIsInvalid(getContentPaths()); return enableNext; } /** - * Validates path to selected data source. + * Validates path to selected data source and displays warning if it is invalid. * @param path Absolute path to the selected data source - * @return true if path is valid, false otherwise. */ - private boolean isImagePathValid(String path) { + private void warnIfPathIsInvalid(String path) { errorLabel.setVisible(false); // Path variable for "Local files" module is a coma separated string containg multiple paths @@ -119,10 +118,9 @@ import org.sleuthkit.autopsy.coreutils.MultiUserPathValidator; if (!MultiUserPathValidator.isValid(currentPath, currentCaseType)) { errorLabel.setVisible(true); errorLabel.setText(NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text")); - return false; + return; } } - return true; } //@Override From 9e925bb0b786e38eb1ff17d83340f90a867ba611 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Wed, 27 May 2015 14:13:14 -0400 Subject: [PATCH 15/18] Refactored PathValidator and error label --- Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties | 6 +++--- .../org/sleuthkit/autopsy/casemodule/ImageFilePanel.java | 4 ++-- .../org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java | 4 ++-- .../org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java | 4 ++-- .../sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java | 4 ++-- .../{MultiUserPathValidator.java => PathValidator.java} | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) rename Core/src/org/sleuthkit/autopsy/coreutils/{MultiUserPathValidator.java => PathValidator.java} (92%) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties index 29eb25b0cc..8afd1f5cdb 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties @@ -58,7 +58,7 @@ LocalDiskPanel.diskLabel.text=Select a local disk: MissingImageDialog.selectButton.text=Select Image MissingImageDialog.titleLabel.text=Search for missing image MissingImageDialog.cancelButton.text=Cancel -LocalDiskPanel.errorLabel.text= +LocalDiskPanel.errorLabel.text=Error Label LocalFilesPanel.infoLabel.text=Add local files and folders: LocalFilesPanel.selectButton.text=Add LocalFilesPanel.localFileChooser.dialogTitle=Select Local Files or Folders @@ -231,8 +231,8 @@ AddImageWizardIngestConfigPanel.CANCEL_BUTTON.text=Cancel NewCaseVisualPanel1.rbSingleUserCase.text=Single-user NewCaseVisualPanel1.rbMultiUserCase.text=Multi-user NewCaseVisualPanel1.lbBadMultiUserSettings.text= -ImageFilePanel.errorLabel.text= +ImageFilePanel.errorLabel.text=Error Label DataSourceOnCDriveError.text=Path to multi-user data source is on \"C:\" drive NewCaseVisualPanel1.CaseFolderOnCDriveError.text=Path to multi-user case folder is on \"C:\" drive -LocalFilesPanel.errorLabel.text= +LocalFilesPanel.errorLabel.text=Error Label NewCaseVisualPanel1.errorLabel.text=Error Label diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java index 83e02d349d..e9f518eb80 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java @@ -37,7 +37,7 @@ import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import java.util.logging.Level; import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.coreutils.MultiUserPathValidator; +import org.sleuthkit.autopsy.coreutils.PathValidator; /** * ImageTypePanel for adding an image file such as .img, .E0x, .00x, etc. @@ -286,7 +286,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener { * @param path Absolute path to the selected data source */ private void warnIfPathIsInvalid(String path){ - if (!MultiUserPathValidator.isValid(path, Case.getCurrentCase().getCaseType())) { + if (!PathValidator.isValid(path, Case.getCurrentCase().getCaseType())) { errorLabel.setVisible(true); errorLabel.setText(NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text")); } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java index eb07ddab2d..7e03c59268 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java @@ -45,7 +45,7 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.coreutils.LocalDisk; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; -import org.sleuthkit.autopsy.coreutils.MultiUserPathValidator; +import org.sleuthkit.autopsy.coreutils.PathValidator; import org.sleuthkit.autopsy.coreutils.PlatformUtil; /** @@ -248,7 +248,7 @@ final class LocalDiskPanel extends JPanel { } errorLabel.setVisible(false); - if (!MultiUserPathValidator.isValid(newPath, Case.getCurrentCase().getCaseType())) { + if (!PathValidator.isValid(newPath, Case.getCurrentCase().getCaseType())) { errorLabel.setVisible(true); errorLabel.setText(NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text")); } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java index efcb4439b0..f2c1d7d82f 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java @@ -34,7 +34,7 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import java.util.logging.Level; import org.sleuthkit.autopsy.casemodule.Case.CaseType; import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.coreutils.MultiUserPathValidator; +import org.sleuthkit.autopsy.coreutils.PathValidator; /** * Add input wizard subpanel for adding local files / dirs to the case */ @@ -115,7 +115,7 @@ import org.sleuthkit.autopsy.coreutils.MultiUserPathValidator; CaseType currentCaseType = Case.getCurrentCase().getCaseType(); for (String currentPath : pathsList) { - if (!MultiUserPathValidator.isValid(currentPath, currentCaseType)) { + if (!PathValidator.isValid(currentPath, currentCaseType)) { errorLabel.setVisible(true); errorLabel.setText(NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text")); return; diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java index 4fb29e7d1b..1ae4d3c406 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java @@ -29,7 +29,7 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.sleuthkit.autopsy.casemodule.Case.CaseType; import org.sleuthkit.autopsy.core.UserPreferences; -import org.sleuthkit.autopsy.coreutils.MultiUserPathValidator; +import org.sleuthkit.autopsy.coreutils.PathValidator; import org.sleuthkit.datamodel.CaseDbConnectionInfo; import org.sleuthkit.datamodel.TskData.DbType; @@ -391,7 +391,7 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { return false; // no need for error message as the module sets path to "" at startup } - if (!MultiUserPathValidator.isValid(path, getCaseType())) { + if (!PathValidator.isValid(path, getCaseType())) { errorLabel.setVisible(true); errorLabel.setText(NbBundle.getMessage(this.getClass(), "NewCaseVisualPanel1.CaseFolderOnCDriveError.text")); return false; diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/MultiUserPathValidator.java b/Core/src/org/sleuthkit/autopsy/coreutils/PathValidator.java similarity index 92% rename from Core/src/org/sleuthkit/autopsy/coreutils/MultiUserPathValidator.java rename to Core/src/org/sleuthkit/autopsy/coreutils/PathValidator.java index 3bc4b3f4f7..b4d842fd88 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/MultiUserPathValidator.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/PathValidator.java @@ -24,9 +24,9 @@ import java.util.regex.Pattern; import org.sleuthkit.autopsy.casemodule.Case; /** - * Validates absolute path to a data source depending on case type. + * Validates absolute path (e.g. to a data source or case output folder) depending on case type. */ -public final class MultiUserPathValidator { +public final class PathValidator { private static final Pattern driveLetterPattern = Pattern.compile("^[Cc]:.*$"); public static boolean isValid(String path, Case.CaseType caseType) { From 571119735770553029265fcca47c24643617a791 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Wed, 27 May 2015 14:40:34 -0400 Subject: [PATCH 16/18] Local disk DSP is no longer available for MU cases --- .../AddImageWizardChooseDataSourceVisual.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java index 328d307935..7e2442f789 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java @@ -83,8 +83,11 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { // make a list of core DSPs // ensure that the core DSPs are at the top and in a fixed order - coreDSPTypes.add(ImageDSProcessor.getType()); - coreDSPTypes.add(LocalDiskDSProcessor.getType()); + coreDSPTypes.add(ImageDSProcessor.getType()); + // Local disk processing is not allowed for multi-user cases + if (Case.getCurrentCase().getCaseType() != Case.CaseType.MULTI_USER_CASE){ + coreDSPTypes.add(LocalDiskDSProcessor.getType()); + } coreDSPTypes.add(LocalFilesDSProcessor.getType()); for (String dspType : coreDSPTypes) { @@ -94,7 +97,10 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { // now add any addtional DSPs that haven't already been added for (String dspType : dspTypes) { if (!coreDSPTypes.contains(dspType)) { - typeComboBox.addItem(dspType); + // Local disk processing is not allowed for multi-user cases + if (Case.getCurrentCase().getCaseType() != Case.CaseType.MULTI_USER_CASE || !dspType.contains(LocalDiskDSProcessor.getType())) { + typeComboBox.addItem(dspType); + } } } From 146c0c3b23642f901ca9953806dbcde13d0cec2d Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Wed, 27 May 2015 14:50:18 -0400 Subject: [PATCH 17/18] Refactored some code --- .../AddImageWizardChooseDataSourceVisual.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java index 7e2442f789..721320d369 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java @@ -97,10 +97,7 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { // now add any addtional DSPs that haven't already been added for (String dspType : dspTypes) { if (!coreDSPTypes.contains(dspType)) { - // Local disk processing is not allowed for multi-user cases - if (Case.getCurrentCase().getCaseType() != Case.CaseType.MULTI_USER_CASE || !dspType.contains(LocalDiskDSProcessor.getType())) { - typeComboBox.addItem(dspType); - } + addDataSourceProcessorToComboBox(dspType); } } @@ -122,6 +119,13 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { typeComboBox.addActionListener(cbActionListener); typeComboBox.setSelectedIndex(0); } + + private void addDataSourceProcessorToComboBox(String dspType) { + // Local disk processing is not allowed for multi-user cases + if (Case.getCurrentCase().getCaseType() != Case.CaseType.MULTI_USER_CASE || !dspType.contains(LocalDiskDSProcessor.getType())) { + typeComboBox.addItem(dspType); + } + } private void discoverDataSourceProcessors() { From ee48f3850d96360dc2ab5271971e458f43a4d9a0 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Thu, 28 May 2015 10:09:18 -0400 Subject: [PATCH 18/18] Changes from review feedback --- .../AddImageWizardChooseDataSourceVisual.java | 14 ++++------ .../autopsy/casemodule/LocalDiskPanel.java | 28 +------------------ .../casemodule/NewCaseVisualPanel1.java | 14 ++-------- .../casemodule/NewCaseWizardPanel1.java | 1 - 4 files changed, 9 insertions(+), 48 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java index 721320d369..4476083f1d 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java @@ -87,7 +87,10 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { // Local disk processing is not allowed for multi-user cases if (Case.getCurrentCase().getCaseType() != Case.CaseType.MULTI_USER_CASE){ coreDSPTypes.add(LocalDiskDSProcessor.getType()); - } + } else { + // remove LocalDiskDSProcessor from list of DSPs + datasourceProcessorsMap.remove(LocalDiskDSProcessor.getType()); + } coreDSPTypes.add(LocalFilesDSProcessor.getType()); for (String dspType : coreDSPTypes) { @@ -97,7 +100,7 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { // now add any addtional DSPs that haven't already been added for (String dspType : dspTypes) { if (!coreDSPTypes.contains(dspType)) { - addDataSourceProcessorToComboBox(dspType); + typeComboBox.addItem(dspType); } } @@ -119,13 +122,6 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { typeComboBox.addActionListener(cbActionListener); typeComboBox.setSelectedIndex(0); } - - private void addDataSourceProcessorToComboBox(String dspType) { - // Local disk processing is not allowed for multi-user cases - if (Case.getCurrentCase().getCaseType() != Case.CaseType.MULTI_USER_CASE || !dspType.contains(LocalDiskDSProcessor.getType())) { - typeComboBox.addItem(dspType); - } - } private void discoverDataSourceProcessors() { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java index 7e03c59268..3cf6b40bc6 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java @@ -45,7 +45,6 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.coreutils.LocalDisk; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; -import org.sleuthkit.autopsy.coreutils.PathValidator; import org.sleuthkit.autopsy.coreutils.PlatformUtil; /** @@ -65,8 +64,6 @@ final class LocalDiskPanel extends JPanel { private LocalDiskModel model; private boolean enableNext = false; - - private final int prePendedStringLength = 4; // "Local Disk" panel pre-pends "\\.\" in front of all drive letter and drive names /** * Creates new form LocalDiskPanel @@ -227,32 +224,9 @@ final class LocalDiskPanel extends JPanel { * @return true */ //@Override - public boolean validatePanel() { - - // display warning if there is one (but don't disable "next" button) - warnIfPathIsInvalid(getContentPaths()); - + public boolean validatePanel() { return enableNext; } - - /** - * Validates path to selected data source and displays warning if it is invalid. - * @param path Absolute path to the selected data source - */ - private void warnIfPathIsInvalid(String path){ - String newPath = path; - if (path.length() > prePendedStringLength) { - // "Local Disk" panel pre-pends "\\.\" in front of all drive letter and drive names. - // Path validators expect a "standard" path as input, i.e. one that starts with a drive letter. - newPath = path.substring(prePendedStringLength, path.length()); - } - - errorLabel.setVisible(false); - if (!PathValidator.isValid(newPath, Case.getCurrentCase().getCaseType())) { - errorLabel.setVisible(true); - errorLabel.setText(NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text")); - } - } //@Override public void reset() { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java index 1ae4d3c406..0ca9173fee 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseVisualPanel1.java @@ -375,27 +375,19 @@ final class NewCaseVisualPanel1 extends JPanel implements DocumentListener { } // display warning if there is one (but don't disable "next" button) - isImagePathValid(parentDir); + warnIfPathIsInvalid(parentDir); } /** - * Validates path to selected case output folder. + * Validates path to selected case output folder. Displays warning if path is invalid. * * @param path Absolute path to the selected case folder - * @return true if path is valid, false otherwise. */ - private boolean isImagePathValid(String path) { + private void warnIfPathIsInvalid(String path) { errorLabel.setVisible(false); - - if (path.isEmpty()) { - return false; // no need for error message as the module sets path to "" at startup - } - if (!PathValidator.isValid(path, getCaseType())) { errorLabel.setVisible(true); errorLabel.setText(NbBundle.getMessage(this.getClass(), "NewCaseVisualPanel1.CaseFolderOnCDriveError.text")); - return false; } - return true; } } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel1.java b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel1.java index 92bad320dd..ccdb48b951 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel1.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel1.java @@ -35,7 +35,6 @@ import org.openide.WizardDescriptor; import org.openide.WizardValidationException; import org.openide.util.HelpCtx; import org.sleuthkit.autopsy.casemodule.Case.CaseType; -import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.coreutils.ModuleSettings; /**