From ec3e4eae9495b97b544c7b9104f803b15d975b62 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Tue, 6 Nov 2018 11:16:42 -0500 Subject: [PATCH] Moving the report into it's own package --- .../modules/case_uco/Bundle.properties | 9 + .../modules/case_uco/Bundle_ja.properties | 2 + .../case_uco/DataSourceComboBoxModel.java | 80 +++++++++ .../case_uco}/ReportCaseUco.java | 9 +- .../case_uco/ReportCaseUcoConfigPanel.form | 67 +++++++ .../case_uco/ReportCaseUcoConfigPanel.java | 163 ++++++++++++++++++ 6 files changed, 327 insertions(+), 3 deletions(-) create mode 100755 Core/src/org/sleuthkit/autopsy/modules/case_uco/Bundle.properties create mode 100755 Core/src/org/sleuthkit/autopsy/modules/case_uco/Bundle_ja.properties create mode 100755 Core/src/org/sleuthkit/autopsy/modules/case_uco/DataSourceComboBoxModel.java rename Core/src/org/sleuthkit/autopsy/{report => modules/case_uco}/ReportCaseUco.java (97%) create mode 100755 Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.form create mode 100755 Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.java diff --git a/Core/src/org/sleuthkit/autopsy/modules/case_uco/Bundle.properties b/Core/src/org/sleuthkit/autopsy/modules/case_uco/Bundle.properties new file mode 100755 index 0000000000..3fb4ab5d6e --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/modules/case_uco/Bundle.properties @@ -0,0 +1,9 @@ +OpenIDE-Module-Name=CaseUcoModule +ReportCaseUco.progress.initializing=Creating directories... +ReportCaseUco.progress.querying=Querying files... +ReportCaseUco.ingestWarning.text=Warning, this report was run before ingest services completed\! +ReportCaseUco.progress.loading=Loading files... +ReportCaseUco.progress.processing=Now processing {0}... +ReportCaseUco.getName.text=CASE/UCO +ReportCaseUco.getDesc.text=CASE/UCO format report with basic property fields for every file. +ReportCaseUcoConfigPanel.jLabelSelectDataSource.text=Select a data source for the CASE/UCO report diff --git a/Core/src/org/sleuthkit/autopsy/modules/case_uco/Bundle_ja.properties b/Core/src/org/sleuthkit/autopsy/modules/case_uco/Bundle_ja.properties new file mode 100755 index 0000000000..1204a1e9dc --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/modules/case_uco/Bundle_ja.properties @@ -0,0 +1,2 @@ + +ReportCaseUcoConfigPanel.jLabelSelectDataSource.text=STIX\u30d5\u30a1\u30a4\u30eb\u307e\u305f\u306fSTIX\u30d5\u30a1\u30a4\u30eb\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u9078\u629e diff --git a/Core/src/org/sleuthkit/autopsy/modules/case_uco/DataSourceComboBoxModel.java b/Core/src/org/sleuthkit/autopsy/modules/case_uco/DataSourceComboBoxModel.java new file mode 100755 index 0000000000..34fcdb3966 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/modules/case_uco/DataSourceComboBoxModel.java @@ -0,0 +1,80 @@ +/* + * + * Autopsy Forensic Browser + * + * Copyright 2018 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.modules.case_uco; + +import javax.swing.AbstractListModel; +import javax.swing.ComboBoxModel; +import javax.swing.event.ListDataListener; + +/** + * Encapsulates meta data needed to populate the data source selection drop down menu + */ +public class DataSourceComboBoxModel extends AbstractListModel implements ComboBoxModel { + + private static final long serialVersionUID = 1L; + private final String[] dataSourceList; + private String selection = null; + + /** + * Use this to initialize the panel + */ + DataSourceComboBoxModel() { + this.dataSourceList = new String[0]; + } + + /** + * Use this when we have data to display. + * + * @param theDataSoureList names of data sources for user to pick from + */ + DataSourceComboBoxModel(String... theDataSoureList) { + dataSourceList = theDataSoureList.clone(); + } + + @Override + public void setSelectedItem(Object anItem) { + selection = (String) anItem; + } + + @Override + public Object getSelectedItem() { + return selection; + } + + @Override + public int getSize() { + return dataSourceList.length; + } + + @Override + public String getElementAt(int index) { + return dataSourceList[index]; + } + + @Override + public void addListDataListener(ListDataListener listener) { + this.listenerList.add(ListDataListener.class, listener); + } + + @Override + public void removeListDataListener(ListDataListener listener) { + this.listenerList.remove(ListDataListener.class, listener); + } +} diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportCaseUco.java b/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUco.java similarity index 97% rename from Core/src/org/sleuthkit/autopsy/report/ReportCaseUco.java rename to Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUco.java index 289a9c6eae..35b3c71b91 100755 --- a/Core/src/org/sleuthkit/autopsy/report/ReportCaseUco.java +++ b/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUco.java @@ -20,7 +20,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.sleuthkit.autopsy.report; +package org.sleuthkit.autopsy.modules.case_uco; import java.io.IOException; import java.nio.file.Files; @@ -35,13 +35,14 @@ import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; import java.sql.ResultSet; import java.sql.SQLException; import java.util.SimpleTimeZone; -import java.util.TimeZone; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.datamodel.ContentUtils; import org.sleuthkit.autopsy.ingest.IngestManager; +import org.sleuthkit.autopsy.report.GeneralReportModule; +import org.sleuthkit.autopsy.report.ReportProgressPanel; import org.sleuthkit.autopsy.report.ReportProgressPanel.ReportStatus; import org.sleuthkit.datamodel.*; @@ -53,6 +54,7 @@ class ReportCaseUco implements GeneralReportModule { private static final Logger logger = Logger.getLogger(ReportCaseUco.class.getName()); private static ReportCaseUco instance = null; + private ReportCaseUcoConfigPanel configPanel; private Case currentCase; private SleuthkitCase skCase; @@ -242,6 +244,7 @@ class ReportCaseUco implements GeneralReportModule { @Override public JPanel getConfigurationPanel() { - return null; // No configuration panel + configPanel = new ReportCaseUcoConfigPanel(); + return configPanel; } } diff --git a/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.form b/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.form new file mode 100755 index 0000000000..f3fe980200 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.form @@ -0,0 +1,67 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.java b/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.java new file mode 100755 index 0000000000..756a25976a --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/modules/case_uco/ReportCaseUcoConfigPanel.java @@ -0,0 +1,163 @@ +/* + * + * Autopsy Forensic Browser + * + * Copyright 2018 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.modules.case_uco; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Observable; +import java.util.Observer; +import javax.swing.ComboBoxModel; + +/** + * UI controls for Common Files Search scenario where the user intends to find + * common files between datasources. It is an inner panel which provides the + * ability to select all datasources or a single datasource from a dropdown list + * of sources in the current case. + */ +public final class ReportCaseUcoConfigPanel extends javax.swing.JPanel { + + private static final long serialVersionUID = 1L; + static final long NO_DATA_SOURCE_SELECTED = -1; + private final Observable fileTypeFilterObservable; + private ComboBoxModel dataSourcesList = new DataSourceComboBoxModel(); + private final Map dataSourceMap; + + /** + * Creates new form IntraCasePanel + */ + public ReportCaseUcoConfigPanel() { + initComponents(); + this.dataSourceMap = new HashMap<>(); + fileTypeFilterObservable = new Observable() { + @Override + public void notifyObservers() { + //set changed before notify observers + //we want this observerable to always cause the observer to update when notified + this.setChanged(); + super.notifyObservers(); + } + }; + } + + /** + * Add an Observer to the Observable portion of this panel so that it can be + * notified of changes to this panel. + * + * @param observer the object which is observing this panel + */ + void addObserver(Observer observer) { + fileTypeFilterObservable.addObserver(observer); + } + + /** + * Get the map of datasources which was used to populate the combo box on + * this panel. + * + * @return an unmodifiable copy of the map of datasources + */ + Map getDataSourceMap() { + return Collections.unmodifiableMap(this.dataSourceMap); + } + + /** + * Get the ID for the datasource selected in the combo box. + * + * @return the selected datasource ID or + ReportCaseUcoConfigPanel.NO_DATA_SOURCE_SELECTED if none is selected + */ + Long getSelectedDataSourceId() { + for (Entry entry : this.dataSourceMap.entrySet()) { + if (entry.getValue().equals(this.selectDataSourceComboBox.getSelectedItem())) { + return entry.getKey(); + } + } + return ReportCaseUcoConfigPanel.NO_DATA_SOURCE_SELECTED; + } + + /** + * 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + selectDataSourceComboBox = new javax.swing.JComboBox<>(); + jLabelSelectDataSource = new javax.swing.JLabel(); + + selectDataSourceComboBox.setModel(dataSourcesList); + selectDataSourceComboBox.setEnabled(false); + + jLabelSelectDataSource.setText(org.openide.util.NbBundle.getMessage(ReportCaseUcoConfigPanel.class, "ReportCaseUcoConfigPanel.jLabelSelectDataSource.text")); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(21, 21, 21) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabelSelectDataSource) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(selectDataSourceComboBox, 0, 348, Short.MAX_VALUE)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(11, 11, 11) + .addComponent(jLabelSelectDataSource) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(selectDataSourceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(172, 172, 172)) + ); + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabelSelectDataSource; + private javax.swing.JComboBox selectDataSourceComboBox; + // End of variables declaration//GEN-END:variables + + /** + * Set the datamodel for the combo box which displays the data sources in + * the current case + * + * @param dataSourceComboBoxModel the DataSourceComboBoxModel to use + */ + void setDatasourceComboboxModel(DataSourceComboBoxModel dataSourceComboBoxModel) { + this.dataSourcesList = dataSourceComboBoxModel; + this.selectDataSourceComboBox.setModel(dataSourcesList); + } + + /** + * Update the map of datasources that this panel allows the user to select + * from + * + * @param dataSourceMap A map of datasources + */ + void setDataSourceMap(Map dataSourceMap) { + this.dataSourceMap.clear(); + this.dataSourceMap.putAll(dataSourceMap); + } +}