19 package org.sleuthkit.autopsy.modules.hashdatabase;
22 import java.awt.event.KeyEvent;
23 import java.beans.PropertyChangeEvent;
24 import java.beans.PropertyChangeListener;
26 import java.util.ArrayList;
27 import java.util.List;
28 import java.util.logging.Level;
29 import javax.swing.JComponent;
30 import javax.swing.JOptionPane;
31 import javax.swing.JTable;
32 import javax.swing.ListSelectionModel;
33 import javax.swing.event.ListSelectionEvent;
34 import javax.swing.event.ListSelectionListener;
35 import javax.swing.table.AbstractTableModel;
36 import javax.swing.table.TableCellRenderer;
38 import org.openide.util.NbBundle;
72 public void propertyChange(PropertyChangeEvent evt) {
74 EventQueue.invokeLater(
new Runnable() {
85 @NbBundle.Messages({
"HashLookupSettingsPanel.Title=Global Hash Lookup Settings"})
87 setName(Bundle.HashLookupSettingsPanel_Title());
92 hashSetTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
93 hashSetTable.getSelectionModel().addListSelectionListener(
new ListSelectionListener() {
95 public void valueChanged(ListSelectionEvent e) {
96 if (!e.getValueIsAdjusting()) {
124 indexButton.setText(NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexButtonText.index"));
152 }
catch (TskCoreException ex) {
159 }
catch (TskCoreException ex) {
166 }
catch (TskCoreException ex) {
173 if (db.isIndexing()) {
175 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexButtonText.indexing"));
177 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexStatusText.indexGen"));
180 }
else if (db.hasIndex()) {
181 if (db.hasIndexOnly()) {
183 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexStatusText.indexOnly"));
186 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexStatusText.indexed"));
189 if (db.canBeReIndexed()) {
191 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexButtonText.reIndex"));
194 indexButton.setText(NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexButtonText.index"));
199 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexStatusText.noIndex"));
201 indexButton.setText(NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexButtonText.index"));
204 }
catch (TskCoreException ex) {
208 indexButton.setText(NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexButtonText.index"));
213 if (ingestIsRunning) {
233 String shortenedPath = path;
234 if (shortenedPath.length() > 50) {
235 shortenedPath = shortenedPath.substring(0, 10 + shortenedPath.substring(10).indexOf(File.separator) + 1) +
"..." + shortenedPath.substring((shortenedPath.length() - 20) + shortenedPath.substring(shortenedPath.length() - 20).indexOf(File.separator));
237 return shortenedPath;
242 AutopsyEvent
event = (AutopsyEvent) evt;
243 if (event.getSourceType() == AutopsyEvent.SourceType.LOCAL) {
244 String eventType =
event.getPropertyName();
256 List<HashDb> unindexed =
new ArrayList<>();
259 if (!hashSet.hasIndex()) {
260 unindexed.add(hashSet);
262 }
catch (TskCoreException ex) {
268 if (unindexed.size() == 1) {
270 }
else if (unindexed.size() > 1) {
274 hashSetManager.save();
280 hashSetTableModel.refreshModel();
299 void removeThese(List<HashDb> toRemove) {
300 for (
HashDb hashDb : toRemove) {
301 hashSetManager.removeHashDatabaseInternal(hashDb);
303 hashSetTableModel.refreshModel();
317 for (
HashDb hdb : unindexed) {
318 total +=
"\n" + hdb.getHashSetName();
321 message = NbBundle.getMessage(this.getClass(),
"HashDbConfigPanel.dbsNotIndexedMsg", total);
323 message = NbBundle.getMessage(this.getClass(),
"HashDbConfigPanel.dbNotIndexedMsg", total);
325 int res = JOptionPane.showConfirmDialog(
this, message,
326 NbBundle.getMessage(
this.getClass(),
327 "HashDbConfigPanel.unindexedDbsMsg"),
328 JOptionPane.YES_NO_OPTION);
329 if (res == JOptionPane.YES_OPTION) {
330 ModalNoButtons indexingDialog =
new ModalNoButtons(
this,
new Frame(), unindexed);
331 indexingDialog.setLocationRelativeTo(null);
332 indexingDialog.setVisible(
true);
333 indexingDialog.setModal(
true);
334 hashSetTableModel.refreshModel();
336 if (res == JOptionPane.NO_OPTION) {
337 JOptionPane.showMessageDialog(
this, NbBundle.getMessage(
this.getClass(),
338 "HashDbConfigPanel.allUnindexedDbsRmFromListMsg"));
339 removeThese(unindexed);
355 JComponent cellRenderer = (JComponent) super.prepareRenderer(renderer, row, column);
356 cellRenderer.setToolTipText((String) getValueAt(row, column));
362 cellRenderer.setForeground(Color.black);
364 cellRenderer.setForeground(Color.red);
371 return hashSetTableModel.getHashSetAt(getSelectionModel().getMinSelectionIndex());
376 getSelectionModel().setSelectionInterval(index, index);
400 return hashSets.size();
405 return NbBundle.getMessage(this.getClass(),
"HashDbConfigPanel.nameColLbl");
410 return hashSets.get(rowIndex).getHashSetName();
415 return hashSets.get(rowIndex).hasIndex();
416 }
catch (TskCoreException ex) {
428 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
429 throw new UnsupportedOperationException(
430 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.editingCellsNotSupportedMsg"));
438 HashDb getHashSetAt(
int index) {
439 if (!hashSets.isEmpty() && index >= 0 && index < hashSets.size()) {
440 return hashSets.get(index);
446 int getIndexByName(String name) {
447 for (
int i = 0; i < hashSets.size(); ++i) {
448 if (hashSets.get(i).getHashSetName().equals(name)) {
455 void refreshModel() {
456 hashSets = HashDbManager.getInstance().getAllHashSets();
460 void refreshDisplay() {
461 fireTableDataChanged();
473 jLabel2 =
new javax.swing.JLabel();
474 jLabel4 =
new javax.swing.JLabel();
475 jLabel6 =
new javax.swing.JLabel();
476 jButton3 =
new javax.swing.JButton();
478 jPanel1 =
new javax.swing.JPanel();
504 jLabel2.setFont(
jLabel2.getFont().deriveFont(
jLabel2.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
507 jLabel4.setFont(
jLabel4.getFont().deriveFont(
jLabel4.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
510 jLabel6.setFont(
jLabel6.getFont().deriveFont(
jLabel6.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
516 setMinimumSize(
new java.awt.Dimension(700, 430));
517 setPreferredSize(
new java.awt.Dimension(700, 430));
519 jPanel1.setPreferredSize(
new java.awt.Dimension(671, 430));
522 ingestWarningLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png")));
526 hashSetTable.setModel(
new javax.swing.table.DefaultTableModel(
536 hashSetTable.addKeyListener(
new java.awt.event.KeyAdapter() {
537 public void keyPressed(java.awt.event.KeyEvent evt) {
544 deleteDatabaseButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/delete16.png")));
550 public void actionPerformed(java.awt.event.ActionEvent evt) {
556 importDatabaseButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/import16.png")));
562 public void actionPerformed(java.awt.event.ActionEvent evt) {
597 indexButton.addActionListener(
new java.awt.event.ActionListener() {
598 public void actionPerformed(java.awt.event.ActionEvent evt) {
606 public void actionPerformed(java.awt.event.ActionEvent evt) {
618 createDatabaseButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/new16.png")));
624 public void actionPerformed(java.awt.event.ActionEvent evt) {
639 public void actionPerformed(java.awt.event.ActionEvent evt) {
644 javax.swing.GroupLayout jPanel1Layout =
new javax.swing.GroupLayout(
jPanel1);
645 jPanel1.setLayout(jPanel1Layout);
646 jPanel1Layout.setHorizontalGroup(
647 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
648 .addGroup(jPanel1Layout.createSequentialGroup()
650 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
651 .addGroup(jPanel1Layout.createSequentialGroup()
652 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
653 .addGroup(jPanel1Layout.createSequentialGroup()
654 .addComponent(
createDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
655 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
656 .addComponent(
importDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE))
657 .addComponent(
jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE))
658 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
659 .addGroup(jPanel1Layout.createSequentialGroup()
661 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
662 .addGroup(jPanel1Layout.createSequentialGroup()
664 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
667 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
669 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
670 .addGroup(jPanel1Layout.createSequentialGroup()
671 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
673 .addComponent(
indexButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
675 .addComponent(
indexLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
678 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
679 .addComponent(
hashDbTypeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
680 .addComponent(
hashDbLocationLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
681 .addComponent(
indexPathLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
682 .addComponent(
hashDbIndexStatusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
683 .addGroup(jPanel1Layout.createSequentialGroup()
685 .addGap(0, 0, Short.MAX_VALUE))))
686 .addGroup(jPanel1Layout.createSequentialGroup()
690 .addGap(0, 0, Short.MAX_VALUE))))
691 .addGroup(jPanel1Layout.createSequentialGroup()
693 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
694 .addComponent(
optionsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE))))
695 .addGroup(jPanel1Layout.createSequentialGroup()
698 .addGap(0, 0, Short.MAX_VALUE))))
699 .addGroup(jPanel1Layout.createSequentialGroup()
700 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
702 .addComponent(
deleteDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))
703 .addGap(0, 0, Short.MAX_VALUE)))
706 jPanel1Layout.setVerticalGroup(
707 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
708 .addGroup(jPanel1Layout.createSequentialGroup()
712 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
713 .addGroup(jPanel1Layout.createSequentialGroup()
714 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
716 .addGroup(jPanel1Layout.createSequentialGroup()
718 .addComponent(
informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 3, javax.swing.GroupLayout.PREFERRED_SIZE)))
720 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
723 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
724 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
727 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
728 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
731 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
732 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
735 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
736 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
739 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
740 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
744 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
746 .addComponent(
optionsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE))
751 .addComponent(
jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 304, javax.swing.GroupLayout.PREFERRED_SIZE))
752 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
753 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
754 .addComponent(
importDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
755 .addComponent(
createDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
756 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
757 .addComponent(
deleteDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
758 .addContainerGap(33, Short.MAX_VALUE))
763 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
764 this.setLayout(layout);
765 layout.setHorizontalGroup(
766 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
767 .addGroup(layout.createSequentialGroup()
769 .addComponent(
jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 690, Short.MAX_VALUE))
771 layout.setVerticalGroup(
772 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
773 .addGroup(layout.createSequentialGroup()
775 .addComponent(
jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 410, javax.swing.GroupLayout.PREFERRED_SIZE)
776 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
782 assert hashDb != null;
788 public void propertyChange(PropertyChangeEvent evt) {
791 if (selectedHashDb != null && hashDb != null && hashDb.equals(selectedHashDb)) {
794 hashSetTableModel.refreshDisplay();
804 ModalNoButtons indexDialog =
new ModalNoButtons(
this,
new Frame(), hashDb);
805 indexDialog.setLocationRelativeTo(null);
806 indexDialog.setVisible(
true);
807 indexDialog.setModal(
true);
811 if (JOptionPane.showConfirmDialog(null,
812 NbBundle.getMessage(
this.getClass(),
813 "HashDbConfigPanel.deleteDbActionConfirmMsg"),
814 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.deleteDbActionMsg"),
815 JOptionPane.YES_NO_OPTION,
816 JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
818 if (hashDb != null) {
819 hashSetManager.removeHashDatabaseInternal(hashDb);
820 hashSetTableModel.refreshModel();
826 if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
828 if (hashDb != null) {
829 hashSetManager.removeHashDatabaseInternal(hashDb);
830 hashSetTableModel.refreshModel();
837 if (hashDb != null) {
843 HashDb hashDb =
new HashDbImportDatabaseDialog().getHashDatabase();
844 if (null != hashDb) {
845 hashSetTableModel.refreshModel();
851 HashDb hashDb =
new HashDbCreateDatabaseDialog().getHashDatabase();
852 if (null != hashDb) {
853 hashSetTableModel.refreshModel();
void importDatabaseButtonActionPerformed(java.awt.event.ActionEvent evt)
boolean getSendIngestMessages()
javax.swing.JLabel indexLabel
static synchronized IngestManager getInstance()
boolean isCellEditable(int rowIndex, int columnIndex)
javax.swing.JLabel hashDbIndexStatusLabel
javax.swing.JLabel jLabel6
void setValueAt(Object aValue, int rowIndex, int columnIndex)
javax.swing.JLabel optionsLabel
boolean getSearchDuringIngest()
javax.swing.JLabel hashDatabasesLabel
javax.swing.JLabel ingestWarningLabel
javax.swing.JLabel typeLabel
javax.swing.JLabel indexPathLabel
void updateComponentsForSelection(HashDb db)
javax.swing.JButton createDatabaseButton
void createDatabaseButtonActionPerformed(java.awt.event.ActionEvent evt)
static String shortenPath(String path)
boolean indexExists(int rowIndex)
boolean isIngestRunning()
HashLookupSettingsPanel()
javax.swing.JButton jButton3
javax.swing.JScrollPane jScrollPane1
void updateComponentsForNoSelection()
javax.swing.JLabel hashDbLocationLabel
javax.swing.JLabel nameLabel
javax.swing.JLabel locationLabel
javax.swing.JButton indexButton
javax.swing.JLabel informationLabel
void addPropertyChangeListener(PropertyChangeListener pcl)
void sendIngestMessagesCheckBoxActionPerformed(java.awt.event.ActionEvent evt)
Component prepareRenderer(TableCellRenderer renderer, int row, int column)
static final String ERROR_GETTING_INDEX_STATUS_TEXT
void indexButtonActionPerformed(java.awt.event.ActionEvent evt)
void customizeComponents()
void addIngestJobEventListener(final PropertyChangeListener listener)
static final String NO_SELECTION_TEXT
javax.swing.JLabel jLabel2
javax.swing.JScrollPane jScrollPane2
static synchronized HashDbManager getInstance()
boolean isLocalIngestJobEvent(PropertyChangeEvent evt)
javax.swing.JLabel indexPathLabelLabel
void hashSetTableKeyPressed(java.awt.event.KeyEvent evt)
void selectRowByName(String name)
javax.swing.JTable hashSetTable
javax.swing.JLabel hashDbNameLabel
String getColumnName(int column)
javax.swing.JButton addHashesToDatabaseButton
static final String ERROR_GETTING_PATH_TEXT
javax.swing.JLabel jLabel4
synchronized List< HashDb > getAllHashSets()
javax.swing.JButton deleteDatabaseButton
Object getValueAt(int rowIndex, int columnIndex)
Class<?> getColumnClass(int c)
void setSelection(int index)
javax.swing.JSeparator optionsSeparator
synchronized void loadLastSavedConfiguration()
synchronized static Logger getLogger(String name)
void showInvalidIndex(boolean plural, List< HashDb > unindexed)
javax.swing.JLabel hashDbTypeLabel
KnownFilesType getKnownFilesType()
final HashDbManager hashSetManager
void deleteDatabaseButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JSeparator informationSeparator
final HashSetTableModel hashSetTableModel
javax.swing.JButton importDatabaseButton
javax.swing.JPanel jPanel1
javax.swing.JCheckBox sendIngestMessagesCheckBox
void addHashesToDatabaseButtonActionPerformed(java.awt.event.ActionEvent evt)