19 package org.sleuthkit.autopsy.modules.hashdatabase;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
27 import java.util.logging.Level;
28 import javax.swing.JScrollPane;
29 import javax.swing.JTable;
30 import javax.swing.table.AbstractTableModel;
31 import javax.swing.table.TableColumn;
60 private void initializeHashSetModels(HashLookupModuleSettings settings, List<HashDb> hashDbs, List<HashSetModel> hashSetModels) {
61 hashSetModels.clear();
62 for (
HashDb db : hashDbs) {
63 String name = db.getHashSetName();
77 table.setModel(tableModel);
78 table.setTableHeader(null);
79 table.setRowSelectionAllowed(
false);
80 final int width1 = scrollPane.getPreferredSize().width;
83 for (
int i = 0; i < table.getColumnCount(); i++) {
84 column = table.getColumnModel().getColumn(i);
86 column.setPreferredWidth(((
int) (width1 * 0.07)));
88 column.setPreferredWidth(((
int) (width1 * 0.92)));
104 List<String> enabledKnownHashSetNames =
new ArrayList<>();
105 List<String> disabledKnownHashSetNames =
new ArrayList<>();
106 List<String> enabledKnownBadHashSetNames =
new ArrayList<>();
107 List<String> disabledKnownBadHashSetNames =
new ArrayList<>();
108 getHashSetNames(knownHashSetModels, enabledKnownHashSetNames, disabledKnownHashSetNames);
109 getHashSetNames(knownBadHashSetModels, enabledKnownBadHashSetNames, disabledKnownBadHashSetNames);
111 enabledKnownHashSetNames, enabledKnownBadHashSetNames,
112 disabledKnownHashSetNames, disabledKnownBadHashSetNames);
115 private void getHashSetNames(List<HashSetModel> hashSetModels, List<String> enabledHashSetNames, List<String> disabledHashSetNames) {
117 if (model.isEnabled() && model.isIndexed()) {
118 enabledHashSetNames.add(model.getName());
120 disabledHashSetNames.add(model.getName());
127 knownHashSetsTableModel.fireTableDataChanged();
128 knownBadHashSetsTableModel.fireTableDataChanged();
137 Map<String, HashDb> hashSetDbs =
new HashMap<>();
138 for (
HashDb db : hashDbs) {
139 hashSetDbs.put(db.getHashSetName(), db);
143 List<HashSetModel> deletedHashSetModels =
new ArrayList<>();
144 for (HashSetModel model : hashSetModels) {
145 String hashSetName = model.getName();
146 if (hashSetDbs.containsKey(hashSetName)) {
147 HashDb db = hashSetDbs.get(hashSetName);
149 hashSetDbs.remove(hashSetName);
151 deletedHashSetModels.add(model);
156 for (HashSetModel model : deletedHashSetModels) {
157 hashSetModels.remove(model);
161 for (HashDb db : hashSetDbs.values()) {
162 String name = db.getHashSetName();
167 void reset(HashLookupModuleSettings newSettings) {
170 knownHashSetsTableModel.fireTableDataChanged();
171 knownBadHashSetsTableModel.fireTableDataChanged();
175 boolean indexed =
false;
177 indexed = hashDb.hasIndex();
178 }
catch (TskCoreException ex) {
190 HashSetModel(String name,
boolean enabled,
boolean indexed) {
200 void setEnabled(
boolean enabled) {
204 boolean isEnabled() {
208 void setIndexed(
boolean indexed) {
212 boolean isIndexed() {
227 return hashSets.size();
237 if (columnIndex == 0) {
238 return hashSets.get(rowIndex).isEnabled();
240 return hashSets.get(rowIndex).getName();
246 return (columnIndex == 0 && hashSets.get(rowIndex).isIndexed());
250 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
251 if (columnIndex == 0) {
252 hashSets.get(rowIndex).setEnabled((Boolean) aValue);
267 @SuppressWarnings(
"unchecked")
279 setPreferredSize(
new java.awt.Dimension(292, 150));
281 jScrollPane1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
300 jScrollPane2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
315 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
316 this.setLayout(layout);
317 layout.setHorizontalGroup(
318 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
319 .addGroup(layout.createSequentialGroup()
321 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
322 .addGroup(layout.createSequentialGroup()
323 .addComponent(
knownHashDbsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 272, javax.swing.GroupLayout.PREFERRED_SIZE)
324 .addGap(0, 18, Short.MAX_VALUE))
325 .addComponent(
knownBadHashDbsLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
326 .addGroup(layout.createSequentialGroup()
328 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
329 .addComponent(
jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
330 .addComponent(
jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))
331 .addComponent(
alwaysCalcHashesCheckbox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
334 layout.setVerticalGroup(
335 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
336 .addGroup(layout.createSequentialGroup()
339 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
340 .addComponent(
jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE)
341 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
343 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
344 .addComponent(
jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 53, Short.MAX_VALUE)
345 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
346 .addComponent(
alwaysCalcHashesCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
javax.swing.JLabel knownBadHashDbsLabel
void setValueAt(Object aValue, int rowIndex, int columnIndex)
javax.swing.JScrollPane jScrollPane1
javax.swing.JTable knownBadHashTable
IngestModuleIngestJobSettings getSettings()
void propertyChange(PropertyChangeEvent event)
void updateHashSetModels()
synchronized void addPropertyChangeListener(PropertyChangeListener listener)
void getHashSetNames(List< HashSetModel > hashSetModels, List< String > enabledHashSetNames, List< String > disabledHashSetNames)
void initializeHashSetModels(HashLookupModuleSettings settings, List< HashDb > hashDbs, List< HashSetModel > hashSetModels)
void customizeHashSetsTable(JScrollPane scrollPane, JTable table, HashSetsTableModel tableModel)
javax.swing.JScrollPane jScrollPane2
javax.swing.JTable knownHashTable
boolean isCellEditable(int rowIndex, int columnIndex)
final HashSetsTableModel knownBadHashSetsTableModel
void initializeHashSetModels(HashLookupModuleSettings settings)
synchronized List< HashDb > getKnownBadFileHashSets()
static synchronized HashDbManager getInstance()
boolean isHashDbIndexed(HashDb hashDb)
final HashSetsTableModel knownHashSetsTableModel
void customizeComponents(HashLookupModuleSettings settings)
Object getValueAt(int rowIndex, int columnIndex)
javax.swing.JCheckBox alwaysCalcHashesCheckbox
final HashDbManager hashDbManager
synchronized static Logger getLogger(String name)
final List< HashSetModel > knownBadHashSetModels
final List< HashSetModel > hashSets
javax.swing.JLabel knownHashDbsLabel
synchronized List< HashDb > getKnownFileHashSets()
final List< HashSetModel > knownHashSetModels
Class<?> getColumnClass(int c)