1
0
mirror of https://github.com/elisspace/autopsy.git synced 2026-09-06 02:24:30 +00:00

TSK-507: Allow .001 files for single raw file (awaiting GUI feedback)

This commit is contained in:
Dick Fickling
2012-06-22 13:27:38 -04:00
parent 31c64c82f8
commit 58d68d340f
13 changed files with 135 additions and 819 deletions

View File

@@ -60,7 +60,7 @@ public final class AddImageAction extends CallableSystemAction implements Presen
// String: time zone that the image is from
static final String TIMEZONE_PROP = "timeZone";
// String[]: array of paths to each image selected
static final String IMGPATHS_PROP = "imgPaths";
static final String IMGPATH_PROP = "imgPath";
// CleanupTask: task to clean up the database file if wizard errors/is cancelled after it is created
static final String IMAGECLEANUPTASK_PROP = "finalFileCleanup";
// int: the next availble id for a new image

View File

@@ -1,4 +1,4 @@
<?xml version="1.1" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
@@ -6,9 +6,6 @@
</Component>
</NonVisualComponents>
<Properties>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[559, 328]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[588, 328]"/>
</Property>
@@ -31,22 +28,7 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="10" pref="10" max="10" attributes="0"/>
<Component id="noFatOrphansCheckbox" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="imgTypeLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="10" pref="10" max="10" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="rawSplit" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="rawSingle" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="encase" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="multipleSelectLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="imgInfoLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
<Group type="102" alignment="0" attributes="1">
<Component id="timeZoneLabel" min="-2" max="-2" attributes="0"/>
@@ -63,6 +45,10 @@
</Group>
<Component id="optionsLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
<Component id="noFatOrphansCheckbox" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="39" max="32767" attributes="0"/>
</Group>
@@ -73,85 +59,29 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="imgInfoLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
<Component id="imgTypeLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="rawSingle" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="rawSplit" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="encase" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="imgPathLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="imgPathTextField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="imgPathBrowserButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="multipleSelectLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="timeZoneLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="timeZoneComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="optionsLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="noFatOrphansCheckbox" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="18" max="32767" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
<EmptySpace type="separate" max="32767" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JRadioButton" name="rawSingle">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="AddImageVisualPanel1.rawSingle.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="requestFocusEnabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rawSingleActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="10"/>
</AuxValues>
</Component>
<Component class="javax.swing.JRadioButton" name="rawSplit">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="AddImageVisualPanel1.rawSplit.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="requestFocusEnabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rawSplitActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="imgTypeLabel">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="AddImageVisualPanel1.imgTypeLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JRadioButton" name="encase">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="AddImageVisualPanel1.encase.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="requestFocusEnabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="encaseActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="imgPathLabel">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
@@ -159,13 +89,6 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="multipleSelectLabel">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="AddImageVisualPanel1.multipleSelectLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="imgPathTextField">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
@@ -199,16 +122,6 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="33" green="0" red="ff" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/casemodule/Bundle.properties" key="AddImageVisualPanel1.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="timeZoneComboBox">
<Properties>
<Property name="maximumRowCount" type="int" value="30"/>

View File

