Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
HashLookupSettingsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2019 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.modules.hashdatabase;
20 
21 import java.awt.Color;
22 import java.awt.Component;
23 import java.awt.EventQueue;
24 import java.awt.Frame;
25 import java.awt.event.KeyEvent;
26 import java.beans.PropertyChangeEvent;
27 import java.beans.PropertyChangeListener;
28 import java.util.ArrayList;
29 import java.util.List;
30 import java.util.logging.Level;
31 import javax.swing.JComponent;
32 import javax.swing.JOptionPane;
33 import javax.swing.JTable;
34 import javax.swing.ListSelectionModel;
35 import javax.swing.SwingUtilities;
36 import javax.swing.event.ListSelectionEvent;
37 import javax.swing.event.ListSelectionListener;
38 import javax.swing.table.AbstractTableModel;
39 import javax.swing.table.TableCellRenderer;
40 import org.netbeans.spi.options.OptionsPanelController;
41 import org.openide.util.NbBundle;
42 import org.openide.util.NbBundle.Messages;
53 import org.sleuthkit.datamodel.TskCoreException;
57 
62 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
64 
65  private static final String NSRL_URL = "https://sourceforge.net/projects/autopsy/files/NSRL/";
66  private static final String NSRL_NAME_STRING = "nsrl";
67  private static final String NO_SELECTION_TEXT = NbBundle
68  .getMessage(HashLookupSettingsPanel.class, "HashDbConfigPanel.noSelectionText");
69  private static final String ERROR_GETTING_PATH_TEXT = NbBundle
70  .getMessage(HashLookupSettingsPanel.class, "HashDbConfigPanel.errorGettingPathText");
71  private static final String ERROR_GETTING_INDEX_STATUS_TEXT = NbBundle
72  .getMessage(HashLookupSettingsPanel.class, "HashDbConfigPanel.errorGettingIndexStatusText");
73  private static final Logger logger = Logger.getLogger(HashLookupSettingsPanel.class.getName());
74  private final HashDbManager hashSetManager = HashDbManager.getInstance();
75  private final HashSetTableModel hashSetTableModel = new HashSetTableModel();
76  private final List<Integer> newReferenceSetIDs = new ArrayList<>();
77 
79  initComponents();
80  customizeComponents();
81  updateComponentsForNoSelection();
82 
83  // Listen to the ingest modules to refresh the enabled/disabled state of
84  // the components in sync with file ingest.
85  IngestManager.getInstance().addIngestJobEventListener(new PropertyChangeListener() {
86  @Override
87  public void propertyChange(PropertyChangeEvent evt) {
88  if (isLocalIngestJobEvent(evt)) {
89  EventQueue.invokeLater(new Runnable() {
90  @Override
91  public void run() {
92  updateComponents();
93  }
94  });
95  }
96  }
97  });
98 
99  HashDbManager.getInstance().addPropertyChangeListener(new PropertyChangeListener() {
100  @Override
101  public void propertyChange(PropertyChangeEvent evt) {
102  String propName = evt.getPropertyName();
103  if(propName.equals(SetEvt.DB_ADDED.toString()) ||
104  propName.equals(SetEvt.DB_DELETED.toString())) {
105  hashSetTableModel.refreshModel();
106  }
107  }
108  });
109  }
110 
111  @NbBundle.Messages({"HashLookupSettingsPanel.Title=Global Hash Lookup Settings"})
112  private void customizeComponents() {
113  setName(Bundle.HashLookupSettingsPanel_Title());
114  this.ingestWarningLabel.setVisible(false);
115  this.hashSetTable.setModel(hashSetTableModel);
116  this.hashSetTable.setTableHeader(null);
117  hashSetTable.getParent().setBackground(hashSetTable.getBackground());
118  hashSetTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
119  hashSetTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
120  @Override
121  public void valueChanged(ListSelectionEvent e) {
122  if (!e.getValueIsAdjusting()) {
123  updateComponents();
124  }
125  }
126  });
127  }
128 
129  private void updateComponents() {
130  HashDb db = ((HashSetTable) hashSetTable).getSelection();
131  if (db != null) {
132  updateComponentsForSelection(db);
133  } else {
134  updateComponentsForNoSelection();
135  }
136  }
137 
139  boolean ingestIsRunning = IngestManager.getInstance().isIngestRunning();
140 
141  // Update descriptive labels.
142  hashDbNameLabel.setText(NO_SELECTION_TEXT);
143  hashDbTypeLabel.setText(NO_SELECTION_TEXT);
144  hashDbLocationLabel.setText(NO_SELECTION_TEXT);
145  hashDbVersionLabel.setText(NO_SELECTION_TEXT);
146  hashDbOrgLabel.setText(NO_SELECTION_TEXT);
147  hashDbReadOnlyLabel.setText(NO_SELECTION_TEXT);
148  indexPathLabel.setText(NO_SELECTION_TEXT);
149 
150  // Update indexing components.
151  hashDbIndexStatusLabel.setText(NO_SELECTION_TEXT);
152  hashDbIndexStatusLabel.setForeground(Color.black);
153  indexButton.setText(NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexButtonText.index"));
154  indexButton.setEnabled(false);
155  addHashesToDatabaseButton.setEnabled(false);
156 
157  // Update ingest options.
158  sendIngestMessagesCheckBox.setSelected(false);
159  sendIngestMessagesCheckBox.setEnabled(false);
160 
161  // Update database action buttons.
162  createDatabaseButton.setEnabled(true);
163  importDatabaseButton.setEnabled(true);
164  deleteDatabaseButton.setEnabled(false);
165 
166  // Update ingest in progress warning label.
167  ingestWarningLabel.setVisible(ingestIsRunning);
168  }
169 
170  @NbBundle.Messages({"HashLookupSettingsPanel.readOnly=Read only",
171  "HashLookupSettingsPanel.editable=Editable",
172  "HashLookupSettingsPanel.updateStatusError=Error reading status",
173  "HashLookupSettingsPanel.notApplicable=N/A",
174  "HashLookupSettingsPanel.centralRepo=Central Repository"
175  })
177  boolean ingestIsRunning = IngestManager.getInstance().isIngestRunning();
178 
179  // Update descriptive labels.
180  hashDbNameLabel.setText(db.getHashSetName());
181  hashDbTypeLabel.setText(db.getKnownFilesType().getDisplayName());
182  try {
183  if (db.isUpdateable()) {
184  hashDbReadOnlyLabel.setText(Bundle.HashLookupSettingsPanel_editable());
185  } else {
186  hashDbReadOnlyLabel.setText(Bundle.HashLookupSettingsPanel_readOnly());
187  }
188  } catch (TskCoreException ex) {
189  hashDbReadOnlyLabel.setText(Bundle.HashLookupSettingsPanel_updateStatusError());
190  }
191 
192  try {
193  addHashesToDatabaseButton.setEnabled(!ingestIsRunning && db.isUpdateable());
194  } catch (TskCoreException ex) {
195  Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.SEVERE, "Error identifying if the hash set is updateable.", ex); //NON-NLS
196  addHashesToDatabaseButton.setEnabled(false);
197  }
198 
199  if (db instanceof SleuthkitHashSet) {
200  SleuthkitHashSet hashDb = (SleuthkitHashSet) db;
201 
202  // Disable the central repo fields
203  hashDbVersionLabel.setText(Bundle.HashLookupSettingsPanel_notApplicable());
204  hashDbOrgLabel.setText(Bundle.HashLookupSettingsPanel_notApplicable());
205 
206  // Enable the delete button if ingest is not running
207  deleteDatabaseButton.setEnabled(!ingestIsRunning);
208 
209  try {
210  hashDbLocationLabel.setText(db.getDatabasePath());
211  } catch (TskCoreException ex) {
212  Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.SEVERE, "Error getting hash set path of " + db.getHashSetName() + " hash set", ex); //NON-NLS
213  hashDbLocationLabel.setText(ERROR_GETTING_PATH_TEXT);
214  }
215 
216  try {
217  indexPathLabel.setText(hashDb.getIndexPath());
218  } catch (TskCoreException ex) {
219  Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.SEVERE, "Error getting index path of " + db.getHashSetName() + " hash set", ex); //NON-NLS
220  indexPathLabel.setText(ERROR_GETTING_PATH_TEXT);
221  }
222 
223  // Update indexing components.
224  try {
225  if (hashDb.isIndexing()) {
226  indexButton.setText(
227  NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexButtonText.indexing"));
228  hashDbIndexStatusLabel.setText(
229  NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexStatusText.indexGen"));
230  hashDbIndexStatusLabel.setForeground(Color.black);
231  indexButton.setEnabled(false);
232  } else if (hashDb.hasIndex()) {
233  if (hashDb.hasIndexOnly()) {
234  hashDbIndexStatusLabel.setText(
235  NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexStatusText.indexOnly"));
236  } else {
237  hashDbIndexStatusLabel.setText(
238  NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexStatusText.indexed"));
239  }
240  hashDbIndexStatusLabel.setForeground(Color.black);
241  if (hashDb.canBeReIndexed()) {
242  indexButton.setText(
243  NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexButtonText.reIndex"));
244  indexButton.setEnabled(true);
245  } else {
246  indexButton.setText(NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexButtonText.index"));
247  indexButton.setEnabled(false);
248  }
249  } else {
250  hashDbIndexStatusLabel.setText(
251  NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexStatusText.noIndex"));
252  hashDbIndexStatusLabel.setForeground(Color.red);
253  indexButton.setText(NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexButtonText.index"));
254  indexButton.setEnabled(true);
255  }
256  } catch (TskCoreException ex) {
257  Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.SEVERE, "Error getting index state of hash set", ex); //NON-NLS
258  hashDbIndexStatusLabel.setText(ERROR_GETTING_INDEX_STATUS_TEXT);
259  hashDbIndexStatusLabel.setForeground(Color.red);
260  indexButton.setText(NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.indexButtonText.index"));
261  indexButton.setEnabled(false);
262  }
263  } else {
264 
265  // Disable the file type fields/buttons
266  indexPathLabel.setText(Bundle.HashLookupSettingsPanel_notApplicable());
267  hashDbIndexStatusLabel.setText(Bundle.HashLookupSettingsPanel_notApplicable());
268  hashDbLocationLabel.setText(Bundle.HashLookupSettingsPanel_centralRepo());
269  indexButton.setEnabled(false);
270  deleteDatabaseButton.setEnabled(false);
271 
272  CentralRepoHashSet crDb = (CentralRepoHashSet) db;
273 
274  hashDbVersionLabel.setText(crDb.getVersion());
275  hashDbOrgLabel.setText(crDb.getOrgName());
276  }
277 
278  // Disable the indexing button if ingest is in progress.
279  if (ingestIsRunning) {
280  indexButton.setEnabled(false);
281  }
282 
283  // Update ingest option components.
284  sendIngestMessagesCheckBox.setSelected(db.getSendIngestMessages());
285  sendIngestMessagesCheckBox.setEnabled(!ingestIsRunning && db.getKnownFilesType().equals(KnownFilesType.KNOWN_BAD));
286 
287  // Update database action buttons.
288  createDatabaseButton.setEnabled(true);
289  importDatabaseButton.setEnabled(true);
290 
291  // Update ingest in progress warning label.
292  ingestWarningLabel.setVisible(ingestIsRunning);
293  }
294 
295  private boolean isLocalIngestJobEvent(PropertyChangeEvent evt) {
296  if (evt instanceof AutopsyEvent) {
297  AutopsyEvent event = (AutopsyEvent) evt;
298  if (event.getSourceType() == AutopsyEvent.SourceType.LOCAL) {
299  String eventType = event.getPropertyName();
300  return (eventType.equals(IngestManager.IngestJobEvent.STARTED.toString())
301  || eventType.equals(IngestManager.IngestJobEvent.CANCELLED.toString())
302  || eventType.equals(IngestManager.IngestJobEvent.COMPLETED.toString()));
303  }
304  }
305  return false;
306  }
307 
308  @Override
309  @Messages({"HashLookupSettingsPanel.saveFail.message=Couldn't save hash set settings.",
310  "HashLookupSettingsPanel.saveFail.title=Save Fail"})
311  public void saveSettings() {
312  // Clear out the list of new central repo hash sets. They don't need to be
313  // indexed so will all be saved on both code paths.
314  newReferenceSetIDs.clear();
315 
316  //Checking for for any unindexed databases
317  List<SleuthkitHashSet> unindexed = new ArrayList<>();
318  for (HashDb db : hashSetManager.getAllHashSets()) {
319  if (db instanceof SleuthkitHashSet) {
320  try {
321  SleuthkitHashSet hashDatabase = (SleuthkitHashSet) db;
322  if (!hashDatabase.hasIndex()) {
323  unindexed.add(hashDatabase);
324  }
325  } catch (TskCoreException ex) {
326  Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.SEVERE, "Error getting index info for hash set", ex); //NON-NLS
327  }
328  }
329  }
330 
331  // If there are unindexed databases, give the user the option to index them now. This
332  // needs to be on the EDT, and will save the hash settings after completing
333  if (!unindexed.isEmpty()) {
334  SwingUtilities.invokeLater(new Runnable() {
335  @Override
336  public void run() {
337  //If unindexed ones are found, show a popup box that will either index them, or remove them.
338  if (!unindexed.isEmpty()) {
339  showInvalidIndex(unindexed);
340  }
341  }
342  });
343  } else {
344  try {
345  hashSetManager.save();
347  SwingUtilities.invokeLater(() -> {
348  JOptionPane.showMessageDialog(this, Bundle.HashLookupSettingsPanel_saveFail_message(), Bundle.HashLookupSettingsPanel_saveFail_title(), JOptionPane.ERROR_MESSAGE);
349  });
350  }
351  }
352  }
353 
354  @Override
355  public void load() {
356  hashSetTable.clearSelection();
357  hashSetTableModel.refreshModel();
358  }
359 
360  @Override
361  public void store() {
362  saveSettings();
363  }
364 
365  public void cancel() {
366  /*
367  * Revert back to last settings only if the user could have made
368  * changes. Doing this while ingest is running causes hash dbs to be
369  * closed while they are still being used.
370  */
371  if (IngestManager.getInstance().isIngestRunning() == false) {
372  // Remove any new central repo hash sets from the database
373  for (int refID : newReferenceSetIDs) {
374  try {
377  } else {
378  // This is the case where the user imported a database, then switched over to the central
379  // repo panel and disabled it before cancelling. We can't delete the database at this point.
380  Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.WARNING, "Error reverting central repository hash sets"); //NON-NLS
381  }
382  } catch (CentralRepoException ex) {
383  Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.SEVERE, "Error reverting central repository hash sets", ex); //NON-NLS
384  }
385  }
387  }
388  }
389 
390  @Messages({"# {0} - hash lookup name", "HashLookupSettingsPanel.removeDatabaseFailure.message=Failed to remove hash lookup: {0}"})
391  void removeThese(List<SleuthkitHashSet> toRemove) {
392  for (SleuthkitHashSet hashDb : toRemove) {
393  try {
394  hashSetManager.removeHashDatabaseNoSave(hashDb);
395  } catch (HashDbManager.HashDbManagerException ex) {
396  JOptionPane.showMessageDialog(this, Bundle.HashLookupSettingsPanel_removeDatabaseFailure_message(hashDb.getHashSetName()));
397  }
398  }
399  hashSetTableModel.refreshModel();
400  }
401 
409  @NbBundle.Messages({"# {0} - nsrlUrlAddress",
410  "HashLookupSettingsPanel.removeUnindexedNsrl.text=Instead of indexing the NSRL, please download an already indexed version available here:\n{0}",
411  "# {0} - nsrlHashSet",
412  "HashLookupSettingsPanel.unindexedNsrl.base=The following hash set appears to be an unindexed version of the NSRL, it will be removed from the list.\nHash set:{0}\n",
413  "# {0} - nsrlHashSets",
414  "HashLookupSettingsPanel.unindexedNsrls.base=The following hash sets appear to be unindexed versions of the NSRL, they will be removed from the list.\nHash sets:{0}\n",
415  "HashLookupSettingsPanel.removeUnindexedNsrl.title=Unindexed NSRL(s) will be removed"})
416  private void showInvalidIndex(List<SleuthkitHashSet> unindexed) {
417  String total = "";
418  String nsrlTotal = "";
419 
420  List<SleuthkitHashSet> nsrlHashsets = new ArrayList<>();
421  for (SleuthkitHashSet hdb : unindexed) {
422  //check if this is the NSRL if so point users toward already indexed versions
423  if (isWindows() && hdb.getHashSetName().toLowerCase().contains(NSRL_NAME_STRING)) {
424  nsrlHashsets.add(hdb);
425  nsrlTotal += "\n" + hdb.getHashSetName();
426  } else {
427  total += "\n" + hdb.getHashSetName();
428  }
429  }
430  if (!nsrlHashsets.isEmpty()) {
431  String message;
432  if (nsrlHashsets.size() > 1) {
433  message = Bundle.HashLookupSettingsPanel_unindexedNsrls_base(nsrlTotal) + Bundle.HashLookupSettingsPanel_removeUnindexedNsrl_text(NSRL_URL);
434  } else {
435  message = Bundle.HashLookupSettingsPanel_unindexedNsrl_base(nsrlTotal) + Bundle.HashLookupSettingsPanel_removeUnindexedNsrl_text(NSRL_URL);
436  }
437  JOptionPane.showMessageDialog(this, message, Bundle.HashLookupSettingsPanel_removeUnindexedNsrl_title(), JOptionPane.INFORMATION_MESSAGE);
438  for (SleuthkitHashSet hdb : nsrlHashsets) {
439  unindexed.remove(hdb);
440  }
441  removeThese(nsrlHashsets);
442  }
443  String message = NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.dbNotIndexedMsg", total);
444  if (unindexed.isEmpty()) {
445  return;
446  } else if (unindexed.size() > 1) {
447  message = NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.dbsNotIndexedMsg", total);
448  }
449  int res = JOptionPane.showConfirmDialog(this, message,
450  NbBundle.getMessage(this.getClass(),
451  "HashDbConfigPanel.unindexedDbsMsg"),
452  JOptionPane.YES_NO_OPTION);
453  if (res == JOptionPane.YES_OPTION) {
454  ModalNoButtons indexingDialog = new ModalNoButtons(this, new Frame(), unindexed);
455  indexingDialog.setLocationRelativeTo(null);
456  indexingDialog.setVisible(true);
457  indexingDialog.setModal(true);
458  hashSetTableModel.refreshModel();
459  }
460  if (res == JOptionPane.NO_OPTION) {
461  JOptionPane.showMessageDialog(this, NbBundle.getMessage(this.getClass(),
462  "HashDbConfigPanel.allUnindexedDbsRmFromListMsg"));
463  removeThese(unindexed);
464  }
465  try {
466  hashSetManager.save();
468  JOptionPane.showMessageDialog(this, Bundle.HashLookupSettingsPanel_saveFail_message(), Bundle.HashLookupSettingsPanel_saveFail_title(), JOptionPane.ERROR_MESSAGE);
469  }
470  }
471 
472  boolean valid() {
473  return true;
474  }
475 
479  private class HashSetTable extends JTable {
480 
481  @Override
482  public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
483  // Use the hash set name as the cell text.
484  JComponent cellRenderer = (JComponent) super.prepareRenderer(renderer, row, column);
485  cellRenderer.setToolTipText((String) getValueAt(row, column));
486 
487  // Give the user a visual indication of any hash sets with a hash
488  // database that needs to be indexed by displaying the hash set name
489  // in red.
490  if (hashSetTableModel.isValid(row)) {
491  cellRenderer.setForeground(Color.black);
492  } else {
493  cellRenderer.setForeground(Color.red);
494  }
495 
496  return cellRenderer;
497  }
498 
499  public HashDb getSelection() {
500  return hashSetTableModel.getHashSetAt(getSelectionModel().getMinSelectionIndex());
501  }
502 
503  public void setSelection(int index) {
504  if (index >= 0 && index < hashSetTable.getRowCount()) {
505  getSelectionModel().setSelectionInterval(index, index);
506  }
507  }
508 
509  public void selectRowByDatabase(HashDb db) {
510  setSelection(hashSetTableModel.getIndexByDatabase(db));
511  }
512 
513  @Deprecated
514  public void selectRowByName(String name) {
515  setSelection(hashSetTableModel.getIndexByName(name));
516  }
517  }
518 
523  private class HashSetTableModel extends AbstractTableModel {
524 
525  List<HashDb> hashSets = HashDbManager.getInstance().getAllHashSets();
526 
527  @Override
528  public int getColumnCount() {
529  return 1;
530  }
531 
532  @Override
533  public int getRowCount() {
534  return hashSets.size();
535  }
536 
537  @Override
538  public String getColumnName(int column) {
539  return NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.nameColLbl");
540  }
541 
542  @Override
543  public Object getValueAt(int rowIndex, int columnIndex) {
544  return hashSets.get(rowIndex).getDisplayName();
545  }
546 
547  private boolean isValid(int rowIndex) {
548  try {
549  return hashSets.get(rowIndex).isValid();
550  } catch (TskCoreException ex) {
551  Logger.getLogger(HashSetTableModel.class.getName()).log(Level.SEVERE, "Error getting index info for hash set", ex); //NON-NLS
552  return false;
553  }
554  }
555 
556  @Override
557  public boolean isCellEditable(int rowIndex, int columnIndex) {
558  return false;
559  }
560 
561  @Override
562  public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
563  throw new UnsupportedOperationException(
564  NbBundle.getMessage(this.getClass(), "HashDbConfigPanel.editingCellsNotSupportedMsg"));
565  }
566 
567  @Override
568  public Class<?> getColumnClass(int c) {
569  return getValueAt(0, c).getClass();
570  }
571 
572  HashDb getHashSetAt(int index) {
573  if (!hashSets.isEmpty() && index >= 0 && index < hashSets.size()) {
574  return hashSets.get(index);
575  } else {
576  return null;
577  }
578  }
579 
580  int getIndexByDatabase(HashDb db) {
581  for (int i = 0; i < hashSets.size(); ++i) {
582  if (hashSets.get(i).equals(db)) {
583  return i;
584  }
585  }
586  return -1;
587  }
588 
589  @Deprecated
590  int getIndexByName(String name) {
591  for (int i = 0; i < hashSets.size(); ++i) {
592  if (hashSets.get(i).getHashSetName().equals(name)) {
593  return i;
594  }
595  }
596  return -1;
597  }
598 
599  void refreshModel() {
600  hashSets = HashDbManager.getInstance().getAllHashSets();
601  refreshDisplay();
602  }
603 
604  void refreshDisplay() {
605  fireTableDataChanged();
606  }
607  }
608 
614  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
615  private void initComponents() {
616 
617  jScrollPane2 = new javax.swing.JScrollPane();
618  jPanel1 = new javax.swing.JPanel();
619  hashDatabasesLabel = new javax.swing.JLabel();
620  jScrollPane1 = new javax.swing.JScrollPane();
621  hashSetTable = new HashSetTable();
622  createDatabaseButton = new javax.swing.JButton();
623  importDatabaseButton = new javax.swing.JButton();
624  deleteDatabaseButton = new javax.swing.JButton();
625  informationLabel = new javax.swing.JLabel();
626  informationScrollPanel = new javax.swing.JScrollPane();
627  informationPanel = new javax.swing.JPanel();
628  nameLabel = new javax.swing.JLabel();
629  hashDbNameLabel = new javax.swing.JLabel();
630  typeLabel = new javax.swing.JLabel();
631  hashDbTypeLabel = new javax.swing.JLabel();
632  locationLabel = new javax.swing.JLabel();
633  hashDbLocationLabel = new javax.swing.JLabel();
634  versionLabel = new javax.swing.JLabel();
635  hashDbVersionLabel = new javax.swing.JLabel();
636  orgLabel = new javax.swing.JLabel();
637  hashDbOrgLabel = new javax.swing.JLabel();
638  readOnlyLabel = new javax.swing.JLabel();
639  hashDbReadOnlyLabel = new javax.swing.JLabel();
640  indexPathLabelLabel = new javax.swing.JLabel();
641  indexPathLabel = new javax.swing.JLabel();
642  indexLabel = new javax.swing.JLabel();
643  hashDbIndexStatusLabel = new javax.swing.JLabel();
644  indexButton = new javax.swing.JButton();
645  addHashesToDatabaseButton = new javax.swing.JButton();
646  sendIngestMessagesCheckBox = new javax.swing.JCheckBox();
647  ingestWarningLabel = new javax.swing.JLabel();
648 
649  org.openide.awt.Mnemonics.setLocalizedText(hashDatabasesLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.hashDatabasesLabel.text")); // NOI18N
650 
651  hashSetTable.setModel(new javax.swing.table.DefaultTableModel(
652  new Object [][] {
653 
654  },
655  new String [] {
656 
657  }
658  ));
659  hashSetTable.setShowHorizontalLines(false);
660  hashSetTable.setShowVerticalLines(false);
661  hashSetTable.addKeyListener(new java.awt.event.KeyAdapter() {
662  public void keyPressed(java.awt.event.KeyEvent evt) {
663  hashSetTableKeyPressed(evt);
664  }
665  });
666  jScrollPane1.setViewportView(hashSetTable);
667 
668  createDatabaseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/new16.png"))); // NOI18N
669  org.openide.awt.Mnemonics.setLocalizedText(createDatabaseButton, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.createDatabaseButton.text")); // NOI18N
670  createDatabaseButton.setToolTipText(org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.createDatabaseButton.toolTipText")); // NOI18N
671  createDatabaseButton.setMaximumSize(new java.awt.Dimension(140, 25));
672  createDatabaseButton.setMinimumSize(new java.awt.Dimension(140, 25));
673  createDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
674  public void actionPerformed(java.awt.event.ActionEvent evt) {
675  createDatabaseButtonActionPerformed(evt);
676  }
677  });
678 
679  importDatabaseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/import16.png"))); // NOI18N
680  org.openide.awt.Mnemonics.setLocalizedText(importDatabaseButton, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.importDatabaseButton.text")); // NOI18N
681  importDatabaseButton.setToolTipText(org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.importDatabaseButton.toolTipText")); // NOI18N
682  importDatabaseButton.setMaximumSize(new java.awt.Dimension(140, 25));
683  importDatabaseButton.setMinimumSize(new java.awt.Dimension(140, 25));
684  importDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
685  public void actionPerformed(java.awt.event.ActionEvent evt) {
686  importDatabaseButtonActionPerformed(evt);
687  }
688  });
689 
690  deleteDatabaseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/delete16.png"))); // NOI18N
691  org.openide.awt.Mnemonics.setLocalizedText(deleteDatabaseButton, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.deleteDatabaseButton.text")); // NOI18N
692  deleteDatabaseButton.setMaximumSize(new java.awt.Dimension(140, 25));
693  deleteDatabaseButton.setMinimumSize(new java.awt.Dimension(140, 25));
694  deleteDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
695  public void actionPerformed(java.awt.event.ActionEvent evt) {
696  deleteDatabaseButtonActionPerformed(evt);
697  }
698  });
699 
700  org.openide.awt.Mnemonics.setLocalizedText(informationLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.informationLabel.text")); // NOI18N
701 
702  informationScrollPanel.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
703 
704  org.openide.awt.Mnemonics.setLocalizedText(nameLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.nameLabel.text")); // NOI18N
705 
706  org.openide.awt.Mnemonics.setLocalizedText(hashDbNameLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.hashDbNameLabel.text")); // NOI18N
707 
708  org.openide.awt.Mnemonics.setLocalizedText(typeLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.typeLabel.text")); // NOI18N
709 
710  org.openide.awt.Mnemonics.setLocalizedText(hashDbTypeLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.hashDbTypeLabel.text")); // NOI18N
711 
712  org.openide.awt.Mnemonics.setLocalizedText(locationLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.locationLabel.text")); // NOI18N
713 
714  org.openide.awt.Mnemonics.setLocalizedText(hashDbLocationLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.hashDbLocationLabel.text")); // NOI18N
715 
716  org.openide.awt.Mnemonics.setLocalizedText(versionLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.versionLabel.text_1")); // NOI18N
717 
718  org.openide.awt.Mnemonics.setLocalizedText(hashDbVersionLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.hashDbVersionLabel.text_1")); // NOI18N
719 
720  org.openide.awt.Mnemonics.setLocalizedText(orgLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.orgLabel.text_1")); // NOI18N
721 
722  org.openide.awt.Mnemonics.setLocalizedText(hashDbOrgLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.hashDbOrgLabel.text_1")); // NOI18N
723 
724  org.openide.awt.Mnemonics.setLocalizedText(readOnlyLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.readOnlyLabel.text_1")); // NOI18N
725 
726  org.openide.awt.Mnemonics.setLocalizedText(hashDbReadOnlyLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.hashDbReadOnlyLabel.text_1")); // NOI18N
727 
728  org.openide.awt.Mnemonics.setLocalizedText(indexPathLabelLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.indexPathLabelLabel.text")); // NOI18N
729 
730  org.openide.awt.Mnemonics.setLocalizedText(indexPathLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.indexPathLabel.text")); // NOI18N
731 
732  org.openide.awt.Mnemonics.setLocalizedText(indexLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.indexLabel.text")); // NOI18N
733 
734  org.openide.awt.Mnemonics.setLocalizedText(hashDbIndexStatusLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.hashDbIndexStatusLabel.text")); // NOI18N
735 
736  javax.swing.GroupLayout informationPanelLayout = new javax.swing.GroupLayout(informationPanel);
737  informationPanel.setLayout(informationPanelLayout);
738  informationPanelLayout.setHorizontalGroup(
739  informationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
740  .addGroup(informationPanelLayout.createSequentialGroup()
741  .addContainerGap()
742  .addGroup(informationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
743  .addGroup(informationPanelLayout.createSequentialGroup()
744  .addComponent(locationLabel)
745  .addGap(18, 18, 18)
746  .addComponent(hashDbLocationLabel))
747  .addGroup(informationPanelLayout.createSequentialGroup()
748  .addComponent(nameLabel)
749  .addGap(18, 18, 18)
750  .addComponent(hashDbNameLabel))
751  .addGroup(informationPanelLayout.createSequentialGroup()
752  .addComponent(typeLabel)
753  .addGap(18, 18, 18)
754  .addComponent(hashDbTypeLabel))
755  .addGroup(informationPanelLayout.createSequentialGroup()
756  .addComponent(versionLabel)
757  .addGap(18, 18, 18)
758  .addComponent(hashDbVersionLabel))
759  .addGroup(informationPanelLayout.createSequentialGroup()
760  .addComponent(orgLabel)
761  .addGap(18, 18, 18)
762  .addComponent(hashDbOrgLabel))
763  .addGroup(informationPanelLayout.createSequentialGroup()
764  .addComponent(readOnlyLabel)
765  .addGap(18, 18, 18)
766  .addComponent(hashDbReadOnlyLabel))
767  .addGroup(informationPanelLayout.createSequentialGroup()
768  .addComponent(indexLabel)
769  .addGap(18, 18, 18)
770  .addComponent(hashDbIndexStatusLabel))
771  .addGroup(informationPanelLayout.createSequentialGroup()
772  .addComponent(indexPathLabelLabel)
773  .addGap(18, 18, 18)
774  .addComponent(indexPathLabel)))
775  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
776  );
777 
778  informationPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {indexLabel, indexPathLabelLabel, locationLabel, nameLabel, orgLabel, readOnlyLabel, typeLabel, versionLabel});
779 
780  informationPanelLayout.setVerticalGroup(
781  informationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
782  .addGroup(informationPanelLayout.createSequentialGroup()
783  .addGroup(informationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
784  .addComponent(nameLabel)
785  .addComponent(hashDbNameLabel))
786  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
787  .addGroup(informationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
788  .addComponent(typeLabel)
789  .addComponent(hashDbTypeLabel))
790  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
791  .addGroup(informationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
792  .addComponent(locationLabel)
793  .addComponent(hashDbLocationLabel))
794  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
795  .addGroup(informationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
796  .addComponent(versionLabel)
797  .addComponent(hashDbVersionLabel))
798  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
799  .addGroup(informationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
800  .addComponent(orgLabel)
801  .addComponent(hashDbOrgLabel))
802  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
803  .addGroup(informationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
804  .addComponent(readOnlyLabel)
805  .addComponent(hashDbReadOnlyLabel))
806  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
807  .addGroup(informationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
808  .addComponent(indexPathLabelLabel)
809  .addComponent(indexPathLabel))
810  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
811  .addGroup(informationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
812  .addComponent(indexLabel)
813  .addComponent(hashDbIndexStatusLabel))
814  .addGap(0, 49, Short.MAX_VALUE))
815  );
816 
817  informationScrollPanel.setViewportView(informationPanel);
818 
819  org.openide.awt.Mnemonics.setLocalizedText(indexButton, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.indexButton.text")); // NOI18N
820  indexButton.setEnabled(false);
821  indexButton.addActionListener(new java.awt.event.ActionListener() {
822  public void actionPerformed(java.awt.event.ActionEvent evt) {
823  indexButtonActionPerformed(evt);
824  }
825  });
826 
827  org.openide.awt.Mnemonics.setLocalizedText(addHashesToDatabaseButton, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.addHashesToDatabaseButton.text")); // NOI18N
828  addHashesToDatabaseButton.setEnabled(false);
829  addHashesToDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
830  public void actionPerformed(java.awt.event.ActionEvent evt) {
831  addHashesToDatabaseButtonActionPerformed(evt);
832  }
833  });
834 
835  org.openide.awt.Mnemonics.setLocalizedText(sendIngestMessagesCheckBox, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.sendIngestMessagesCheckBox.text")); // NOI18N
836  sendIngestMessagesCheckBox.addActionListener(new java.awt.event.ActionListener() {
837  public void actionPerformed(java.awt.event.ActionEvent evt) {
838  sendIngestMessagesCheckBoxActionPerformed(evt);
839  }
840  });
841 
842  ingestWarningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png"))); // NOI18N
843  org.openide.awt.Mnemonics.setLocalizedText(ingestWarningLabel, org.openide.util.NbBundle.getMessage(HashLookupSettingsPanel.class, "HashLookupSettingsPanel.ingestWarningLabel.text")); // NOI18N
844 
845  javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
846  jPanel1.setLayout(jPanel1Layout);
847  jPanel1Layout.setHorizontalGroup(
848  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
849  .addGroup(jPanel1Layout.createSequentialGroup()
850  .addContainerGap()
851  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
852  .addGroup(jPanel1Layout.createSequentialGroup()
853  .addGap(1, 1, 1)
854  .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
855  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
856  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
857  .addComponent(informationScrollPanel)
858  .addGroup(jPanel1Layout.createSequentialGroup()
859  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
860  .addGroup(jPanel1Layout.createSequentialGroup()
861  .addComponent(indexButton)
862  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
863  .addComponent(addHashesToDatabaseButton))
864  .addComponent(sendIngestMessagesCheckBox)
865  .addComponent(ingestWarningLabel)
866  .addComponent(informationLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE))
867  .addGap(0, 0, Short.MAX_VALUE)))
868  .addContainerGap())
869  .addGroup(jPanel1Layout.createSequentialGroup()
870  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
871  .addComponent(hashDatabasesLabel)
872  .addGroup(jPanel1Layout.createSequentialGroup()
873  .addComponent(createDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
874  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
875  .addComponent(importDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
876  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
877  .addComponent(deleteDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
878  .addGap(0, 0, Short.MAX_VALUE))))
879  );
880  jPanel1Layout.setVerticalGroup(
881  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
882  .addGroup(jPanel1Layout.createSequentialGroup()
883  .addContainerGap()
884  .addComponent(hashDatabasesLabel)
885  .addGap(6, 6, 6)
886  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
887  .addGroup(jPanel1Layout.createSequentialGroup()
888  .addComponent(informationLabel)
889  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
890  .addComponent(informationScrollPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)
891  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
892  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
893  .addComponent(indexButton)
894  .addComponent(addHashesToDatabaseButton))
895  .addGap(18, 18, 18)
896  .addComponent(sendIngestMessagesCheckBox)
897  .addGap(18, 18, 18)
898  .addComponent(ingestWarningLabel)
899  .addGap(0, 0, Short.MAX_VALUE))
900  .addComponent(jScrollPane1))
901  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
902  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
903  .addComponent(createDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
904  .addComponent(importDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
905  .addComponent(deleteDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
906  .addContainerGap())
907  );
908 
909  jScrollPane2.setViewportView(jPanel1);
910 
911  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
912  this.setLayout(layout);
913  layout.setHorizontalGroup(
914  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
915  .addComponent(jScrollPane2)
916  );
917  layout.setVerticalGroup(
918  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
919  .addComponent(jScrollPane2)
920  );
921  }// </editor-fold>//GEN-END:initComponents
922 
923  private void addHashesToDatabaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addHashesToDatabaseButtonActionPerformed
924 
925  HashDb hashDb = ((HashSetTable) hashSetTable).getSelection();
927  }//GEN-LAST:event_addHashesToDatabaseButtonActionPerformed
928 
929  private void createDatabaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createDatabaseButtonActionPerformed
930  HashDb hashDb = new HashDbCreateDatabaseDialog().getHashDatabase();
931  if (null != hashDb) {
932  if (hashDb instanceof CentralRepoHashSet) {
933  int newDbIndex = ((CentralRepoHashSet) hashDb).getReferenceSetID();
934  newReferenceSetIDs.add(newDbIndex);
935  }
936 
937  hashSetTableModel.refreshModel();
938  ((HashSetTable) hashSetTable).selectRowByDatabase(hashDb);
939  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
940  }
941  }//GEN-LAST:event_createDatabaseButtonActionPerformed
942 
943  private void sendIngestMessagesCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendIngestMessagesCheckBoxActionPerformed
944  HashDb hashDb = ((HashSetTable) hashSetTable).getSelection();
945  if (hashDb != null) {
946  hashDb.setSendIngestMessages(sendIngestMessagesCheckBox.isSelected());
947  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
948  }
949  }//GEN-LAST:event_sendIngestMessagesCheckBoxActionPerformed
950 
956  private boolean isWindows() {
957  return PlatformUtil.getOSName().toLowerCase().startsWith("Windows");
958  }
959 
960  @NbBundle.Messages({"HashLookupSettingsPanel.indexNsrl.text=This hash set appears to be the NSRL, it will be removed from the list.\n",
961  "HashLookupSettingsPanel.indexNsrl.title=NSRL will not be indexed"})
962  private void indexButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_indexButtonActionPerformed
963  final HashDb hashDatabase = ((HashSetTable) hashSetTable).getSelection();
964  assert hashDatabase != null;
965  assert hashDatabase instanceof SleuthkitHashSet;
966 
967  // Add a listener for the INDEXING_DONE event. This listener will update
968  // the UI.
969  SleuthkitHashSet hashDb = (SleuthkitHashSet) hashDatabase;
970  if (isWindows() && hashDb.getHashSetName().toLowerCase().contains(NSRL_NAME_STRING)) {
971  JOptionPane.showMessageDialog(this, Bundle.HashLookupSettingsPanel_indexNsrl_text() + Bundle.HashLookupSettingsPanel_removeUnindexedNsrl_text(NSRL_URL), Bundle.HashLookupSettingsPanel_indexNsrl_title(), JOptionPane.INFORMATION_MESSAGE);
972  try {
973  hashSetManager.removeHashDatabaseNoSave(hashDatabase);
974  hashSetTableModel.refreshModel();
975  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
977  logger.log(Level.WARNING, "Unable to remove unindexed NSRL from hash set list", ex);
978  }
979  } else {
980  hashDb.addPropertyChangeListener(new PropertyChangeListener() {
981  @Override
982  public void propertyChange(PropertyChangeEvent evt) {
983  if (evt.getPropertyName().equals(SleuthkitHashSet.Event.INDEXING_DONE.toString())) {
984  HashDb selectedHashDb = ((HashSetTable) hashSetTable).getSelection();
985  if (selectedHashDb != null && hashDb != null && hashDb.equals(selectedHashDb)) {
986  updateComponents();
987  }
988  hashSetTableModel.refreshDisplay();
989  }
990  }
991  });
992 
993  // Display a modal dialog box to kick off the indexing on a worker thread
994  // and try to persuade the user to wait for the indexing task to finish.
995  // TODO: If the user waits, this defeats the purpose of doing the indexing on a worker thread.
996  // But if the user cancels the dialog, other operations on the database
997  // may be attempted when it is not in a suitable state.
998  ModalNoButtons indexDialog = new ModalNoButtons(this, new Frame(), hashDb);
999  indexDialog.setLocationRelativeTo(null);
1000  indexDialog.setVisible(true);
1001  indexDialog.setModal(true);
1002  }
1003  }//GEN-LAST:event_indexButtonActionPerformed
1004 
1005  private void importDatabaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importDatabaseButtonActionPerformed
1006  HashDb hashDb = new HashDbImportDatabaseDialog().getHashDatabase();
1007  if (null != hashDb) {
1008  if (hashDb instanceof CentralRepoHashSet) {
1009  int newReferenceSetID = ((CentralRepoHashSet) hashDb).getReferenceSetID();
1010  newReferenceSetIDs.add(newReferenceSetID);
1011  }
1012 
1013  hashSetTableModel.refreshModel();
1014  ((HashSetTable) hashSetTable).selectRowByDatabase(hashDb);
1015  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1016  }
1017  }//GEN-LAST:event_importDatabaseButtonActionPerformed
1018 
1019  @Messages({
1020  "HashLookupSettingsPanel.promptTitle.deleteHashDb=Delete Hash Database from Configuration",
1021  "HashLookupSettingsPanel.promptMessage.deleteHashDb=This will make the hash database unavailable for lookup. Do you want to proceed?\n\nNote: The hash database can still be re-imported later."
1022  })
1023  private void deleteDatabaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteDatabaseButtonActionPerformed
1024  if (JOptionPane.showConfirmDialog(this,
1025  Bundle.HashLookupSettingsPanel_promptMessage_deleteHashDb(),
1026  Bundle.HashLookupSettingsPanel_promptTitle_deleteHashDb(),
1027  JOptionPane.YES_NO_OPTION,
1028  JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
1029  HashDb hashDb = ((HashSetTable) hashSetTable).getSelection();
1030  if (hashDb != null) {
1031  try {
1032  hashSetManager.removeHashDatabaseNoSave(hashDb);
1033  } catch (HashDbManager.HashDbManagerException ex) {
1034  JOptionPane.showMessageDialog(this, Bundle.HashLookupSettingsPanel_removeDatabaseFailure_message(hashDb.getHashSetName()));
1035  }
1036  hashSetTableModel.refreshModel();
1037  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1038  }
1039  }
1040  }//GEN-LAST:event_deleteDatabaseButtonActionPerformed
1041 
1042  private void hashSetTableKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_hashSetTableKeyPressed
1043  if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
1044  HashDb hashDb = ((HashSetTable) hashSetTable).getSelection();
1045  if (hashDb != null) {
1046  try {
1047  hashSetManager.removeHashDatabaseNoSave(hashDb);
1048  } catch (HashDbManager.HashDbManagerException ex) {
1049  JOptionPane.showMessageDialog(this, Bundle.HashLookupSettingsPanel_removeDatabaseFailure_message(hashDb.getHashSetName()));
1050  }
1051  hashSetTableModel.refreshModel();
1052  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
1053  }
1054  }
1055  }//GEN-LAST:event_hashSetTableKeyPressed
1056 
1057  // Variables declaration - do not modify//GEN-BEGIN:variables
1058  private javax.swing.JButton addHashesToDatabaseButton;
1059  private javax.swing.JButton createDatabaseButton;
1060  private javax.swing.JButton deleteDatabaseButton;
1061  private javax.swing.JLabel hashDatabasesLabel;
1062  private javax.swing.JLabel hashDbIndexStatusLabel;
1063  private javax.swing.JLabel hashDbLocationLabel;
1064  private javax.swing.JLabel hashDbNameLabel;
1065  private javax.swing.JLabel hashDbOrgLabel;
1066  private javax.swing.JLabel hashDbReadOnlyLabel;
1067  private javax.swing.JLabel hashDbTypeLabel;
1068  private javax.swing.JLabel hashDbVersionLabel;
1069  private javax.swing.JTable hashSetTable;
1070  private javax.swing.JButton importDatabaseButton;
1071  private javax.swing.JButton indexButton;
1072  private javax.swing.JLabel indexLabel;
1073  private javax.swing.JLabel indexPathLabel;
1074  private javax.swing.JLabel indexPathLabelLabel;
1075  private javax.swing.JLabel informationLabel;
1076  private javax.swing.JPanel informationPanel;
1077  private javax.swing.JScrollPane informationScrollPanel;
1078  private javax.swing.JLabel ingestWarningLabel;
1079  private javax.swing.JPanel jPanel1;
1080  private javax.swing.JScrollPane jScrollPane1;
1081  private javax.swing.JScrollPane jScrollPane2;
1082  private javax.swing.JLabel locationLabel;
1083  private javax.swing.JLabel nameLabel;
1084  private javax.swing.JLabel orgLabel;
1085  private javax.swing.JLabel readOnlyLabel;
1086  private javax.swing.JCheckBox sendIngestMessagesCheckBox;
1087  private javax.swing.JLabel typeLabel;
1088  private javax.swing.JLabel versionLabel;
1089  // End of variables declaration//GEN-END:variables
1090 }
static synchronized IngestManager getInstance()
synchronized void addPropertyChangeListener(PropertyChangeListener listener)
Component prepareRenderer(TableCellRenderer renderer, int row, int column)
void addIngestJobEventListener(final PropertyChangeListener listener)
synchronized void removeHashDatabaseNoSave(HashDb hashDb)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.