mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Removed unused ImportCentralRepoDatabaseDialog
Starting cleanup
This commit is contained in:
parent
bfa9502fa2
commit
b1fb068cc1
@ -34,9 +34,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager;
|
||||
import org.sleuthkit.datamodel.TskData;
|
||||
|
||||
/**
|
||||
@ -1306,15 +1304,11 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
*/
|
||||
@Override
|
||||
public boolean referenceSetIsValid(int centralRepoIndex, String hashSetName, String version) throws EamDbException{
|
||||
System.out.println("###\nChecking if " + centralRepoIndex + " : " + hashSetName + " " + version + " is valid");
|
||||
EamGlobalSet refSet = this.getReferenceSetByID(centralRepoIndex);
|
||||
if(refSet == null){
|
||||
System.out.println(" Not valid - no matching index");
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean res = refSet.getSetName().equals(hashSetName) && refSet.getVersion().equals(version);
|
||||
System.out.println(" res: " + res + " (" + refSet.getSetName() + ", " + refSet.getVersion() + ")");
|
||||
return(refSet.getSetName().equals(hashSetName) && refSet.getVersion().equals(version));
|
||||
}
|
||||
|
||||
|
@ -1,286 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Component class="javax.swing.ButtonGroup" name="buttonGroup1">
|
||||
</Component>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<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="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="okButton" linkSize="1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cancelButton" linkSize="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="lbWarningMsg" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="lbDatabasePath" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lbDatabaseName" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="tfFilePath" min="-2" pref="277" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="openButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="tfDatabaseName" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="lbDatabaseType" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="knownRadioButton" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="knownBadRadioButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="lbDatabaseVersion" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="tfDatabaseVersion" min="-2" pref="154" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="lbSourceOrganization" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="comboboxSourceOrganization" min="-2" pref="98" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="bnNewOrganization" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="cbInboxMessages" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="openButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="tfFilePath" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lbDatabasePath" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="lbDatabaseName" alignment="3" min="-2" pref="20" max="-2" attributes="0"/>
|
||||
<Component id="tfDatabaseName" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="lbDatabaseVersion" alignment="3" min="-2" pref="20" max="-2" attributes="0"/>
|
||||
<Component id="tfDatabaseVersion" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="lbSourceOrganization" alignment="3" min="-2" pref="20" max="-2" attributes="0"/>
|
||||
<Component id="comboboxSourceOrganization" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="bnNewOrganization" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="9" max="32767" attributes="0"/>
|
||||
<Component id="lbDatabaseType" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="knownRadioButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="knownBadRadioButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cbInboxMessages" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="117" max="-2" attributes="0"/>
|
||||
<Component id="lbWarningMsg" min="-2" pref="23" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="okButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="ImportCentralRepoDatabaseDialog.okButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="cancelButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="ImportCentralRepoDatabaseDialog.cancelButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="tfFilePath">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="ImportCentralRepoDatabaseDialog.tfFilePath.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="openButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="ImportCentralRepoDatabaseDialog.openButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="openButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="knownRadioButton">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="buttonGroup1"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="ImportCentralRepoDatabaseDialog.knownRadioButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="knownBadRadioButton">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="buttonGroup1"/>
|
||||
</Property>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="ImportCentralRepoDatabaseDialog.knownBadRadioButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lbDatabaseType">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="ImportCentralRepoDatabaseDialog.lbDatabaseType.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lbDatabasePath">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="ImportHashDatabaseDialog.lbFilePath.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lbSourceOrganization">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="ImportCentralRepoDatabaseDialog.lbSourceOrganization.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lbDatabaseName">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="ImportCentralRepoDatabaseDialog.lbDatabaseName.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lbDatabaseVersion">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="ImportCentralRepoDatabaseDialog.lbDatabaseVersion.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="comboboxSourceOrganization">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="4">
|
||||
<StringItem index="0" value="Item 1"/>
|
||||
<StringItem index="1" value="Item 2"/>
|
||||
<StringItem index="2" value="Item 3"/>
|
||||
<StringItem index="3" value="Item 4"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboboxSourceOrganizationActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="tfDatabaseName">
|
||||
<Properties>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="ImportHashDatabaseDialog.tfDatabaseName.tooltip" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="tfDatabaseVersion">
|
||||
<Properties>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="ImportHashDatabaseDialog.tfDatabaseVersion.tooltip.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="bnNewOrganization">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="ImportCentralRepoDatabaseDialog.bnNewOrganization.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="bnNewOrganizationActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lbWarningMsg">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Tahoma" size="12" style="1"/>
|
||||
</Property>
|
||||
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="0" green="0" red="ff" type="rgb"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="cbInboxMessages">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="ImportCentralRepoDatabaseDialog.cbInboxMessages.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -1,693 +0,0 @@
|
||||
/*
|
||||
* Central Repository
|
||||
*
|
||||
* Copyright 2015-2017 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.centralrepository.optionspanel;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Toolkit;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.file.Files;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import org.netbeans.api.progress.ProgressHandle;
|
||||
import org.netbeans.spi.options.OptionsPanelController;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.openide.windows.WindowManager;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttribute;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamGlobalFileInstance;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamGlobalSet;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamOrganization;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb;
|
||||
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager;
|
||||
import org.sleuthkit.datamodel.TskData;
|
||||
|
||||
/**
|
||||
* Instances of this class allow a user to select an existing hash database and
|
||||
* add it to the set of hash databases used to classify files as unknown, known,
|
||||
* or notable.
|
||||
*/
|
||||
final public class ImportCentralRepoDatabaseDialog extends javax.swing.JDialog {
|
||||
private static final Logger LOGGER = Logger.getLogger(ImportCentralRepoDatabaseDialog.class.getName());
|
||||
|
||||
private final JFileChooser fileChooser = new JFileChooser();
|
||||
private final static String LAST_FILE_PATH_KEY = "CentralRepositoryImport_Path"; // NON-NLS
|
||||
private final int HASH_IMPORT_THRESHOLD = 10000;
|
||||
private EamOrganization selectedOrg = null;
|
||||
private List<EamOrganization> orgs = null;
|
||||
private final Collection<JTextField> textBoxes;
|
||||
private final TextBoxChangedListener textBoxChangedListener;
|
||||
private HashDbManager.HashDatabase selectedHashDb = null;
|
||||
|
||||
|
||||
/**
|
||||
* Displays a dialog that allows a user to select an existing hash database
|
||||
* and add it to the set of hash databases used to classify files as
|
||||
* unknown, known, or notable.
|
||||
*/
|
||||
@Messages({"ImportHashDatabaseDialog.importHashDbMsg=Import Hash Database"})
|
||||
public ImportCentralRepoDatabaseDialog() {
|
||||
super((JFrame) WindowManager.getDefault().getMainWindow(),
|
||||
Bundle.ImportHashDatabaseDialog_importHashDbMsg(),
|
||||
true); // NON-NLS
|
||||
textBoxes = new ArrayList<>();
|
||||
textBoxChangedListener = new TextBoxChangedListener();
|
||||
initFileChooser();
|
||||
initComponents();
|
||||
customizeComponents();
|
||||
display();
|
||||
}
|
||||
|
||||
@Messages({"ImportHashDatabaseDialog.fileNameExtFilter.text=Hash Database File",})
|
||||
private void initFileChooser() {
|
||||
fileChooser.setDragEnabled(false);
|
||||
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
String[] EXTENSION = new String[]{"idx"}; //NON-NLS
|
||||
FileNameExtensionFilter filter = new FileNameExtensionFilter(
|
||||
Bundle.ImportHashDatabaseDialog_fileNameExtFilter_text(),
|
||||
EXTENSION); // NON-NLS
|
||||
fileChooser.setFileFilter(filter);
|
||||
fileChooser.setMultiSelectionEnabled(false);
|
||||
|
||||
if (ModuleSettings.settingExists(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY)) {
|
||||
String lastBaseDirectory = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY);
|
||||
File hashDbFolder = new File(lastBaseDirectory);
|
||||
if(hashDbFolder.exists()){
|
||||
fileChooser.setCurrentDirectory(hashDbFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void customizeComponents() {
|
||||
populateCombobox();
|
||||
setTextBoxListeners();
|
||||
enableOkButton(false);
|
||||
}
|
||||
|
||||
public HashDbManager.HashDatabase getHashDatabase(){
|
||||
return this.selectedHashDb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register for notifications when the text boxes get updated.
|
||||
*/
|
||||
private void setTextBoxListeners() {
|
||||
textBoxes.add(tfFilePath);
|
||||
textBoxes.add(tfDatabaseName);
|
||||
textBoxes.add(tfDatabaseVersion);
|
||||
addDocumentListeners(textBoxes, textBoxChangedListener);
|
||||
}
|
||||
|
||||
private void populateCombobox() {
|
||||
comboboxSourceOrganization.removeAllItems();
|
||||
try {
|
||||
EamDb dbManager = EamDb.getInstance();
|
||||
orgs = dbManager.getOrganizations();
|
||||
orgs.forEach((org) -> {
|
||||
comboboxSourceOrganization.addItem(org.getName());
|
||||
});
|
||||
if (!orgs.isEmpty()) {
|
||||
selectedOrg = orgs.get(0);
|
||||
}
|
||||
valid();
|
||||
} catch (EamDbException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Failure populating combobox with organizations.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a change listener to a collection of text fields.
|
||||
*
|
||||
* @param textFields The text fields.
|
||||
* @param listener The change listener.
|
||||
*/
|
||||
private static void addDocumentListeners(Collection<JTextField> textFields, TextBoxChangedListener listener) {
|
||||
textFields.forEach((textField) -> {
|
||||
textField.getDocument().addDocumentListener(listener);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether or not values have been entered in all of the required
|
||||
* text fields.
|
||||
*
|
||||
* @return True or false.
|
||||
*/
|
||||
private boolean textFieldsArePopulated() {
|
||||
return !tfDatabaseName.getText().trim().isEmpty()
|
||||
&& !tfDatabaseVersion.getText().trim().isEmpty()
|
||||
&& !tfFilePath.getText().trim().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether or not all of the settings components are populated.
|
||||
*
|
||||
* @return True or false.
|
||||
*/
|
||||
@Messages({"ImportHashDatabaseDialog.validation.incompleteFields=Fill in all values"})
|
||||
private boolean checkFields() {
|
||||
boolean result = true;
|
||||
|
||||
boolean allPopulated = textFieldsArePopulated();
|
||||
|
||||
if (!allPopulated) {
|
||||
// We don't even have everything filled out
|
||||
result = false;
|
||||
lbWarningMsg.setText(Bundle.ImportHashDatabaseDialog_validation_incompleteFields());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that the form is filled out correctly for our usage.
|
||||
*
|
||||
* @return true if it's okay, false otherwise.
|
||||
*/
|
||||
@Messages({"ImportHashDatabaseDialog.validation.notEnabled=Central Repository is not enabled."})
|
||||
public boolean valid() {
|
||||
lbWarningMsg.setText("");
|
||||
if (!EamDb.isEnabled()) {
|
||||
lbWarningMsg.setText(Bundle.ImportHashDatabaseDialog_validation_notEnabled());
|
||||
return false;
|
||||
}
|
||||
|
||||
return enableOkButton(checkFields() && null != selectedOrg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the "OK" button to create the Global File Set and insert the instances.
|
||||
*
|
||||
* @param enable
|
||||
*
|
||||
* @return True or False
|
||||
*/
|
||||
private boolean enableOkButton(Boolean enable) {
|
||||
okButton.setEnabled(enable);
|
||||
return enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to listen for changes in text boxes. It lets the panel know things
|
||||
* have been updated and that validation needs to happen.
|
||||
*/
|
||||
private class TextBoxChangedListener implements DocumentListener {
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
||||
valid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
||||
valid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
||||
valid();
|
||||
}
|
||||
}
|
||||
|
||||
private void display() {
|
||||
Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
setLocation((screenDimension.width - getSize().width) / 2, (screenDimension.height - getSize().height) / 2);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
buttonGroup1 = new javax.swing.ButtonGroup();
|
||||
okButton = new javax.swing.JButton();
|
||||
cancelButton = new javax.swing.JButton();
|
||||
tfFilePath = new javax.swing.JTextField();
|
||||
openButton = new javax.swing.JButton();
|
||||
knownRadioButton = new javax.swing.JRadioButton();
|
||||
knownBadRadioButton = new javax.swing.JRadioButton();
|
||||
lbDatabaseType = new javax.swing.JLabel();
|
||||
lbDatabasePath = new javax.swing.JLabel();
|
||||
lbSourceOrganization = new javax.swing.JLabel();
|
||||
lbDatabaseName = new javax.swing.JLabel();
|
||||
lbDatabaseVersion = new javax.swing.JLabel();
|
||||
comboboxSourceOrganization = new javax.swing.JComboBox<>();
|
||||
tfDatabaseName = new javax.swing.JTextField();
|
||||
tfDatabaseVersion = new javax.swing.JTextField();
|
||||
bnNewOrganization = new javax.swing.JButton();
|
||||
lbWarningMsg = new javax.swing.JLabel();
|
||||
cbInboxMessages = new javax.swing.JCheckBox();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(okButton, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.okButton.text")); // NOI18N
|
||||
okButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
okButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.cancelButton.text")); // NOI18N
|
||||
cancelButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
cancelButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
tfFilePath.setText(org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.tfFilePath.text")); // NOI18N
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(openButton, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.openButton.text")); // NOI18N
|
||||
openButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
openButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonGroup1.add(knownRadioButton);
|
||||
org.openide.awt.Mnemonics.setLocalizedText(knownRadioButton, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.knownRadioButton.text")); // NOI18N
|
||||
|
||||
buttonGroup1.add(knownBadRadioButton);
|
||||
knownBadRadioButton.setSelected(true);
|
||||
org.openide.awt.Mnemonics.setLocalizedText(knownBadRadioButton, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.knownBadRadioButton.text")); // NOI18N
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseType, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.lbDatabaseType.text")); // NOI18N
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(lbDatabasePath, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportHashDatabaseDialog.lbFilePath.text")); // NOI18N
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(lbSourceOrganization, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.lbSourceOrganization.text")); // NOI18N
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseName, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.lbDatabaseName.text")); // NOI18N
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseVersion, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.lbDatabaseVersion.text")); // NOI18N
|
||||
|
||||
comboboxSourceOrganization.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
||||
comboboxSourceOrganization.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
comboboxSourceOrganizationActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
tfDatabaseName.setToolTipText(org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportHashDatabaseDialog.tfDatabaseName.tooltip")); // NOI18N
|
||||
|
||||
tfDatabaseVersion.setToolTipText(org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportHashDatabaseDialog.tfDatabaseVersion.tooltip.text")); // NOI18N
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(bnNewOrganization, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.bnNewOrganization.text")); // NOI18N
|
||||
bnNewOrganization.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
bnNewOrganizationActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
lbWarningMsg.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
|
||||
lbWarningMsg.setForeground(new java.awt.Color(255, 0, 0));
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(cbInboxMessages, org.openide.util.NbBundle.getMessage(ImportCentralRepoDatabaseDialog.class, "ImportCentralRepoDatabaseDialog.cbInboxMessages.text")); // NOI18N
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(okButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(cancelButton))
|
||||
.addComponent(lbWarningMsg, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lbDatabasePath)
|
||||
.addComponent(lbDatabaseName))
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(tfFilePath, javax.swing.GroupLayout.PREFERRED_SIZE, 277, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(openButton))
|
||||
.addComponent(tfDatabaseName)))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lbDatabaseType)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(19, 19, 19)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(knownRadioButton)
|
||||
.addComponent(knownBadRadioButton)))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(lbDatabaseVersion)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(tfDatabaseVersion, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(lbSourceOrganization)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(comboboxSourceOrganization, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(bnNewOrganization))
|
||||
.addComponent(cbInboxMessages))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cancelButton, okButton});
|
||||
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(openButton)
|
||||
.addComponent(tfFilePath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lbDatabasePath))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lbDatabaseName, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(tfDatabaseName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lbDatabaseVersion, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(tfDatabaseVersion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lbSourceOrganization, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(comboboxSourceOrganization, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(bnNewOrganization))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
|
||||
.addComponent(lbDatabaseType)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(knownRadioButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(knownBadRadioButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(cbInboxMessages)
|
||||
.addGap(117, 117, 117)
|
||||
.addComponent(lbWarningMsg, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(okButton)
|
||||
.addComponent(cancelButton))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
@Messages({"ImportHashDatabaseDialog.failedToGetDbPathMsg=Failed to get the path of the selected database.",})
|
||||
private void openButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openButtonActionPerformed
|
||||
if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
|
||||
File databaseFile = fileChooser.getSelectedFile();
|
||||
try {
|
||||
tfFilePath.setText(databaseFile.getCanonicalPath());
|
||||
if (databaseFile.getName().toLowerCase().contains("nsrl")) { //NON-NLS
|
||||
knownRadioButton.setSelected(true);
|
||||
}
|
||||
ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY, databaseFile.getParent());
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(ImportCentralRepoDatabaseDialog.class.getName()).log(Level.SEVERE, "Failed to get path of selected database", ex); // NON-NLS
|
||||
lbWarningMsg.setText(Bundle.ImportHashDatabaseDialog_failedToGetDbPathMsg());
|
||||
}
|
||||
}
|
||||
valid();
|
||||
}//GEN-LAST:event_openButtonActionPerformed
|
||||
|
||||
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
|
||||
dispose();
|
||||
}//GEN-LAST:event_cancelButtonActionPerformed
|
||||
|
||||
/**
|
||||
* Create the new global set and return the ID number
|
||||
*
|
||||
* @return ID number of new global set
|
||||
* @throws EamDbException
|
||||
*/
|
||||
private int createGlobalSet() throws EamDbException {
|
||||
EamDb dbManager = EamDb.getInstance();
|
||||
/*
|
||||
EamGlobalSet eamGlobalSet = new EamGlobalSet(
|
||||
selectedOrg.getOrgID(),
|
||||
tfDatabaseName.getText().trim(),
|
||||
tfDatabaseVersion.getText().trim(),
|
||||
LocalDate.now());
|
||||
return dbManager.newReferencelSet(eamGlobalSet);*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Messages({"ImportHashDatabaseDialog.createGlobalSet.failedMsg.text=Failed to store attribution details.",
|
||||
"ImportHashDatabaseDialog.mustSelectHashDbFilePathMsg=Missing hash database file path.",
|
||||
"ImportHashDatabaseDialog.hashDbDoesNotExistMsg=The selected hash database does not exist.",
|
||||
"# {0} - selected file path",
|
||||
"ImportHashDatabaseDialog.errorMessage.failedToOpenHashDbMsg=Failed to open hash database at {0}.",
|
||||
})
|
||||
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
|
||||
// Note that the error handlers in this method call return without disposing of the
|
||||
// dialog to allow the user to try again, if desired.
|
||||
/*String selectedFilePath = tfFilePath.getText();
|
||||
|
||||
// have valid file path
|
||||
if (selectedFilePath.isEmpty()) {
|
||||
lbWarningMsg.setText(Bundle.ImportHashDatabaseDialog_mustSelectHashDbFilePathMsg());
|
||||
return;
|
||||
}
|
||||
File file = new File(selectedFilePath);
|
||||
if (!file.exists()) {
|
||||
lbWarningMsg.setText(Bundle.ImportHashDatabaseDialog_hashDbDoesNotExistMsg());
|
||||
return;
|
||||
}
|
||||
|
||||
HashDbManager.HashDb.KnownFilesType known;
|
||||
if (knownRadioButton.isSelected()) {
|
||||
known = HashDbManager.HashDb.KnownFilesType.KNOWN;
|
||||
} else{
|
||||
known = HashDbManager.HashDb.KnownFilesType.KNOWN_BAD;
|
||||
}
|
||||
|
||||
try{
|
||||
HashDbManager.getInstance().importCentralRepoHashSet(tfDatabaseName.getText().trim(), tfDatabaseVersion.getText().trim(),
|
||||
selectedOrg.getOrgID(), true, true,
|
||||
known, selectedFilePath);
|
||||
} catch (Exception ex){
|
||||
|
||||
} finally {
|
||||
dispose();
|
||||
}*/
|
||||
/*
|
||||
// create global set
|
||||
int globalSetID;
|
||||
try {
|
||||
globalSetID = createGlobalSet();
|
||||
} catch (EamDbException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Failed to create global set.", ex);
|
||||
lbWarningMsg.setText(Bundle.ImportHashDatabaseDialog_createGlobalSet_failedMsg_text());
|
||||
return;
|
||||
}
|
||||
|
||||
// insert hashes
|
||||
TskData.FileKnown knownStatus = TskData.FileKnown.UNKNOWN;
|
||||
if (knownRadioButton.isSelected()) {
|
||||
knownStatus = TskData.FileKnown.KNOWN;
|
||||
} else if (knownBadRadioButton.isSelected()) {
|
||||
knownStatus = TskData.FileKnown.BAD;
|
||||
}
|
||||
|
||||
String errorMessage = Bundle.ImportHashDatabaseDialog_errorMessage_failedToOpenHashDbMsg(selectedFilePath);
|
||||
// Future, make UI handle more than the "FILES" type.
|
||||
try {
|
||||
EamDb dbManager = EamDb.getInstance();
|
||||
CorrelationAttribute.Type contentType = dbManager.getCorrelationTypeById(CorrelationAttribute.FILES_TYPE_ID); // get "FILES" type
|
||||
// run in the background and close dialog
|
||||
SwingUtilities.invokeLater(new ImportHashDatabaseWorker(selectedFilePath, knownStatus, globalSetID, contentType)::execute);
|
||||
dispose();
|
||||
} catch (EamDbException | UnknownHostException ex) {
|
||||
Logger.getLogger(ImportHashDatabaseDialog.class.getName()).log(Level.SEVERE, errorMessage, ex);
|
||||
lbWarningMsg.setText(ex.getMessage());
|
||||
}*/
|
||||
|
||||
}//GEN-LAST:event_okButtonActionPerformed
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
private void bnNewOrganizationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnNewOrganizationActionPerformed
|
||||
AddNewOrganizationDialog dialogO = new AddNewOrganizationDialog();
|
||||
// update the combobox options
|
||||
if (dialogO.isChanged()) {
|
||||
populateCombobox();
|
||||
}
|
||||
}//GEN-LAST:event_bnNewOrganizationActionPerformed
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
private void comboboxSourceOrganizationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboboxSourceOrganizationActionPerformed
|
||||
JComboBox<String> cb = (JComboBox<String>)evt.getSource();
|
||||
String orgName = (String)cb.getSelectedItem();
|
||||
if (null == orgName) return;
|
||||
|
||||
for (EamOrganization org : orgs) {
|
||||
if (org.getName().equals(orgName)) {
|
||||
selectedOrg = org;
|
||||
return;
|
||||
}
|
||||
}
|
||||
valid();
|
||||
}//GEN-LAST:event_comboboxSourceOrganizationActionPerformed
|
||||
|
||||
@NbBundle.Messages({"ImportHashDatabaseDialog.ImportHashDatabaseWorker.displayName=Importing Hash Database"})
|
||||
public class ImportHashDatabaseWorker extends SwingWorker<Void, Void> {
|
||||
|
||||
private final File file;
|
||||
private final TskData.FileKnown knownStatus;
|
||||
private final int globalSetID;
|
||||
private final ProgressHandle progress;
|
||||
private final CorrelationAttribute.Type contentType;
|
||||
|
||||
public ImportHashDatabaseWorker(String filename, TskData.FileKnown knownStatus, int globalSetID, CorrelationAttribute.Type contentType) throws EamDbException, UnknownHostException {
|
||||
this.file = new File(filename);
|
||||
this.knownStatus = knownStatus;
|
||||
this.globalSetID = globalSetID;
|
||||
this.contentType = contentType;
|
||||
this.progress = ProgressHandle.createHandle(Bundle.ImportHashDatabaseDialog_ImportHashDatabaseWorker_displayName());
|
||||
|
||||
if (!EamDb.isEnabled()) {
|
||||
throw new EamDbException("Central repository database is not enabled."); // NON-NLS
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
importHashDatabase();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Messages({"ImportHashDatabaseDialog.ImportHashDatabaseWorker.error=Failed to import hash database."})
|
||||
protected void done() {
|
||||
progress.finish();
|
||||
try {
|
||||
get();
|
||||
} catch (InterruptedException | ExecutionException ex) {
|
||||
Logger.getLogger(ImportCentralRepoDatabaseDialog.class.getName()).log(Level.SEVERE, Bundle.ImportHashDatabaseDialog_ImportHashDatabaseWorker_error(), ex);
|
||||
MessageNotifyUtil.Notify.show(Bundle.ImportHashDatabaseDialog_ImportHashDatabaseWorker_error(),
|
||||
ex.getMessage(),
|
||||
MessageNotifyUtil.MessageType.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
private long numberOfLinesInFile(File f) throws IOException {
|
||||
return Files.lines(f.toPath()).count();
|
||||
}
|
||||
|
||||
@Messages({"# {0} - value content",
|
||||
"ImportHashDatabaseDialog.ImportHashDatabaseWorker.duplicate=Duplicate value {0} found in import file."})
|
||||
private void importHashDatabase() throws EamDbException, IOException {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
String line;
|
||||
EamDb dbManager = EamDb.getInstance();
|
||||
Set<EamGlobalFileInstance> globalInstances = new HashSet<>();
|
||||
|
||||
long totalLines = numberOfLinesInFile(file);
|
||||
if (totalLines <= Integer.MAX_VALUE) {
|
||||
progress.start((int) totalLines);
|
||||
} else {
|
||||
progress.start();
|
||||
}
|
||||
|
||||
int numLines = 0;
|
||||
LOGGER.log(Level.INFO, "Importing hash database {0}", file.getName());
|
||||
while ((line = reader.readLine()) != null) {
|
||||
progress.progress(++numLines);
|
||||
|
||||
String[] parts = line.split("\\|");
|
||||
|
||||
// Header lines start with a 41 character dummy hash, 1 character longer than a SHA-1 hash
|
||||
if (parts.length != 2 || parts[0].length() == 41) {
|
||||
continue;
|
||||
}
|
||||
|
||||
EamGlobalFileInstance eamGlobalFileInstance = new EamGlobalFileInstance(
|
||||
globalSetID,
|
||||
parts[0].toLowerCase(),
|
||||
knownStatus,
|
||||
"");
|
||||
|
||||
globalInstances.add(eamGlobalFileInstance);
|
||||
|
||||
if(numLines % HASH_IMPORT_THRESHOLD == 0){
|
||||
dbManager.bulkInsertReferenceTypeEntries(globalInstances, contentType);
|
||||
globalInstances.clear();
|
||||
}
|
||||
}
|
||||
|
||||
dbManager.bulkInsertReferenceTypeEntries(globalInstances, contentType);
|
||||
LOGGER.log(Level.INFO, "Finished importing hash database. Total entries: {0}", numLines);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton bnNewOrganization;
|
||||
private javax.swing.ButtonGroup buttonGroup1;
|
||||
private javax.swing.JButton cancelButton;
|
||||
private javax.swing.JCheckBox cbInboxMessages;
|
||||
private javax.swing.JComboBox<String> comboboxSourceOrganization;
|
||||
private javax.swing.JRadioButton knownBadRadioButton;
|
||||
private javax.swing.JRadioButton knownRadioButton;
|
||||
private javax.swing.JLabel lbDatabaseName;
|
||||
private javax.swing.JLabel lbDatabasePath;
|
||||
private javax.swing.JLabel lbDatabaseType;
|
||||
private javax.swing.JLabel lbDatabaseVersion;
|
||||
private javax.swing.JLabel lbSourceOrganization;
|
||||
private javax.swing.JLabel lbWarningMsg;
|
||||
private javax.swing.JButton okButton;
|
||||
private javax.swing.JButton openButton;
|
||||
private javax.swing.JTextField tfDatabaseName;
|
||||
private javax.swing.JTextField tfDatabaseVersion;
|
||||
private javax.swing.JTextField tfFilePath;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
@ -224,7 +224,6 @@ HashLookupSettingsPanel.nameLabel1.text=Hash Set Name:
|
||||
HashLookupSettingsPanel.sendIngestMessagesCheckBox1.text=Send ingest inbox message for each hit
|
||||
HashLookupSettingsPanel.importDatabaseButton1.toolTipText=
|
||||
HashLookupSettingsPanel.typeLabel1.text=Type:
|
||||
HashLookupSettingsPanel.jButton1.text=Import CR Hashset
|
||||
ImportCentralRepoDatabaseDialog.cbInboxMessages.text=Send ingest inbox message for each hit
|
||||
ImportCentralRepoDatabaseDialog.cancelButton.text=Cancel
|
||||
ImportCentralRepoDatabaseDialog.lbDatabaseVersion.text=Hash Set Version:
|
||||
|
@ -512,10 +512,6 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
|
||||
void save() throws HashDbManagerException {
|
||||
try {
|
||||
System.out.println("######\nHashDbManager: Saving Hash Lookup settings");
|
||||
for(HashDatabase db: this.hashSets){
|
||||
System.out.println(" " + db.getHashSetName() + " " + db.getDatabaseType().name());
|
||||
}
|
||||
if (!HashLookupSettings.writeSettings(new HashLookupSettings(HashLookupSettings.convertHashSetList(this.hashSets)))) {
|
||||
throw new HashDbManagerException(NbBundle.getMessage(this.getClass(), "HashDbManager.saveErrorExceptionMsg"));
|
||||
}
|
||||
|
@ -125,10 +125,6 @@ final class HashLookupSettings implements Serializable {
|
||||
try {
|
||||
try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(SERIALIZATION_FILE_PATH))) {
|
||||
HashLookupSettings filesSetsSettings = (HashLookupSettings) in.readObject();
|
||||
System.out.println("#####\nHashLookupSettings");
|
||||
for(HashDbInfo dbInfo:filesSetsSettings.hashDbInfoList){
|
||||
System.out.println(" " + dbInfo.getHashSetName() + " File type: " + dbInfo.isFileDatabaseType());
|
||||
}
|
||||
return filesSetsSettings;
|
||||
}
|
||||
} catch (IOException | ClassNotFoundException ex) {
|
||||
|
@ -161,10 +161,7 @@
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="ingestWarningLabel" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" pref="148" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="ingestWarningLabel" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
@ -258,8 +255,6 @@
|
||||
<Component id="sendIngestMessagesCheckBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="ingestWarningLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jScrollPane1" max="32767" attributes="0"/>
|
||||
@ -620,16 +615,6 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addHashesToDatabaseButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/modules/hashdatabase/Bundle.properties" key="HashLookupSettingsPanel.jButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="versionLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
|
@ -595,7 +595,6 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
||||
indexPathLabelLabel = new javax.swing.JLabel();
|
||||
indexPathLabel = new javax.swing.JLabel();
|
||||
addHashesToDatabaseButton = new javax.swing.JButton();
|
||||
jButton1 = new javax.swing.JButton();
|
||||
versionLabel = new javax.swing.JLabel();
|
||||
hashDbVersionLabel = new javax.swing.JLabel();
|
||||
orgLabel = new javax.swing.JLabel();
|
||||
@ -740,13 +739,6 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
||||
}
|
||||
});
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.jButton1.text")); // NOI18N
|
||||
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(versionLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.versionLabel.text_1")); // NOI18N
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(hashDbVersionLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.hashDbVersionLabel.text_1")); // NOI18N
|
||||
@ -822,9 +814,7 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
||||
.addComponent(sendIngestMessagesCheckBox))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGap(10, 10, 10)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(ingestWarningLabel)
|
||||
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)))))
|
||||
.addComponent(ingestWarningLabel))))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@ -894,8 +884,6 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
||||
.addComponent(sendIngestMessagesCheckBox)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(ingestWarningLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jButton1)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addComponent(jScrollPane1))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
@ -1027,20 +1015,6 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
||||
}
|
||||
}//GEN-LAST:event_hashSetTableKeyPressed
|
||||
|
||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
if(EamDb.isEnabled()){
|
||||
HashDatabase hashDb = new ImportCentralRepoDatabaseDialog().getHashDatabase();
|
||||
if (null != hashDb) {
|
||||
hashSetTableModel.refreshModel();
|
||||
((HashSetTable) hashSetTable).selectRowByDatabase(hashDb);
|
||||
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
||||
}
|
||||
} else {
|
||||
// TEMP
|
||||
JOptionPane.showMessageDialog(null, "Central repo not enabled");
|
||||
}
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton addHashesToDatabaseButton;
|
||||
private javax.swing.JButton createDatabaseButton;
|
||||
@ -1062,7 +1036,6 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
||||
private javax.swing.JLabel informationLabel;
|
||||
private javax.swing.JSeparator informationSeparator;
|
||||
private javax.swing.JLabel ingestWarningLabel;
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JButton jButton3;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel4;
|
||||
|
@ -24,27 +24,22 @@ import java.beans.PropertyChangeEvent;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.WindowConstants;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.Executors;
|
||||
import javax.swing.JOptionPane;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.windows.WindowManager;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttribute;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamGlobalFileInstance;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamOrganization;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
import org.sleuthkit.datamodel.TskData;
|
||||
|
||||
@ -53,8 +48,7 @@ import org.sleuthkit.datamodel.TskData;
|
||||
*/
|
||||
class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements PropertyChangeListener{
|
||||
|
||||
private CentralRepoImportWorker worker;
|
||||
|
||||
private CentralRepoImportWorker worker;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -108,9 +102,6 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
||||
@NbBundle.Messages({"ImportCentralRepoDbProgressDialog.linesProcessed= lines processed"})
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
System.out.println("### Evt type: " + evt.getPropertyName());
|
||||
System.out.println(" newValue: " + evt.getNewValue().toString());
|
||||
System.out.println("### Setting progress to " + worker.getProgressPercentage());
|
||||
|
||||
if("progress".equals(evt.getPropertyName())){
|
||||
progressBar.setValue(worker.getProgressPercentage());
|
||||
@ -199,16 +190,6 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
||||
return this.getProgress();
|
||||
}
|
||||
|
||||
//@Override
|
||||
//public void addPropertyChangeListener(PropertyChangeListener dialog){
|
||||
// super.addPropertyChangeListener(dialog);
|
||||
//}
|
||||
|
||||
//@Override
|
||||
//public void run(){
|
||||
// this.execute();
|
||||
//}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
|
||||
@ -218,69 +199,58 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
||||
} else {
|
||||
knownStatus = TskData.FileKnown.BAD;
|
||||
}
|
||||
try{
|
||||
// Create an empty hashset in the central repository
|
||||
crIndex = EamDb.getInstance().newReferenceSet(orgId, hashSetName, version, knownStatus, readOnly);
|
||||
} catch (EamDbException ex){
|
||||
throw new TskCoreException(ex.getLocalizedMessage());
|
||||
}
|
||||
|
||||
// Create an empty hashset in the central repository
|
||||
crIndex = EamDb.getInstance().newReferenceSet(orgId, hashSetName, version, knownStatus, readOnly);
|
||||
|
||||
try{
|
||||
EamDb dbManager = EamDb.getInstance();
|
||||
CorrelationAttribute.Type contentType = dbManager.getCorrelationTypeById(CorrelationAttribute.FILES_TYPE_ID); // get "FILES" type
|
||||
BufferedReader reader = new BufferedReader(new FileReader(importFile));
|
||||
String line;
|
||||
Set<EamGlobalFileInstance> globalInstances = new HashSet<>();
|
||||
EamDb dbManager = EamDb.getInstance();
|
||||
CorrelationAttribute.Type contentType = dbManager.getCorrelationTypeById(CorrelationAttribute.FILES_TYPE_ID); // get "FILES" type
|
||||
BufferedReader reader = new BufferedReader(new FileReader(importFile));
|
||||
String line;
|
||||
Set<EamGlobalFileInstance> globalInstances = new HashSet<>();
|
||||
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if(isCancelled()){
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] parts = line.split("\\|");
|
||||
|
||||
// Header lines start with a 41 character dummy hash, 1 character longer than a SHA-1 hash
|
||||
if (parts.length != 2 || parts[0].length() == 41) {
|
||||
continue;
|
||||
}
|
||||
|
||||
EamGlobalFileInstance eamGlobalFileInstance = new EamGlobalFileInstance(
|
||||
crIndex,
|
||||
parts[0].toLowerCase(),
|
||||
knownStatus,
|
||||
"");
|
||||
|
||||
globalInstances.add(eamGlobalFileInstance);
|
||||
numLines.incrementAndGet();
|
||||
|
||||
if(numLines.get() % HASH_IMPORT_THRESHOLD == 0){
|
||||
dbManager.bulkInsertReferenceTypeEntries(globalInstances, contentType);
|
||||
globalInstances.clear();
|
||||
|
||||
int progress = (int)(numLines.get() * 100 / totalLines);
|
||||
if(progress < 100){
|
||||
this.setProgress(progress);
|
||||
} else {
|
||||
this.setProgress(99);
|
||||
}
|
||||
}
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if(isCancelled()){
|
||||
return null;
|
||||
}
|
||||
|
||||
dbManager.bulkInsertReferenceTypeEntries(globalInstances, contentType);
|
||||
this.setProgress(100);
|
||||
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex){
|
||||
// TODO
|
||||
ex.printStackTrace();
|
||||
throw new TskCoreException(ex.getLocalizedMessage());
|
||||
String[] parts = line.split("\\|");
|
||||
|
||||
// Header lines start with a 41 character dummy hash, 1 character longer than a SHA-1 hash
|
||||
if (parts.length != 2 || parts[0].length() == 41) {
|
||||
continue;
|
||||
}
|
||||
|
||||
EamGlobalFileInstance eamGlobalFileInstance = new EamGlobalFileInstance(
|
||||
crIndex,
|
||||
parts[0].toLowerCase(),
|
||||
knownStatus,
|
||||
"");
|
||||
|
||||
globalInstances.add(eamGlobalFileInstance);
|
||||
numLines.incrementAndGet();
|
||||
|
||||
if(numLines.get() % HASH_IMPORT_THRESHOLD == 0){
|
||||
dbManager.bulkInsertReferenceTypeEntries(globalInstances, contentType);
|
||||
globalInstances.clear();
|
||||
|
||||
int progress = (int)(numLines.get() * 100 / totalLines);
|
||||
if(progress < 100){
|
||||
this.setProgress(progress);
|
||||
} else {
|
||||
this.setProgress(99);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dbManager.bulkInsertReferenceTypeEntries(globalInstances, contentType);
|
||||
this.setProgress(100);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void deleteIncompleteSet(int crIndex){
|
||||
if(crIndex >= 0){
|
||||
System.out.println("Deleting incomplete reference set");
|
||||
|
||||
// This can be slow on large reference sets
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
@ -289,13 +259,14 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
||||
try{
|
||||
EamDb.getInstance().deleteReferenceSet(crIndex);
|
||||
} catch (EamDbException ex2){
|
||||
|
||||
Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE, "Error deleting incomplete hash set from central repository", ex2);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@NbBundle.Messages({"ImportCentralRepoDbProgressDialog.addDbError.message=Error adding new hash set"})
|
||||
@Override
|
||||
protected void done() {
|
||||
if(isCancelled()){
|
||||
@ -307,23 +278,20 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
||||
try {
|
||||
get();
|
||||
try{
|
||||
System.out.println("### Finished - adding hashDb object");
|
||||
newHashDb = HashDbManager.getInstance().addExistingCentralRepoHashSet(hashSetName, version,
|
||||
crIndex,
|
||||
searchDuringIngest, sendIngestMessages, knownFilesType, readOnly);
|
||||
} catch (TskCoreException ex){
|
||||
System.out.println("\n### Error!");
|
||||
JOptionPane.showMessageDialog(null, Bundle.ImportCentralRepoDbProgressDialog_addDbError_message());
|
||||
Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE, "Error adding imported hash set", ex);
|
||||
}
|
||||
} catch (InterruptedException | ExecutionException ex) {
|
||||
|
||||
System.out.println("\n### Interrupted!");
|
||||
|
||||
} catch (Exception ex) {
|
||||
// Delete this incomplete hash set from the central repo
|
||||
if(crIndex >= 0){
|
||||
try{
|
||||
EamDb.getInstance().deleteReferenceSet(crIndex);
|
||||
} catch (EamDbException ex2){
|
||||
|
||||
Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE, "Error deleting incomplete hash set from central repository", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user