@@ -19,19 +19,17 @@
package org.sleuthkit.autopsy.casemodule;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
import javax.swing.JCheckBox;
import javax.swing.event.DocumentEvent;
import javax.swing.filechooser.FileFilter;
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.DialogDescriptor;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
/**
* The "Add Image" wizard panel 1. This class is used to design the "form" of
@@ -42,17 +40,19 @@ import org.openide.NotifyDescriptor;
final class AddImageVisualPanel1 extends JPanel implements DocumentListener {
private JFileChooser fc = new JFileChooser();
private FileFilter filter;
static final String[] imgExt = {".img", ".dd"};
static final String imgDesc = "Raw Images (*.img, *.dd)";
static GeneralFilter imgFilter = new GeneralFilter(imgExt, imgDesc, false);
static final String[] splitExt = {".*\\.[0-9][0-9][0-9]", ".*\\.[a-z][a-z]"};
static final String splitDesc = "Split Part (*.001, *.002, etc)";
static GeneralFilter splitFilter = new GeneralFilter(splitExt, splitDesc, true);
static final String[] encasExt = {".*\\.e[0-9][0-9]", ".*\\.e[a-z][a-z]"};
static final List<String> rawExt = Arrays.asList(new String[]{".img", ".dd", ".001", ".aa"});
static final String rawDesc = "Raw Images (*.img, *.dd, *.001, *.aa)";
static GeneralFilter rawFilter = new GeneralFilter(rawExt, rawDesc);
static final List<String> encaseExt = Arrays.asList(new String[]{".e01", ".eaa"});
static final String encaseDesc = "Encase Images (*.e01, *.eAA)";
static GeneralFilter encaseFilter = new GeneralFilter(encasExt, encaseDesc, true);
private boolean multi = false;
static GeneralFilter encaseFilter = new GeneralFilter(encaseExt, encaseDesc);
static final List<String> allExt = new ArrayList<String>();
{
allExt.addAll(rawExt);
allExt.addAll(encaseExt);
}
static final String allDesc = "All Supported Types";
static GeneralFilter allFilter = new GeneralFilter(allExt, allDesc);
private AddImageWizardPanel1 wizPanel;
/**
@@ -62,20 +62,15 @@ final class AddImageVisualPanel1 extends JPanel implements DocumentListener {
AddImageVisualPanel1(AddImageWizardPanel1 wizPanel) {
initComponents();
this.wizPanel = wizPanel;
fc.setDragEnabled(multi);
fc.setDragEnabled(false);
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setMultiSelectionEnabled(multi);
fc.addChoosableFileFilter(imgFilter);
filter = imgFilter;
buttonGroup1.add(encase);
buttonGroup1.add(rawSingle);
buttonGroup1.add(rawSplit);
fc.setMultiSelectionEnabled(false);
fc.addChoosableFileFilter(allFilter);
fc.addChoosableFileFilter(rawFilter);
fc.addChoosableFileFilter(encaseFilter);
fc.setFileFilter(allFilter);
imgPathTextField.getDocument().addDocumentListener(this);
imgPathTextField.setText("");
jLabel1.setText("");
rawSingle.setSelected(true);
rawSplit.setSelected(false);
encase.setSelected(false);
createTimeZoneList();
}
@@ -91,16 +86,16 @@ final class AddImageVisualPanel1 extends JPanel implements DocumentListener {
}
/**
* Gets the array of image paths from the Image Path Text Field.
* Gets the image path from the Image Path Text Field.
*
* @return imagePaths the array of image paths
* @return imagePath the image path
*/
public String[] getImagePaths() {
String[] imgPath = Case.convertImgPath(imgPathTextField.getText());
if (Case.checkMultiplePathExist(imgPath)) {
public String getImagePath() {
String imgPath = imgPathTextField.getText();
if (Case.pathExists(imgPath)) {
return imgPath;
} else {
return new String[0];
return "";
}
}
@@ -115,27 +110,6 @@ final class AddImageVisualPanel1 extends JPanel implements DocumentListener {
boolean getNoFatOrphans() {
return noFatOrphansCheckbox.isSelected();
}
/**
* Gets the type of the image that's selected.
*
* @return imgType the type of the image that selected
*/
public String getImgType() {
if (rawSingle.isSelected()) {
return "Raw Single";
}
if (rawSplit.isSelected()) {
return "Raw Split";
}
if (encase.isSelected()) {
return "EnCase";
} else {
return "Nothing Selected";
}
}
/**
* Gets the time zone that selected on the drop down list.
@@ -197,57 +171,22 @@ final class AddImageVisualPanel1 extends JPanel implements DocumentListener {
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
rawSingle = new javax.swing.JRadioButton();
rawSplit = new javax.swing.JRadioButton();
imgTypeLabel = new javax.swing.JLabel();
encase = new javax.swing.JRadioButton();
imgPathLabel = new javax.swing.JLabel();
multipleSelectLabel = new javax.swing.JLabel();
imgPathTextField = new javax.swing.JTextField();
imgPathBrowserButton = new javax.swing.JButton();
this.imgPathBrowserButton.setDefaultCapable(true);
this.imgPathBrowserButton.requestFocus();
imgInfoLabel = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
timeZoneComboBox = new javax.swing.JComboBox();
timeZoneLabel = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
noFatOrphansCheckbox = new javax.swing.JCheckBox();
optionsLabel1 = new javax.swing.JLabel();
setMinimumSize(new java.awt.Dimension(559, 328));
setPreferredSize(new java.awt.Dimension(588, 328));
org.openide.awt.Mnemonics.setLocalizedText(rawSingle, org.openide.util.NbBundle.getMessage(AddImageVisualPanel1.class, "AddImageVisualPanel1.rawSingle.text")); // NOI18N
rawSingle.setRequestFocusEnabled(false);
rawSingle.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rawSingleActionPerformed(evt);
}
});
org.openide.awt.Mnemonics.setLocalizedText(rawSplit, org.openide.util.NbBundle.getMessage(AddImageVisualPanel1.class, "AddImageVisualPanel1.rawSplit.text")); // NOI18N
rawSplit.setRequestFocusEnabled(false);
rawSplit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rawSplitActionPerformed(evt);
}
});
org.openide.awt.Mnemonics.setLocalizedText(imgTypeLabel, org.openide.util.NbBundle.getMessage(AddImageVisualPanel1.class, "AddImageVisualPanel1.imgTypeLabel.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(encase, org.openide.util.NbBundle.getMessage(AddImageVisualPanel1.class, "AddImageVisualPanel1.encase.text")); // NOI18N
encase.setRequestFocusEnabled(false);
encase.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
encaseActionPerformed(evt);
}
});
org.openide.awt.Mnemonics.setLocalizedText(imgPathLabel, org.openide.util.NbBundle.getMessage(AddImageVisualPanel1.class, "AddImageVisualPanel1.imgPathLabel.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(multipleSelectLabel, org.openide.util.NbBundle.getMessage(AddImageVisualPanel1.class, "AddImageVisualPanel1.multipleSelectLabel.text")); // NOI18N
imgPathTextField.setText(org.openide.util.NbBundle.getMessage(AddImageVisualPanel1.class, "AddImageVisualPanel1.imgPathTextField.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(imgPathBrowserButton, org.openide.util.NbBundle.getMessage(AddImageVisualPanel1.class, "AddImageVisualPanel1.imgPathBrowserButton.text")); // NOI18N
@@ -257,12 +196,9 @@ final class AddImageVisualPanel1 extends JPanel implements DocumentListener {
}
});
imgInfoLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
imgInfoLabel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(imgInfoLabel, org.openide.util.NbBundle.getMessage(AddImageVisualPanel1.class, "AddImageVisualPanel1.imgInfoLabel.text")); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 0, 51));
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(AddImageVisualPanel1.class, "AddImageVisualPanel1.jLabel1.text")); // NOI18N
timeZoneComboBox.setMaximumRowCount(30);
org.openide.awt.Mnemonics.setLocalizedText(timeZoneLabel, org.openide.util.NbBundle.getMessage(AddImageVisualPanel1.class, "AddImageVisualPanel1.timeZoneLabel.text")); // NOI18N
@@ -281,19 +217,7 @@ final class AddImageVisualPanel1 extends JPanel implements DocumentListener {
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(noFatOrphansCheckbox))
.addComponent(imgTypeLabel)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(rawSplit)
.addComponent(rawSingle)
.addComponent(encase)))
.addComponent(multipleSelectLabel)
.addComponent(imgInfoLabel)
.addComponent(jLabel1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(timeZoneLabel)
@@ -306,7 +230,10 @@ final class AddImageVisualPanel1 extends JPanel implements DocumentListener {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(imgPathBrowserButton)))
.addComponent(optionsLabel1)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(noFatOrphansCheckbox)))
.addContainerGap(39, Short.MAX_VALUE))
);
layout.setVerticalGroup(
@@ -314,84 +241,25 @@ final class AddImageVisualPanel1 extends JPanel implements DocumentListener {
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(imgInfoLabel)
.addGap(19, 19, 19)
.addComponent(imgTypeLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(rawSingle)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(rawSplit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(encase)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(imgPathLabel)
.addComponent(imgPathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(imgPathBrowserButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(multipleSelectLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGap(26, 26, 26)
.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))
.addGap(18, 18, 18)
.addComponent(optionsLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(noFatOrphansCheckbox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel1)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(25, 25, 25))
.addGap(18, 18, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(20, 20, 20))
);
}// </editor-fold>//GEN-END:initComponents
/**
* When the "rawSingle" radio button is selected.
*
* @param evt the action event
*/
private void rawSingleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rawSingleActionPerformed
rawSingle.setSelected(true);
rawSplit.setSelected(false);
encase.setSelected(false);
multipleSelectLabel.setText("Single Image: Multiple Select Disabled");
filter = imgFilter;
multi = false;
this.updateUI(null);
}//GEN-LAST:event_rawSingleActionPerformed
/**
* When the "rawSplit" radio button is selected.
*
* @param evt the action event
*/
private void rawSplitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rawSplitActionPerformed
rawSingle.setSelected(false);
rawSplit.setSelected(true);
encase.setSelected(false);
multipleSelectLabel.setText("Split Image: Multiple Select Enabled. Use Ctrl, Shift, "
+ "or Drag to select multiple image parts");
filter = splitFilter;
multi = true;
updateUI(null);
}//GEN-LAST:event_rawSplitActionPerformed
/**
* When the "encase" radio button is selected.
*
* @param evt the action event
*/
private void encaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_encaseActionPerformed
rawSingle.setSelected(false);
rawSplit.setSelected(false);
encase.setSelected(true);
multipleSelectLabel.setText("EnCase Image: Multiple Select Enabled. Use Ctrl, Shift, "
+ "or Drag to select multiple image parts");
filter = encaseFilter;
multi = true;
updateUI(null);
}//GEN-LAST:event_encaseActionPerformed
/**
* When the "Browse" button is pressed, open the file chooser window to
* select the images.
@@ -399,12 +267,7 @@ final class AddImageVisualPanel1 extends JPanel implements DocumentListener {
* @param evt the action event
*/
private void imgPathBrowserButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imgPathBrowserButtonActionPerformed
fc.resetChoosableFileFilters();
fc.addChoosableFileFilter(filter);
fc.setFileFilter(filter);
fc.setMultiSelectionEnabled(multi);
fc.setDragEnabled(multi);
String oldText = imgPathTextField.getText();
// set the current directory of the FileChooser if the ImagePath Field is valid
File currentDir = new File(oldText);
@@ -414,39 +277,8 @@ final class AddImageVisualPanel1 extends JPanel implements DocumentListener {
int retval = fc.showOpenDialog(this);
if (retval == JFileChooser.APPROVE_OPTION) {
File[] files = fc.getSelectedFiles();
String path = "";
if (multi) {
for (File file : files) {
path = path + "\"" + file.getPath() + "\" ";
}
imgPathTextField.setText(path);
} else {
path = fc.getSelectedFile().getPath();
imgPathTextField.setText(path);
}
//if split image, and 1 chunk given, verify it's the first chunk
boolean invalidChunk = false;
String[] imgPath = Case.convertImgPath(imgPathTextField.getText());
if (imgPath.length == 1 && multi == true) {
if (!imgPath[0].matches(".*\\.0.*1$") //001
&& !imgPath[0].matches(".*\\.[aA]{1,}$") //aaa
&& !imgPath[0].matches(".*\\.[eE]{1}0.*1$") //E01
) {
NotifyDescriptor nd = new NotifyDescriptor.Confirmation("You need to select either all chunks or only the first chunk of a split image to add the entire image correctly. Are you sure you want to use this selection?", "Warning: First image chunk not selected", NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.WARNING_MESSAGE);
nd.setValue(NotifyDescriptor.NO_OPTION);
Object res = DialogDisplayer.getDefault().notify(nd);
if (res != null && res == DialogDescriptor.NO_OPTION) {
invalidChunk = true;
}
}
}
if (invalidChunk) {
imgPathTextField.setText(oldText);
return;
}
String path = fc.getSelectedFile().getPath();
imgPathTextField.setText(path);
}
@@ -455,19 +287,13 @@ final class AddImageVisualPanel1 extends JPanel implements DocumentListener {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JRadioButton encase;
private javax.swing.JLabel imgInfoLabel;
private javax.swing.JButton imgPathBrowserButton;
private javax.swing.JLabel imgPathLabel;
private static javax.swing.JTextField imgPathTextField;
private javax.swing.JLabel imgTypeLabel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel multipleSelectLabel;
private javax.swing.JCheckBox noFatOrphansCheckbox;
private javax.swing.JLabel optionsLabel1;
private static javax.swing.JRadioButton rawSingle;
private javax.swing.JRadioButton rawSplit;
private javax.swing.JComboBox timeZoneComboBox;
private javax.swing.JLabel timeZoneLabel;
// End of variables declaration//GEN-END:variables
@@ -514,50 +340,13 @@ final class AddImageVisualPanel1 extends JPanel implements DocumentListener {
* @param e the document event
*/
public void updateUI(DocumentEvent e) {
String[] imgPath = Case.convertImgPath(imgPathTextField.getText());
boolean isExist = Case.checkMultiplePathExist(imgPath);
File imgFile = new File(imgPath[0]);
String imgPath = imgPathTextField.getText();
boolean isExist = Case.pathExists(imgPath);
File imgFile = new File(imgPath);
// check if the given paths exist and those are paths to image files
boolean isImagePath = true;
for (int i = 0; i < imgPath.length; i++) {
File tempImgFile = new File(imgPath[i]);
isImagePath = isImagePath && (Case.isPhysicalDrive(imgPath[i]) || (tempImgFile.exists() && !tempImgFile.isDirectory()
&& (imgFilter.accept(tempImgFile) || splitFilter.accept(tempImgFile)
|| encaseFilter.accept(tempImgFile))));
}
boolean isImagePath = allFilter.accept(imgFile);
if (isImagePath) {
Case currentCase = Case.getCurrentCase();
File dbFile = new File(currentCase.getCaseDirectory() + File.separator + imgFile.getName() + ".db");
if (dbFile.exists()) {
String dbExist = "This database already exists. Do you want to overwrite the database?";
NotifyDescriptor d = new NotifyDescriptor.Confirmation(dbExist, "Warning: Overwrite Database", NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.WARNING_MESSAGE);
d.setValue(NotifyDescriptor.NO_OPTION);
isExist = false;
Object res = DialogDisplayer.getDefault().notify(d);
if (res != null && res == DialogDescriptor.YES_OPTION) {
isExist = dbFile.delete();
if (!isExist) {
jLabel1.setText("*Database for this image is already created and it can't be deleted because it's being used.");
}
}
if (res != null && res == DialogDescriptor.NO_OPTION) {
jLabel1.setText("*Database for this image exist. Either delete it or select another image.");
}
}
} else {
isExist = false;
}
if (isExist) {
jLabel1.setText("");
}
this.wizPanel.enableNextButton(isExist);
this.wizPanel.enableNextButton(isExist && isImagePath);
}
}

View File

@@ -22,20 +22,17 @@ package org.sleuthkit.autopsy.casemodule;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JCheckBox;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.openide.WizardDescriptor;
import org.openide.util.HelpCtx;
import org.openide.util.Lookup;
import org.sleuthkit.autopsy.coreutils.AutopsyPropFile;
import org.sleuthkit.autopsy.coreutils.Log;
/**
* The "Add Image" wizard panel1 handling the logic of selecting image file(s)
@@ -211,18 +208,16 @@ class AddImageWizardPanel1 implements WizardDescriptor.Panel<WizardDescriptor>,
*/
@Override
public void storeSettings(WizardDescriptor settings) {
settings.putProperty(AddImageAction.IMGPATHS_PROP, getComponent().getImagePaths());
settings.putProperty(AddImageAction.IMGPATH_PROP, getComponent().getImagePath());
settings.putProperty(AddImageAction.TIMEZONE_PROP, getComponent().getSelectedTimezone()); // store the timezone
settings.putProperty(AddImageAction.NOFATORPHANS_PROP, Boolean.valueOf(getComponent().getNoFatOrphans()));
//settings.putProperty(AddImageAction.LOOKUPFILES_PROP, getComponent().getLookupFilesCheckboxChecked());
//settings.putProperty(AddImageAction.SOLR_PROP, getComponent().getIndexImageCheckboxChecked());
// Store the path to the first image selected into the properties file
if(getComponent().getImagePaths().length > 0){
String firstImage = getComponent().getImagePaths()[0];
String firstImagePath = firstImage.substring(0, firstImage.lastIndexOf(File.separator)+1);
AutopsyPropFile.getInstance().setProperty(PROP_LASTIMAGE, firstImagePath);
}
String firstImage = getComponent().getImagePath();
String firstImagePath = firstImage.substring(0, firstImage.lastIndexOf(File.separator) + 1);
AutopsyPropFile.getInstance().setProperty(PROP_LASTIMAGE, firstImagePath);
}

View File

@@ -50,7 +50,7 @@ import org.sleuthkit.datamodel.TskException;
class AddImageWizardPanel2 implements WizardDescriptor.Panel<WizardDescriptor> {
// the paths of the image files to be added
private String[] imgPaths;
private String imgPath;
// the time zone where the image is added
private String timeZone;
//whether to not process FAT filesystem orphans
@@ -190,7 +190,7 @@ class AddImageWizardPanel2 implements WizardDescriptor.Panel<WizardDescriptor> {
public void readSettings(WizardDescriptor settings) {
cleanupImage = null;
imgAdded = false;
imgPaths = (String[]) settings.getProperty(AddImageAction.IMGPATHS_PROP);
imgPath = (String) settings.getProperty(AddImageAction.IMGPATH_PROP);
timeZone = settings.getProperty(AddImageAction.TIMEZONE_PROP).toString();
noFatOrphans = ((Boolean) settings.getProperty(AddImageAction.NOFATORPHANS_PROP)).booleanValue();
@@ -278,7 +278,7 @@ class AddImageWizardPanel2 implements WizardDescriptor.Panel<WizardDescriptor> {
process = currentCase.makeAddImageProcess(timeZone, true, noFatOrphans);
cancelledWhileRunning.enable();
try {
process.run(imgPaths);
process.run(new String[]{imgPath});
} catch (TskCoreException ex) {
logger.log(Level.WARNING, "Errors occurred while running add image. ", ex);
//critical core/system error and process needs to be interrupted

View File

@@ -178,7 +178,7 @@ class AddImageWizardPanel3 implements WizardDescriptor.Panel<WizardDescriptor> {
*/
private void commitImage(WizardDescriptor settings) throws Exception {
String[] imgPaths = (String[]) settings.getProperty(AddImageAction.IMGPATHS_PROP);
String imgPath = (String) settings.getProperty(AddImageAction.IMGPATH_PROP);
String timezone = settings.getProperty(AddImageAction.TIMEZONE_PROP).toString();
settings.putProperty(AddImageAction.IMAGEID_PROP, "");
SleuthkitJNI.CaseDbHandle.AddImageProcess process = (SleuthkitJNI.CaseDbHandle.AddImageProcess) settings.getProperty(AddImageAction.PROCESS_PROP);
@@ -196,7 +196,7 @@ class AddImageWizardPanel3 implements WizardDescriptor.Panel<WizardDescriptor> {
SleuthkitCase.dbWriteUnlock();
if (imageId != 0) {
newImage = Case.getCurrentCase().addImage(imgPaths, imageId, timezone);
newImage = Case.getCurrentCase().addImage(imgPath, imageId, timezone);
settings.putProperty(AddImageAction.IMAGEID_PROP, imageId);
}

View File

@@ -92,14 +92,8 @@ AddImageVisualPanel2.crDbLabel.text=Adding Image
AddImageVisualPanel2.jLabel5.text=Processing Image and Adding to Database :
AddImageVisualPanel2.progressLabel.text=
AddImageVisualPanel2.jLabel1.text=<html> We are now analyzing the disk image to extract volume and file system data and populate a local database. </html>
AddImageVisualPanel1.jLabel1.text=
AddImageVisualPanel1.timeZoneLabel.text=Please select the image timezone:
AddImageVisualPanel1.rawSingle.text=Raw Single (*.img, *.dd, etc)
AddImageVisualPanel1.rawSplit.text=Raw Split (*.001, *.002, *.aa, *.ab, etc)
AddImageVisualPanel1.imgTypeLabel.text=Image Type:
AddImageVisualPanel1.multipleSelectLabel.text=Single Image: Multiple Select Disabled
AddImageVisualPanel1.imgPathTextField.text=
AddImageVisualPanel1.encase.text=EnCase (*.e01, *.e02, etc)
AddImageVisualPanel1.imgPathLabel.text=Image Path:
AddImageVisualPanel1.imgPathBrowserButton.text=Browse
NewJPanel.jLabel1.text=

View File

@@ -242,10 +242,15 @@ public class Case {
}
}
Map<Long, List<String>> getImagePaths() {
Map<Long, List<String>> imgPaths = new HashMap<Long, List<String>>();
static Map<Long, String> getImagePaths(SleuthkitCase db) { //TODO: clean this up
Map<Long, String> imgPaths = new HashMap<Long, String>();
try {
imgPaths = db.getImagePaths();
Map<Long, List<String>> imgPathsList = db.getImagePaths();
for(Map.Entry<Long, List<String>> entry : imgPathsList.entrySet()) {
if(entry.getValue().size() > 0) {
imgPaths.put(entry.getKey(), entry.getValue().get(0));
}
}
} catch (TskException ex) {
Logger.getLogger(Case.class.getName()).log(Level.WARNING, "Error getting image paths", ex);
}
@@ -253,58 +258,37 @@ public class Case {
}
/**
* Ensure that all image paths point to valid image files
*/
private static void checkImagesExist(SleuthkitCase db) {
Map<Long, List<String>> imgPaths = new HashMap<Long, List<String>>();
try {
imgPaths = db.getImagePaths();
} catch (TskException ex) {
Logger.getLogger(Case.class.getName()).log(Level.WARNING, "Error getting image paths", ex);
}
for (Map.Entry<Long, List<String>> entry : imgPaths.entrySet()) {
* Ensure that all image paths point to valid image files
*/
private static void checkImagesExist(SleuthkitCase db) {
Map<Long, String> imgPaths = getImagePaths(db);
for (Map.Entry<Long, String> entry : imgPaths.entrySet()) {
JFileChooser fc = new JFileChooser();
FileFilter filter;
long obj_id = entry.getKey();
List<String> paths = entry.getValue();
boolean allFilesExist = true;
String pathString = "";
for (String s : paths) {
allFilesExist &= isPhysicalDrive(s) || new File(s).exists();
pathString += s + "\n";
}
if (!allFilesExist) {
File f = new File(paths.get(0));
if (AddImageVisualPanel1.encaseFilter.accept(f)) {
filter = AddImageVisualPanel1.encaseFilter;
} else if (AddImageVisualPanel1.splitFilter.accept(f)) {
filter = AddImageVisualPanel1.splitFilter;
} else {
filter = AddImageVisualPanel1.imgFilter;
}
fc.setMultiSelectionEnabled(true);
String path = entry.getValue();
boolean fileExists = pathExists(path);
if (!fileExists) {
filter = AddImageVisualPanel1.allFilter;
fc.setMultiSelectionEnabled(false);
fc.setFileFilter(filter);
int ret = JOptionPane.showConfirmDialog(null, appName + " has detected that one or more of the images associated with \n"
int ret = JOptionPane.showConfirmDialog(null, appName + " has detected that one of the images associated with \n"
+ "this case are missing. Would you like to search for them now?\n"
+ "Previously, the image(s) were located at:\n" + pathString
+ "Previously, the image was located at:\n" + path
+ "\nPlease note that you will still be able to browse directories and generate reports\n"
+ "if you choose No, but you will not be able to view file content or run the ingest process.", "Missing Images", JOptionPane.YES_NO_OPTION);
+ "if you choose No, but you will not be able to view file content or run the ingest process.", "Missing Image", JOptionPane.YES_NO_OPTION);
if (ret == JOptionPane.YES_OPTION) {
fc.showOpenDialog(null);
if (fc.getSelectedFiles().length == paths.size()) { //TODO: this is the extent of our equality checking...we should do more.
List<String> newPaths = new ArrayList<String>();
for (File newFile : fc.getSelectedFiles()) {
newPaths.add(newFile.getPath());
}
try {
db.setImagePaths(obj_id, newPaths);
} catch (TskException ex) {
Logger.getLogger(Case.class.getName()).log(Level.WARNING, "Error setting image paths", ex);
}
} else {
Logger.getLogger(Case.class.getName()).log(Level.WARNING, "Selected image files don't match old files!");
String newPath = fc.getSelectedFile().getPath();
try {
db.setImagePaths(obj_id, Arrays.asList(new String[]{newPath}));
} catch (TskException ex) {
Logger.getLogger(Case.class.getName()).log(Level.WARNING, "Error setting image paths", ex);
}
} else {
Logger.getLogger(Case.class.getName()).log(Level.WARNING, "Selected image files don't match old files!");
}
}
}
}
@@ -316,12 +300,10 @@ public class Case {
* @param imgId the ID of the image that being added
* @param timeZone the timeZone of the image where it's added
*/
Image addImage(String[] imgPaths, long imgId, String timeZone) throws Exception {
Log.get(this.getClass()).log(Level.INFO, "Adding image to Case. imgPaths: {0} ID: {1} TimeZone: {2}", new Object[]{Arrays.toString(imgPaths), imgId, timeZone});
Image addImage(String imgPath, long imgId, String timeZone) throws Exception {
Log.get(this.getClass()).log(Level.INFO, "Adding image to Case. imgPath: {0} ID: {1} TimeZone: {2}", new Object[]{imgPath, imgId, timeZone});
try {
xmlcm.addImage(imgPaths, imgId, timeZone); // add the image to the document handler in the XML class and to the config file
xmlcm.writeFile(); // write any changes to the config file
Image newImage = db.getImageById(imgId);
pcs.firePropertyChange(CASE_ADD_IMAGE, null, newImage); // the new value is the instance of the image
doAddImage();
@@ -434,46 +416,6 @@ public class Case {
}
}
// Not dealing with removing images for now.
// /**
// * Removes the image from this case
// *
// * @param givenID the ID of the image to be removed
// * @param givenPath the path of the image to be removed
// */
// void removeImage(int givenID, String givenPath) throws Exception {
// Log.get(this.getClass()).log(Level.FINE, "Removing image.\ngivenID: {0}\ngivenPath: {1}", new Object[] {givenID, givenPath});
//
// String[] tempPaths = xmlcm.getImageSet(givenID);
// String tempDb = xmlcm.getImageSetDbPath(givenID);
//
// if (tempPaths[0].equals(givenPath)) {
// xmlcm.removeImageSet(givenID); // make the changes in the config file
// try {
// xmlcm.writeFile();
// } catch (Exception ex) {
// throw new Exception("Error while trying to remove the image from this case.", ex);
// }
//
// Image img = imageIdToData.get(givenID).image; // save the image that we want to delete temporarily
//
// imageIdToData.remove(givenID);
//
// pcs.firePropertyChange(CASE_DEL_IMAGE, givenID, img); // the old value is the image ID that removed, the new value is the instance of the image
//
// img.getSleuthkit().closeConnection(); // to make sure that we close the connection
//
// // need to remove the database as well??
// File database = new File(tempDb);
// boolean test = database.delete(); // delete the database of the image that we remove
// if (!test) {
// database.deleteOnExit(); // delete on exit if the delete is not successful
// }
// } else {
// // throw an error here
// Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Couldn't remove image.", new Exception("Couldn't find the image in this case."));
// }
// }
/**
* Checks whether there is a current case open.
*
@@ -597,9 +539,8 @@ public class Case {
return pcs;
}
String[] getImagePaths(Long imgID) {
List<String> paths = getImagePaths().get(imgID);
return paths.toArray(new String[paths.size()]);
String getImagePaths(Long imgID) {
return getImagePaths(db).get(imgID);
}
/**
@@ -607,7 +548,7 @@ public class Case {
* @return imageIDs
*/
public Long[] getImageIDs() {
Set<Long> ids = getImagePaths().keySet();
Set<Long> ids = getImagePaths(db).keySet();
return ids.toArray(new Long[ids.size()]);
}
@@ -637,11 +578,15 @@ public class Case {
* @return time zones the set of time zones
*/
public Set<TimeZone> getTimeZone() {
if (xmlcm == null) {
return new HashSet<TimeZone>();
} else {
return xmlcm.getTimeZone();
Set<TimeZone> timezones = new HashSet<TimeZone>();
for(Content c : getRootObjects()) {
try {
timezones.add(TimeZone.getTimeZone(c.getImage().getTimeZone()));
} catch (TskException ex) {
Logger.getLogger(Case.class.getName()).log(Level.INFO, "Error getting time zones", ex);
}
}
return timezones;
}
public static synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
@@ -653,73 +598,24 @@ public class Case {
}
/**
* convert the image Path to array string
* @param imgPath the image path
* @return imgPath the converted image path
* Check if image from the given image path exists.
* @param imgPath the image path
* @return isExist whether the path exists
*/
public static String[] convertImgPath(String imgPath) {
String[] result;
String unsplitPaths = imgPath;
int count = 0;
for (int i = 0; i < unsplitPaths.length(); i++) {
if (unsplitPaths.charAt(i) == '\"') {
count++;
}
}
if (count != 0) {
result = new String[count / 2];
int start = 0;
int current = 0;
for (int i = 0; i < count / 2; i++) {
while (unsplitPaths.charAt(current) != '\"') {
current++;
}
start = current;
current++;
while (unsplitPaths.charAt(current) != '\"') {
current++;
}
result[i] = unsplitPaths.substring(start + 1, current);
current++;
}
} else {
result = new String[1];
result[0] = unsplitPaths;
}
return result;
}
/**
* Check if all the images from the given image path exist.
* @param imgPaths the image paths
* @return isExist whether the multiple paths exist
*/
public static boolean checkMultiplePathExist(String[] imgPaths) {
boolean result = false;
int totalLength = imgPaths.length;
if (totalLength > 0) {
result = true;
for (int i = 0; i < totalLength; i++) {
String path = imgPaths[i];
if (!new File(path).exists() && !isPhysicalDrive(path)) {
result = false;
break;
}
}
}
return result;
public static boolean pathExists(String imgPath) {
return new File(imgPath).isFile() || isPhysicalDrive(imgPath);
}
/**
* Does the given string refer to a physical drive?
*/
private static String pdisk = "\\\\.\\physicaldrive";
private static final String pdisk = "\\\\.\\physicaldrive";
private static final String dev = "/dev/";
static boolean isPhysicalDrive(String path) {
int endIndex = Math.min(path.length(), pdisk.length());
return path.substring(0, endIndex).toLowerCase().equals(pdisk);
int pdiskEnd = Math.min(path.length(), pdisk.length());
int devEnd = Math.min(path.length(), dev.length());
return path.substring(0, pdiskEnd).toLowerCase().equals(pdisk) ||
path.substring(0, devEnd).toLowerCase().equals(dev);
}
/**

View File

@@ -23,6 +23,7 @@ import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Collections;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
@@ -43,7 +44,7 @@ public final class CaseOpenAction implements ActionListener {
AutopsyPropFile AutopsyProperties = AutopsyPropFile.getInstance();
JFileChooser fc = new JFileChooser();
GeneralFilter autFilter = new GeneralFilter(new String[]{".aut"}, "AUTOPSY File (*.aut)", false);
GeneralFilter autFilter = new GeneralFilter(Collections.<String>singletonList(".aut"), "AUTOPSY File (*.aut)");
/** The constructor */
public CaseOpenAction() {

View File

@@ -77,7 +77,7 @@ public final class CasePropertiesAction extends CallableSystemAction {
int totalImage = currentCase.getRootObjectsCount();
// put the image paths information into hashmap
Map<Long, List<String>> imgPaths = currentCase.getImagePaths();
Map<Long, String> imgPaths = currentCase.getImagePaths(currentCase.getSleuthkitCase());
// create the case properties form
CasePropertiesForm cpf = new CasePropertiesForm(currentCase, crDate, caseDir, imgPaths);

View File

@@ -76,7 +76,7 @@ class CasePropertiesForm extends javax.swing.JPanel{
/** Creates new form CasePropertiesForm */
CasePropertiesForm(Case currentCase, String crDate, String caseDir, Map<Long, List<String>> imgPaths) {
CasePropertiesForm(Case currentCase, String crDate, String caseDir, Map<Long, String> imgPaths) {
initComponents();
caseNameTextField.setText(currentCase.getName());
caseNumberTextField.setText(currentCase.getNumber());
@@ -94,7 +94,7 @@ class CasePropertiesForm extends javax.swing.JPanel{
int i = 0;
for(long key : imgPaths.keySet()){
String path = imgPaths.get(key).get(0);
String path = imgPaths.get(key);
String shortenPath = shrinkPath(path, 70);
rows[i++] = new String[]{shortenPath};
}

View File

@@ -20,7 +20,7 @@
package org.sleuthkit.autopsy.casemodule;
import java.io.File;
import java.util.regex.Pattern;
import java.util.List;
import javax.swing.filechooser.FileFilter;
/**
@@ -28,14 +28,12 @@ import javax.swing.filechooser.FileFilter;
*/
public class GeneralFilter extends FileFilter{
String[] ext;
List<String> extensions;
String desc;
boolean isMultiple; // whether the filter can accept multiple files.
public GeneralFilter(String[] ext, String desc, boolean isMultiple){
this.ext = ext;
public GeneralFilter(List<String> ext, String desc){
this.extensions = ext;
this.desc = desc;
this.isMultiple = isMultiple;
}
/**
@@ -48,23 +46,13 @@ public class GeneralFilter extends FileFilter{
public boolean accept(File f) {
if(f.isDirectory()){
return true;
}
else{
} else {
Boolean result = false;
String name = f.getName().toLowerCase();
if(isMultiple){
for(int i = 0; i < ext.length; i++){
String regex = ext[i];
if (Pattern.matches(regex, name)){
result = result || true;
}
}
}
else{
for(int i = 0; i < ext.length; i++){
if (name.endsWith(ext[i]))
result = result || true;
for (String ext : extensions) {
if (name.endsWith(ext)) {
result = result || true;
}
}
return result;

View File

@@ -59,19 +59,6 @@ public class XMLCaseManagement implements CaseConfigFileInterface{
final static String AUTOPSY_CRVERSION_NAME = "AutopsyCreatedVersion";
final static String AUTOPSY_MVERSION_NAME = "AutopsySavedVersion";
// disk image paths
final static String IMAGES_NAME = "Images";
final static String IMG_SET_NAME = "ImgSet";
final static String IMG_PATH_NAME = "ImgPath";
final static String IMG_DB_NAME = "ImgDb";
final static String NEXT_ID_NAME = "NextID";
// image attribute
final static String IMG_SET_COUNT = "count";
final static String IMG_SET_ID = "id";
final static String IMG_PATH_ID = "idx";
final static String TIMEZONE = "timezone";
// folders inside case directory
final static String LOG_FOLDER_NAME = "LogFolder";
final static String LOG_FOLDER_RELPATH = "Log";
@@ -473,196 +460,6 @@ public class XMLCaseManagement implements CaseConfigFileInterface{
}
}
/**
* Gets image Element from the document handler
*
* @return imageElement the "Image" element
*/
private Element getImagesElement(){
if(doc != null){
return (Element) doc.getElementsByTagName(IMAGES_NAME).item(0);
}
else{
return null; // should throw error or exception
}
}
//
// /**
// * Looks up for the Image Set Element in the document handler with the given
// * image ID.
// *
// * @param id the image ID
// * @return element the "ImageSet" element
// */
// protected Element getImageSetElement(int id){
// if(doc != null){
// Element result = null;
// int totalImageSet = getImageSetCount();
//
// for(int i = 0; i < totalImageSet; i++){
// Element imageSetElement = (Element)getImagesElement().getElementsByTagName(IMG_SET_NAME).item(i);
// int imgSetID = Integer.parseInt(imageSetElement.getAttribute(IMG_SET_ID));
// if(id == imgSetID){
// result = imageSetElement;
// }
// }
// return result;
// }
// else{
// return null; //TODO: should throw error or exception
// }
// }
//
// /**
// * Sets the ImgDb entry for corresponding image set in the document handler
// *
// * @param id the image ID
// * @param path the image path
// */
// protected void setImageSetDbPath(int id, String path){
// Element imgDbElement = (Element) getImageSetElement(id).getElementsByTagName(IMG_DB_NAME).item(0);
// imgDbElement.setTextContent(path);
// imgDbElement.setAttribute(RELATIVE_NAME, RELATIVE_TRUE); // depends on the path (relative or not)
//
// // if need to write the XML file immidiately, uncomment the code below
// // writeFile();
// }
//
/**
* Returns number of image sets in this case
*
* @return imageSetCount total number of imageSet in this case
*/
protected int getImageSetCount(){
return getImagesElement().getElementsByTagName(IMG_SET_NAME).getLength();
}
//
// /**
// * Returns a set of image paths of the given image ID in this case
// *
// * @param id the image ID
// * @return imagePaths the image paths of the given imageID
// */
// protected String[] getImageSet(int id){
// Element imgSetElement = getImageSetElement(id);
// int totalImagePaths = imgSetElement.getElementsByTagName(IMG_PATH_NAME).getLength(); // or use the attribute count
// String[] result = new String[totalImagePaths];
//
// for(int i = 0; i < totalImagePaths; i++){
// Element imgPathElement = (Element) imgSetElement.getElementsByTagName(IMG_PATH_NAME).item(i);
// if(imgPathElement.getAttribute(RELATIVE_NAME).equals(RELATIVE_TRUE)){
// result[i] = caseDirPath + File.separator + imgPathElement.getTextContent();
// }
// else{
// result[i] = imgPathElement.getTextContent();
// }
// }
// return result;
// }
//
// /**
// * Returns absolute path of image database of the given image ID.
// *
// * @param id the image ID
// * @return dbPath the database path of the given image
// */
// protected String getImageSetDbPath(int id){
// Element imgDbElement = (Element) getImageSetElement(id).getElementsByTagName(IMG_DB_NAME).item(0);
// if(imgDbElement.getAttribute(RELATIVE_NAME).equals(RELATIVE_TRUE)){
// return caseDirPath + File.separator + imgDbElement.getTextContent();
// }
// else{
// return imgDbElement.getTextContent();
// }
// }
//
// /**
// * Gets the next free image ID and and increments the internal counter
// *
// * @return imageID the next free image ID
// */
// @Override
// public int getNextImageID(){
// Element imgElement = getImagesElement();
// if(imgElement == null){
// return -1; // which indicates the error
// }
// else{
// String nextID = imgElement.getAttribute(NEXT_ID_NAME);
// int result = Integer.parseInt(nextID);
//
// // increment the nextID
// int incNextID = result + 1;
// getImagesElement().setAttribute(NEXT_ID_NAME, Integer.toString(incNextID));
//
// // write the change to the config file immediately
// try{
// writeFile();
// }
// catch(Exception ex){
// // TODO: throw exception further up
// Logger logger = Logger.getLogger(this.className);
// logger.log(Level.WARNING, "Error while trying to write the new NextID to the config file.", ex);
// }
//
// return result;
// }
// }
//
// /**
// * Returns an array of all image ID values in this case.
// *
// * @return imageIDs array of all image IDs in this case
// */
// @Override
// public int[] getImageIDs() {
// int totalImageSet = getImageSetCount();
// int[] result = new int[totalImageSet];
//
// Element imgElement = getImagesElement();
// for(int i = 0; i < totalImageSet; i++){
// Element imgSetElement = (Element)imgElement.getElementsByTagName(IMG_SET_NAME).item(i);
// result[i] = Integer.parseInt(imgSetElement.getAttribute(IMG_SET_ID));
// }
//
// return result;
// }
//
// /**
// * Returns the HashSet of all timezone values of all images in this case.
// *
// * @return imageIDs the HashSet of all timezone values
// */
public HashSet<TimeZone> getTimeZone() {
HashSet<TimeZone> result = new HashSet<TimeZone>();
int totalImageSet = getImageSetCount();
Element imgElement = getImagesElement();
for(int i = 0; i < totalImageSet; i++){
Element imgSetElement = (Element)imgElement.getElementsByTagName(IMG_SET_NAME).item(i);
result.add(TimeZone.getTimeZone(imgSetElement.getAttribute(TIMEZONE)));
}
return result; //TODO: get time zones from db
}
//
// /**
// * Removes the imageSet of the given image ID.
// *
// * @param imgID the image ID of the image that going to be removed
// */
// public void removeImageSet(int imgID) {
// Element imgElement = getImagesElement();
// Element selectedElement = getImageSetElement(imgID);
// imgElement.removeChild(selectedElement); // remove the imagesetElement
// doc.normalize();
//
// // edit the modified data
// String newDate = dateFormat.format(new Date());
// Element rootEl = getRootElement();
// rootEl.getElementsByTagName(MODIFIED_DATE_NAME).item(0).setTextContent(newDate);
// }
/**
* Initialize the basic values for a new case management file.
* Note: this is the schema version 1.0
@@ -748,11 +545,6 @@ public class XMLCaseManagement implements CaseConfigFileInterface{
cacheElement.setAttribute(RELATIVE_NAME, "true");
caseElement.appendChild(cacheElement);
// create the new images
Element imagesElement = doc.createElement(IMAGES_NAME); // <Images> ... </Images>
imagesElement.setAttribute(NEXT_ID_NAME, Integer.toString(0)); // add nextID to 0
rootElement.appendChild(imagesElement);
// write more code if needed ...
}
@@ -894,56 +686,4 @@ public class XMLCaseManagement implements CaseConfigFileInterface{
examiner = "";
}
/**
* Adds the image to the current document handler.
*
* @param images the paths of the images that want to be added
* @param currentID the ID of the image that want to be added
* @param timeZone the timeZone where the image is added
*/
protected void addImage(String[] images, long currentID, String timeZone) throws Exception {
//String dbName = "image-" + currentID + ".db";
if (doc == null) {
throw new Exception("No case open.");
} else {
Element rootEl = getRootElement();
int imgCount = images.length; // how many given images to add to the config file
Element imagesElement = getImagesElement();
//int currentID = Integer.parseInt(imagesElement.getAttribute(NEXT_ID_NAME));
// add the latest image set
Element imgSetElement = doc.createElement(IMG_SET_NAME); // <ImgSet> ... </ImgSet>
imgSetElement.setAttribute(IMG_SET_COUNT, Integer.toString(imgCount));
imgSetElement.setAttribute(IMG_SET_ID, Long.toString(currentID));
imgSetElement.setAttribute(TIMEZONE, timeZone);
imagesElement.appendChild(imgSetElement);
// add all the image Path
// for (int i = 0; i < imgCount; i++) {
// Element imgPathElement = doc.createElement(IMG_PATH_NAME); // <ImgPath> ... </ImgPath>
// imgPathElement.setAttribute(IMG_PATH_ID, Integer.toString(i));
// imgPathElement.setAttribute(RELATIVE_NAME, "false");
// imgPathElement.appendChild(doc.createTextNode(images[i]));
// imgSetElement.appendChild(imgPathElement);
// }
//
// // add the database
// Element imgDbElement = doc.createElement(IMG_DB_NAME); // <ImgDb> ... </ImgDb>
// imgDbElement.setAttribute(RELATIVE_NAME, "true");
// imgDbElement.appendChild(doc.createTextNode(dbName));
// //imgDbElement.appendChild(doc.createTextNode("image-" + currentID + ".db"));
// imgSetElement.appendChild(imgDbElement);
// edit the modified data
String newDate = dateFormat.format(new Date());
rootEl.getElementsByTagName(MODIFIED_DATE_NAME).item(0).setTextContent(newDate);
}
// JOptionPane.showMessageDialog(caller, "Error while trying to add the image to XML config file.\n \nDetail: \n" + e.getMessage() + " (at " + className + ").", "Error", JOptionPane.ERROR_MESSAGE);
}
}