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;
61 private void initializeHashSetModels(HashLookupModuleSettings settings, List<HashDb> hashDbs, List<HashSetModel> hashSetModels) {
62 hashSetModels.clear();
63 for (
HashDb db : hashDbs) {
64 String name = db.getHashSetName();
78 table.setModel(tableModel);
79 table.setTableHeader(null);
80 table.setRowSelectionAllowed(
false);
81 final int width1 = scrollPane.getPreferredSize().width;
84 for (
int i = 0; i < table.getColumnCount(); i++) {
85 column = table.getColumnModel().getColumn(i);
87 column.setPreferredWidth(((
int) (width1 * 0.07)));
89 column.setPreferredWidth(((
int) (width1 * 0.92)));
105 List<String> enabledKnownHashSetNames =
new ArrayList<>();
106 List<String> disabledKnownHashSetNames =
new ArrayList<>();
107 List<String> enabledKnownBadHashSetNames =
new ArrayList<>();
108 List<String> disabledKnownBadHashSetNames =
new ArrayList<>();
109 getHashSetNames(knownHashSetModels, enabledKnownHashSetNames, disabledKnownHashSetNames);
110 getHashSetNames(knownBadHashSetModels, enabledKnownBadHashSetNames, disabledKnownBadHashSetNames);
112 enabledKnownHashSetNames, enabledKnownBadHashSetNames,
113 disabledKnownHashSetNames, disabledKnownBadHashSetNames);
116 private void getHashSetNames(List<HashSetModel> hashSetModels, List<String> enabledHashSetNames, List<String> disabledHashSetNames) {
118 if (model.isEnabled() && model.isIndexed()) {
119 enabledHashSetNames.add(model.getName());
121 disabledHashSetNames.add(model.getName());
128 knownHashSetsTableModel.fireTableDataChanged();
129 knownBadHashSetsTableModel.fireTableDataChanged();
138 Map<String, HashDb> hashSetDbs =
new HashMap<>();
139 for (
HashDb db : hashDbs) {
140 hashSetDbs.put(db.getHashSetName(), db);
144 List<HashSetModel> deletedHashSetModels =
new ArrayList<>();
145 for (HashSetModel model : hashSetModels) {
146 String hashSetName = model.getName();
147 if (hashSetDbs.containsKey(hashSetName)) {
148 HashDb db = hashSetDbs.get(hashSetName);
150 hashSetDbs.remove(hashSetName);
152 deletedHashSetModels.add(model);
157 for (HashSetModel model : deletedHashSetModels) {
158 hashSetModels.remove(model);
162 for (HashDb db : hashSetDbs.values()) {
163 String name = db.getHashSetName();
168 void reset(HashLookupModuleSettings newSettings) {
171 knownHashSetsTableModel.fireTableDataChanged();
172 knownBadHashSetsTableModel.fireTableDataChanged();
176 boolean indexed =
false;
178 indexed = hashDb.hasIndex();
191 HashSetModel(String name,
boolean enabled,
boolean indexed) {
201 void setEnabled(
boolean enabled) {
205 boolean isEnabled() {
209 void setIndexed(
boolean indexed) {
213 boolean isIndexed() {
220 private static final long serialVersionUID = 1L;
229 return hashSets.size();
239 if (columnIndex == 0) {
240 return hashSets.get(rowIndex).isEnabled();
242 return hashSets.get(rowIndex).getName();
248 return (columnIndex == 0 && hashSets.get(rowIndex).isIndexed());
252 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
253 if (columnIndex == 0) {
254 hashSets.get(rowIndex).setEnabled((Boolean) aValue);
269 @SuppressWarnings(
"unchecked")
281 setPreferredSize(
new java.awt.Dimension(292, 150));
283 jScrollPane1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
302 jScrollPane2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
317 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
318 this.setLayout(layout);
319 layout.setHorizontalGroup(
320 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
321 .addGroup(layout.createSequentialGroup()
323 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
324 .addGroup(layout.createSequentialGroup()
325 .addComponent(
knownHashDbsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 272, javax.swing.GroupLayout.PREFERRED_SIZE)
326 .addGap(0, 18, Short.MAX_VALUE))
327 .addComponent(
knownBadHashDbsLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
328 .addGroup(layout.createSequentialGroup()
330 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
331 .addComponent(
jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
332 .addComponent(
jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))
333 .addComponent(
alwaysCalcHashesCheckbox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
336 layout.setVerticalGroup(
337 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
338 .addGroup(layout.createSequentialGroup()
341 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
342 .addComponent(
jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE)
343 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
345 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
346 .addComponent(
jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 53, Short.MAX_VALUE)
347 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
348 .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()
static final long serialVersionUID
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)