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