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.SwingUtilities;
34 import javax.swing.event.ListSelectionEvent;
35 import javax.swing.event.ListSelectionListener;
36 import javax.swing.table.AbstractTableModel;
37 import javax.swing.table.TableCellRenderer;
38 import org.netbeans.spi.options.OptionsPanelController;
39 import org.openide.util.NbBundle;
40 import org.openide.util.NbBundle.Messages;
74 public void propertyChange(PropertyChangeEvent evt) {
76 EventQueue.invokeLater(
new Runnable() {
87 @NbBundle.Messages({
"HashLookupSettingsPanel.Title=Global Hash Lookup Settings"})
89 setName(Bundle.HashLookupSettingsPanel_Title());
94 hashSetTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
95 hashSetTable.getSelectionModel().addListSelectionListener(
new ListSelectionListener() {
97 public void valueChanged(ListSelectionEvent e) {
98 if (!e.getValueIsAdjusting()) {
126 indexButton.setText(NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexButtonText.index"));
175 if (db.isIndexing()) {
177 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexButtonText.indexing"));
179 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexStatusText.indexGen"));
182 }
else if (db.hasIndex()) {
185 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexStatusText.indexOnly"));
188 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexStatusText.indexed"));
191 if (db.canBeReIndexed()) {
193 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexButtonText.reIndex"));
196 indexButton.setText(NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexButtonText.index"));
201 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexStatusText.noIndex"));
203 indexButton.setText(NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexButtonText.index"));
210 indexButton.setText(NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.indexButtonText.index"));
215 if (ingestIsRunning) {
235 String shortenedPath = path;
236 if (shortenedPath.length() > 50) {
237 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));
239 return shortenedPath;
244 AutopsyEvent
event = (AutopsyEvent) evt;
245 if (event.getSourceType() == AutopsyEvent.SourceType.LOCAL) {
246 String eventType =
event.getPropertyName();
256 @Messages({
"HashLookupSettingsPanel.saveFail.message=Couldn't save hash db settings.",
257 "HashLookupSettingsPanel.saveFail.title=Save Fail"})
260 List<HashDb> unindexed =
new ArrayList<>();
263 if (!hashSet.hasIndex()) {
264 unindexed.add(hashSet);
272 if (unindexed.size() == 1) {
274 }
else if (unindexed.size() > 1) {
278 hashSetManager.save();
280 SwingUtilities.invokeLater(() -> {
281 JOptionPane.showMessageDialog(null, Bundle.HashLookupSettingsPanel_saveFail_message(), Bundle.HashLookupSettingsPanel_saveFail_title(), JOptionPane.ERROR_MESSAGE);
289 hashSetTableModel.refreshModel();
308 @Messages({
"# {0} - hash lookup name",
"HashLookupSettingsPanel.removeDatabaseFailure.message=Failed to remove hash lookup: {0}"})
309 void removeThese(List<HashDb> toRemove) {
310 for (HashDb hashDb : toRemove) {
313 }
catch (HashDbManager.HashDbManagerException ex) {
314 JOptionPane.showMessageDialog(null, Bundle.HashLookupSettingsPanel_removeDatabaseFailure_message(hashDb.getHashSetName()));
317 hashSetTableModel.refreshModel();
331 for (
HashDb hdb : unindexed) {
332 total +=
"\n" + hdb.getHashSetName();
335 message = NbBundle.getMessage(this.getClass(),
"HashDbConfigPanel.dbsNotIndexedMsg", total);
337 message = NbBundle.getMessage(this.getClass(),
"HashDbConfigPanel.dbNotIndexedMsg", total);
339 int res = JOptionPane.showConfirmDialog(
this, message,
340 NbBundle.getMessage(
this.getClass(),
341 "HashDbConfigPanel.unindexedDbsMsg"),
342 JOptionPane.YES_NO_OPTION);
343 if (res == JOptionPane.YES_OPTION) {
344 ModalNoButtons indexingDialog =
new ModalNoButtons(
this,
new Frame(), unindexed);
345 indexingDialog.setLocationRelativeTo(null);
346 indexingDialog.setVisible(
true);
347 indexingDialog.setModal(
true);
348 hashSetTableModel.refreshModel();
350 if (res == JOptionPane.NO_OPTION) {
351 JOptionPane.showMessageDialog(
this, NbBundle.getMessage(
this.getClass(),
352 "HashDbConfigPanel.allUnindexedDbsRmFromListMsg"));
353 removeThese(unindexed);
369 JComponent cellRenderer = (JComponent) super.prepareRenderer(renderer, row, column);
370 cellRenderer.setToolTipText((String) getValueAt(row, column));
376 cellRenderer.setForeground(Color.black);
378 cellRenderer.setForeground(Color.red);
385 return hashSetTableModel.getHashSetAt(getSelectionModel().getMinSelectionIndex());
390 getSelectionModel().setSelectionInterval(index, index);
414 return hashSets.size();
419 return NbBundle.getMessage(this.getClass(),
"HashDbConfigPanel.nameColLbl");
424 return hashSets.get(rowIndex).getHashSetName();
429 return hashSets.get(rowIndex).hasIndex();
442 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
443 throw new UnsupportedOperationException(
444 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.editingCellsNotSupportedMsg"));
452 HashDb getHashSetAt(
int index) {
453 if (!hashSets.isEmpty() && index >= 0 && index < hashSets.size()) {
454 return hashSets.get(index);
460 int getIndexByName(String name) {
461 for (
int i = 0; i < hashSets.size(); ++i) {
462 if (hashSets.get(i).getHashSetName().equals(name)) {
469 void refreshModel() {
470 hashSets = HashDbManager.getInstance().getAllHashSets();
474 void refreshDisplay() {
475 fireTableDataChanged();
487 jLabel2 =
new javax.swing.JLabel();
488 jLabel4 =
new javax.swing.JLabel();
489 jLabel6 =
new javax.swing.JLabel();
490 jButton3 =
new javax.swing.JButton();
492 jPanel1 =
new javax.swing.JPanel();
518 jLabel2.setFont(
jLabel2.getFont().deriveFont(
jLabel2.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
521 jLabel4.setFont(
jLabel4.getFont().deriveFont(
jLabel4.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
524 jLabel6.setFont(
jLabel6.getFont().deriveFont(
jLabel6.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
531 ingestWarningLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png")));
535 hashSetTable.setModel(
new javax.swing.table.DefaultTableModel(
545 hashSetTable.addKeyListener(
new java.awt.event.KeyAdapter() {
546 public void keyPressed(java.awt.event.KeyEvent evt) {
553 deleteDatabaseButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/delete16.png")));
559 public void actionPerformed(java.awt.event.ActionEvent evt) {
565 importDatabaseButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/import16.png")));
572 public void actionPerformed(java.awt.event.ActionEvent evt) {
607 indexButton.addActionListener(
new java.awt.event.ActionListener() {
608 public void actionPerformed(java.awt.event.ActionEvent evt) {
616 public void actionPerformed(java.awt.event.ActionEvent evt) {
628 createDatabaseButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/new16.png")));
635 public void actionPerformed(java.awt.event.ActionEvent evt) {
650 public void actionPerformed(java.awt.event.ActionEvent evt) {
655 javax.swing.GroupLayout jPanel1Layout =
new javax.swing.GroupLayout(
jPanel1);
656 jPanel1.setLayout(jPanel1Layout);
657 jPanel1Layout.setHorizontalGroup(
658 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 .addComponent(
jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 395, javax.swing.GroupLayout.PREFERRED_SIZE)
665 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
666 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
667 .addGroup(jPanel1Layout.createSequentialGroup()
668 .addComponent(
informationLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
669 .addGap(309, 309, 309))
670 .addGroup(jPanel1Layout.createSequentialGroup()
671 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
672 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
674 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
675 .addComponent(
optionsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 334, javax.swing.GroupLayout.PREFERRED_SIZE))
676 .addGroup(jPanel1Layout.createSequentialGroup()
678 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
679 .addGroup(jPanel1Layout.createSequentialGroup()
680 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
682 .addComponent(
indexButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
684 .addComponent(
indexLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
687 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
688 .addComponent(
hashDbTypeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
689 .addComponent(
hashDbLocationLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
690 .addComponent(
indexPathLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
691 .addComponent(
hashDbIndexStatusLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
693 .addGroup(jPanel1Layout.createSequentialGroup()
697 .addGroup(jPanel1Layout.createSequentialGroup()
699 .addComponent(
informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 305, javax.swing.GroupLayout.PREFERRED_SIZE))
700 .addGroup(jPanel1Layout.createSequentialGroup()
703 .addGroup(jPanel1Layout.createSequentialGroup()
706 .addGap(50, 50, 50))))
707 .addGroup(jPanel1Layout.createSequentialGroup()
708 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
710 .addGroup(jPanel1Layout.createSequentialGroup()
711 .addComponent(
createDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
712 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
713 .addComponent(
importDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
714 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
715 .addComponent(
deleteDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)))
716 .addGap(0, 0, Short.MAX_VALUE))))
718 jPanel1Layout.setVerticalGroup(
719 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
720 .addGroup(jPanel1Layout.createSequentialGroup()
724 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
725 .addGroup(jPanel1Layout.createSequentialGroup()
726 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
728 .addGroup(jPanel1Layout.createSequentialGroup()
730 .addComponent(
informationSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 3, javax.swing.GroupLayout.PREFERRED_SIZE)))
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.RELATED)
740 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
743 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
744 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
747 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
748 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
751 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
752 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
756 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
758 .addComponent(
optionsSeparator, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
763 .addGap(0, 0, Short.MAX_VALUE))
765 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
766 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
767 .addComponent(
createDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
768 .addComponent(
importDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
769 .addComponent(
deleteDatabaseButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
775 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
776 this.setLayout(layout);
777 layout.setHorizontalGroup(
778 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
779 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
783 layout.setVerticalGroup(
784 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
796 HashDb hashDb =
new HashDbCreateDatabaseDialog().getHashDatabase();
797 if (null != hashDb) {
798 hashSetTableModel.refreshModel();
800 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
806 if (hashDb != null) {
808 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
814 assert hashDb != null;
820 public void propertyChange(PropertyChangeEvent evt) {
823 if (selectedHashDb != null && hashDb != null && hashDb.
equals(selectedHashDb)) {
826 hashSetTableModel.refreshDisplay();
836 ModalNoButtons indexDialog =
new ModalNoButtons(
this,
new Frame(), hashDb);
837 indexDialog.setLocationRelativeTo(null);
838 indexDialog.setVisible(
true);
839 indexDialog.setModal(
true);
843 HashDb hashDb =
new HashDbImportDatabaseDialog().getHashDatabase();
844 if (null != hashDb) {
845 hashSetTableModel.refreshModel();
847 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
853 if (JOptionPane.showConfirmDialog(null,
854 NbBundle.getMessage(
this.getClass(),
855 "HashDbConfigPanel.deleteDbActionConfirmMsg"),
856 NbBundle.getMessage(
this.getClass(),
"HashDbConfigPanel.deleteDbActionMsg"),
857 JOptionPane.YES_NO_OPTION,
858 JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
860 if (hashDb != null) {
864 JOptionPane.showMessageDialog(null, Bundle.HashLookupSettingsPanel_removeDatabaseFailure_message(hashDb.
getHashSetName()));
866 hashSetTableModel.refreshModel();
867 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
873 if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
875 if (hashDb != null) {
879 JOptionPane.showMessageDialog(null, Bundle.HashLookupSettingsPanel_removeDatabaseFailure_message(hashDb.
getHashSetName()));
881 hashSetTableModel.refreshModel();
882 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
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
synchronized void removeHashDatabaseNoSave(HashDb hashDb)
javax.swing.JScrollPane jScrollPane2
static synchronized HashDbManager getInstance()
boolean isLocalIngestJobEvent(PropertyChangeEvent evt)
boolean equals(Object obj)
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)