19 package org.sleuthkit.autopsy.modules.interestingitems;
 
   21 import java.awt.EventQueue;
 
   23 import java.util.ArrayList;
 
   24 import java.util.Collection;
 
   25 import java.util.HashMap;
 
   26 import java.util.HashSet;
 
   27 import java.util.List;
 
   30 import java.util.TreeMap;
 
   31 import java.util.logging.Level;
 
   32 import javax.swing.DefaultListModel;
 
   33 import javax.swing.JButton;
 
   34 import javax.swing.JFileChooser;
 
   35 import javax.swing.JOptionPane;
 
   36 import javax.swing.event.ListSelectionEvent;
 
   37 import javax.swing.event.ListSelectionListener;
 
   38 import javax.swing.filechooser.FileNameExtensionFilter;
 
   39 import org.netbeans.spi.options.OptionsPanelController;
 
   40 import org.openide.util.NbBundle;
 
   41 import org.openide.windows.WindowManager;
 
   55     @NbBundle.Messages({
"# {0} - filter name",
 
   56         "# {1} - profile name",
 
   57         "FilesSetDefsPanel.ingest.fileFilterInUseError=The selected file filter, {0}, is being used by a profile, {1}, and cannot be deleted while any profile uses it.",
 
   58         "FilesSetDefsPanel.bytes=Bytes",
 
   59         "FilesSetDefsPanel.kiloBytes=Kilobytes",
 
   60         "FilesSetDefsPanel.megaBytes=Megabytes",
 
   61         "FilesSetDefsPanel.gigaBytes=Gigabytes",
 
   62         "FilesSetDefsPanel.loadError=Error loading interesting files sets from file.",
 
   63         "FilesSetDefsPanel.saveError=Error saving interesting files sets to file.",
 
   64         "FilesSetDefsPanel.interesting.copySetButton.text=Copy Set",
 
   65         "FilesSetDefsPanel.interesting.importSetButton.text=Import Set",
 
   66         "FilesSetDefsPanel.interesting.exportSetButton.text=Export Set" 
   73     private final DefaultListModel<FilesSet> 
setsListModel = 
new DefaultListModel<>();
 
   76     private final JButton 
okButton = 
new JButton(
"OK");
 
   98         this.
setsList.setModel(setsListModel);
 
  108             this.
jLabel7.setVisible(
false);
 
  111             this.ruleDialogTitle = 
"FilesSetPanel.ingest.title";
 
  112             this.
jLabel8.setVisible(
false);
 
  115             this.
jLabel2.setVisible(
false);
 
  124             org.openide.awt.Mnemonics.setLocalizedText(
jLabel6, 
org.openide.util.NbBundle.getMessage(
FilesSetDefsPanel.class, 
"FilesSetDefsPanel.ingest.jLabel6.text")); 
 
  126             this.ruleDialogTitle = 
"FilesSetPanel.interesting.title";
 
  132     @NbBundle.Messages({
"FilesSetDefsPanel.Interesting.Title=Global Interesting Items Settings",
 
  133         "FilesSetDefsPanel.Ingest.Title=File Ingest Filter Settings"})
 
  136             setName(Bundle.FilesSetDefsPanel_Ingest_Title());
 
  138             setName(Bundle.FilesSetDefsPanel_Interesting_Title());
 
  141         Set<String> fileTypesCollated = 
new HashSet<>();
 
  143             fileTypesCollated.add(mediaType);
 
  150             fileTypesCollated.addAll(userDefinedFileTypes);
 
  153             logger.log(Level.SEVERE, 
"Unable to get user defined file types", ex);
 
  156         List<String> toSort = 
new ArrayList<>(fileTypesCollated);
 
  157         toSort.sort((String string1, String string2) -> {
 
  158             int result = String.CASE_INSENSITIVE_ORDER.compare(string1, string2);
 
  160                 result = string1.compareTo(string2);
 
  165         for (String file : toSort) {
 
  186             logger.log(Level.WARNING, Bundle.FilesSetDefsPanel_saveError(), ex);
 
  193         canBeEnabled = isEnabled;
 
  232             logger.log(Level.WARNING, Bundle.FilesSetDefsPanel_loadError(), ex);
 
  233             this.filesSets = 
new TreeMap<>();
 
  238         for (
FilesSet set : this.filesSets.values()) {
 
  239             this.setsListModel.addElement(set);
 
  242         if (!this.filesSets.isEmpty()) {
 
  245             EventQueue.invokeLater(() -> {
 
  256         this.setsListModel.clear();
 
  295             if (e.getValueIsAdjusting()) {
 
  307             if (selectedSet != null) {
 
  319                 TreeMap<String, 
FilesSet.
Rule> rules = 
new TreeMap<>(selectedSet.getRules());
 
  340             if (e.getValueIsAdjusting()) {
 
  356                 if (nameCondition != null) {
 
  367                 switch (typeCondition.getMetaType()) {
 
  374                     case FILES_AND_DIRECTORIES:
 
  378                 if (pathCondition != null) {
 
  385                 if (mimeTypeCondition != null) {
 
  390                 if (fileSizeCondition != null) {
 
  425         if (selectedSet != null) {
 
  436         int option = JOptionPane.OK_OPTION;
 
  438             option = JOptionPane.showConfirmDialog(null, panel, NbBundle.getMessage(
FilesSetPanel.class, ruleDialogTitle), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
 
  439         } 
while (option == JOptionPane.OK_OPTION && !panel.isValidDefinition());
 
  443         if (this.filesSets.containsKey(panel.getFilesSetName()) && shouldCreateNew) {
 
  445                     "FilesSetDefsPanel.doFileSetsDialog.duplicateRuleSet.text",
 
  446                     panel.getFilesSetName()));
 
  450         if (option == JOptionPane.OK_OPTION) {
 
  452             if (selectedSet != null) {
 
  456                 rules.putAll(selectedSet.getRules());
 
  458             if (shouldCreateNew) {
 
  459                 this.replaceFilesSet(null, panel.getFilesSetName(), panel.getFilesSetDescription(), panel.getFileSetIgnoresKnownFiles(), panel.getFileSetIgnoresUnallocatedSpace(), rules);
 
  461                 this.replaceFilesSet(selectedSet, panel.getFilesSetName(), panel.getFilesSetDescription(), panel.getFileSetIgnoresKnownFiles(), panel.getFileSetIgnoresUnallocatedSpace(), rules);
 
  475         FilesSetRulePanel panel;
 
  476         if (selectedRule != null) {
 
  478             panel = 
new FilesSetRulePanel(selectedRule, okButton, cancelButton, panelType);
 
  481             panel = 
new FilesSetRulePanel(okButton, cancelButton, panelType);
 
  486         int option = JOptionPane.OK_OPTION;
 
  488             option = JOptionPane.showOptionDialog(null, panel, NbBundle.getMessage(
FilesSetPanel.class, ruleDialogTitle), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, 
new Object[]{
okButton, cancelButton}, 
okButton);
 
  490         } 
while (option == JOptionPane.OK_OPTION && !panel.isValidRuleDefinition());
 
  492         if (option == JOptionPane.OK_OPTION) {
 
  497             Map<String, 
FilesSet.
Rule> rules = 
new HashMap<>(selectedSet.getRules());
 
  501             if (selectedRule != null) {
 
  502                 rules.remove(selectedRule.getUuid());
 
  504             FilesSet.
Rule newRule = 
new FilesSet.
Rule(panel.getRuleName(), panel.getFileNameCondition(), panel.getMetaTypeCondition(), panel.getPathCondition(), panel.getMimeTypeCondition(), panel.getFileSizeCondition());
 
  505             rules.put(newRule.getUuid(), newRule);
 
  514             EventQueue.invokeLater(() -> {
 
  515                 this.
rulesList.setSelectedValue(newRule, 
true);
 
  535     void replaceFilesSet(
FilesSet oldSet, String name, String description, 
boolean ignoresKnownFiles, 
boolean ignoresUnallocatedSpace, Map<String, FilesSet.Rule> rules) {
 
  536         if (oldSet != null) {
 
  539             this.filesSets.remove(oldSet.
getName());
 
  544         FilesSet newSet = 
new FilesSet(name, description, ignoresKnownFiles, ignoresUnallocatedSpace, rules);
 
  545         this.filesSets.put(newSet.getName(), newSet);
 
  550         for (FilesSet set : this.filesSets.values()) {
 
  551             this.setsListModel.addElement(set);
 
  557         this.
setsList.setSelectedValue(newSet, 
true);
 
  565     @SuppressWarnings(
"unchecked")
 
  572         jPanel1 = 
new javax.swing.JPanel();
 
  573         jLabel6 = 
new javax.swing.JLabel();
 
  584         setsList = 
new javax.swing.JList<>();
 
  586         jLabel3 = 
new javax.swing.JLabel();
 
  588         jLabel5 = 
new javax.swing.JLabel();
 
  593         separator = 
new javax.swing.JSeparator();
 
  599         jLabel2 = 
new javax.swing.JLabel();
 
  601         jLabel1 = 
new javax.swing.JLabel();
 
  602         jLabel4 = 
new javax.swing.JLabel();
 
  606         jLabel7 = 
new javax.swing.JLabel();
 
  608         jLabel8 = 
new javax.swing.JLabel();
 
  618         setFont(getFont().deriveFont(getFont().getStyle() & ~java.awt.Font.BOLD, 11));
 
  622         jPanel1.setFont(
jPanel1.getFont().deriveFont(
jPanel1.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
 
  624         jLabel6.setFont(
jLabel6.getFont().deriveFont(
jLabel6.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
 
  625         org.openide.awt.Mnemonics.setLocalizedText(
jLabel6, 
org.openide.util.NbBundle.getMessage(
FilesSetDefsPanel.class, 
"FilesSetDefsPanel.interesting.jLabel6.text")); 
 
  628         newRuleButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/add16.png"))); 
 
  630         newRuleButton.addActionListener(
new java.awt.event.ActionListener() {
 
  631             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  643         editRuleButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/edit16.png"))); 
 
  646         editRuleButton.addActionListener(
new java.awt.event.ActionListener() {
 
  647             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  658         rulesList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
 
  675         editSetButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/edit16.png"))); 
 
  679         editSetButton.setMaximumSize(
new java.awt.Dimension(111, 25));
 
  680         editSetButton.setMinimumSize(
new java.awt.Dimension(111, 25));
 
  681         editSetButton.setPreferredSize(
new java.awt.Dimension(111, 25));
 
  682         editSetButton.addActionListener(
new java.awt.event.ActionListener() {
 
  683             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  691         setsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
 
  699         jLabel3.setFont(
jLabel3.getFont().deriveFont(
jLabel3.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
 
  700         org.openide.awt.Mnemonics.setLocalizedText(
jLabel3, 
org.openide.util.NbBundle.getMessage(
FilesSetDefsPanel.class, 
"FilesSetDefsPanel.jLabel3.text")); 
 
  706         jLabel5.setFont(
jLabel5.getFont().deriveFont(
jLabel5.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
 
  707         org.openide.awt.Mnemonics.setLocalizedText(
jLabel5, 
org.openide.util.NbBundle.getMessage(
FilesSetDefsPanel.class, 
"FilesSetDefsPanel.jLabel5.text")); 
 
  726         separator.setOrientation(javax.swing.SwingConstants.VERTICAL);
 
  737         deleteSetButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/delete16.png"))); 
 
  744         deleteSetButton.addActionListener(
new java.awt.event.ActionListener() {
 
  745             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  751         deleteRuleButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/delete16.png"))); 
 
  755             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  761         newSetButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/add16.png"))); 
 
  762         org.openide.awt.Mnemonics.setLocalizedText(
newSetButton, 
org.openide.util.NbBundle.getMessage(
FilesSetDefsPanel.class, 
"FilesSetDefsPanel.interesting.newSetButton.text")); 
 
  763         newSetButton.setMargin(
new java.awt.Insets(2, 6, 2, 6));
 
  764         newSetButton.setMaximumSize(
new java.awt.Dimension(111, 25));
 
  765         newSetButton.setMinimumSize(
new java.awt.Dimension(111, 25));
 
  766         newSetButton.setPreferredSize(
new java.awt.Dimension(111, 25));
 
  767         newSetButton.addActionListener(
new java.awt.event.ActionListener() {
 
  768             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  773         jLabel2.setFont(
jLabel2.getFont().deriveFont(
jLabel2.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
 
  774         org.openide.awt.Mnemonics.setLocalizedText(
jLabel2, 
org.openide.util.NbBundle.getMessage(
FilesSetDefsPanel.class, 
"FilesSetDefsPanel.jLabel2.text")); 
 
  781         jLabel1.setFont(
jLabel1.getFont().deriveFont(
jLabel1.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
 
  782         org.openide.awt.Mnemonics.setLocalizedText(
jLabel1, 
org.openide.util.NbBundle.getMessage(
FilesSetDefsPanel.class, 
"FilesSetDefsPanel.jLabel1.text")); 
 
  784         jLabel4.setFont(
jLabel4.getFont().deriveFont(
jLabel4.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
 
  785         org.openide.awt.Mnemonics.setLocalizedText(
jLabel4, 
org.openide.util.NbBundle.getMessage(
FilesSetDefsPanel.class, 
"FilesSetDefsPanel.jLabel4.text")); 
 
  794         jTextArea1.setBackground(
new java.awt.Color(240, 240, 240));
 
  803         org.openide.awt.Mnemonics.setLocalizedText(
jLabel7, 
org.openide.util.NbBundle.getMessage(
FilesSetDefsPanel.class, 
"FilesSetDefsPanel.jLabel7.text")); 
 
  806         mimeTypeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
""}));
 
  811         org.openide.awt.Mnemonics.setLocalizedText(
jLabel8, 
org.openide.util.NbBundle.getMessage(
FilesSetDefsPanel.class, 
"FilesSetDefsPanel.jLabel8.text")); 
 
  813         equalitySignComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] { 
"=", 
">", 
"≥", 
"<", 
"≤" }));
 
  816         fileSizeSpinner.setEnabled(
false);
 
  817         fileSizeSpinner.setMinimumSize(
new java.awt.Dimension(2, 20));
 
  819         fileSizeUnitComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] { Bundle.FilesSetDefsPanel_bytes(), Bundle.FilesSetDefsPanel_kiloBytes(), Bundle.FilesSetDefsPanel_megaBytes(), Bundle.FilesSetDefsPanel_gigaBytes() }));
 
  822         org.openide.awt.Mnemonics.setLocalizedText(ingoreUnallocCheckbox, 
org.openide.util.NbBundle.getMessage(
FilesSetDefsPanel.class, 
"FilesSetDefsPanel.ingoreUnallocCheckbox.text")); 
 
  823         ingoreUnallocCheckbox.setToolTipText(
org.openide.util.NbBundle.getMessage(
FilesSetDefsPanel.class, 
"FilesSetDefsPanel.ingoreUnallocCheckbox.toolTipText")); 
 
  824         ingoreUnallocCheckbox.setEnabled(
false);
 
  827         ingestWarningLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png"))); 
 
  830         copySetButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/new16.png"))); 
 
  834         copySetButton.setMaximumSize(
new java.awt.Dimension(111, 25));
 
  835         copySetButton.setMinimumSize(
new java.awt.Dimension(111, 25));
 
  836         copySetButton.setPreferredSize(
new java.awt.Dimension(111, 25));
 
  837         copySetButton.addActionListener(
new java.awt.event.ActionListener() {
 
  838             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  843         importSetButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/import16.png"))); 
 
  849         importSetButton.addActionListener(
new java.awt.event.ActionListener() {
 
  850             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  855         exportSetButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/export16.png"))); 
 
  862         exportSetButton.addActionListener(
new java.awt.event.ActionListener() {
 
  863             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  868         javax.swing.GroupLayout jPanel1Layout = 
new javax.swing.GroupLayout(
jPanel1);
 
  869         jPanel1.setLayout(jPanel1Layout);
 
  870         jPanel1Layout.setHorizontalGroup(
 
  871             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  872             .addGroup(jPanel1Layout.createSequentialGroup()
 
  874                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  875                     .addGroup(jPanel1Layout.createSequentialGroup()
 
  876                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, 
false)
 
  877                             .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
 
  878                                 .addComponent(
copySetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  879                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  880                                 .addComponent(
importSetButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 
  881                             .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
 
  882                                 .addComponent(
newSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  883                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  884                                 .addComponent(
editSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
 
  885                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  886                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  887                             .addComponent(
exportSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  888                             .addComponent(
deleteSetButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
 
  889                     .addComponent(
setsListScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  890                     .addComponent(
jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  892                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  893                 .addComponent(
separator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  894                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  895                     .addGroup(jPanel1Layout.createSequentialGroup()
 
  896                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  897                             .addGroup(jPanel1Layout.createSequentialGroup()
 
  898                                 .addGap(101, 101, 101)
 
  899                                 .addComponent(
filesRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  900                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  902                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  904                             .addGroup(jPanel1Layout.createSequentialGroup()
 
  905                                 .addGap(105, 105, 105)
 
  906                                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  907                                     .addGroup(jPanel1Layout.createSequentialGroup()
 
  911                                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  914                             .addGroup(jPanel1Layout.createSequentialGroup()
 
  915                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  916                                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  919                                     .addGroup(jPanel1Layout.createSequentialGroup()
 
  925                                     .addGroup(jPanel1Layout.createSequentialGroup()
 
  927                                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  928                                         .addComponent(ingoreUnallocCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  929                                     .addGroup(jPanel1Layout.createSequentialGroup()
 
  930                                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  933                                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  935                         .addGap(24, 28, Short.MAX_VALUE))
 
  936                     .addGroup(jPanel1Layout.createSequentialGroup()
 
  937                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  938                             .addGroup(jPanel1Layout.createSequentialGroup()
 
  940                                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  941                                     .addGroup(jPanel1Layout.createSequentialGroup()
 
  942                                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  946                                     .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  947                                         .addGroup(jPanel1Layout.createSequentialGroup()
 
  948                                             .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  952                                         .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
 
  954                                             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))))
 
  955                                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  956                                     .addGroup(jPanel1Layout.createSequentialGroup()
 
  957                                         .addComponent(
equalitySignComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  958                                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  959                                         .addComponent(fileSizeSpinner, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 
  960                                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  961                                         .addComponent(
fileSizeUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  964                                     .addComponent(
mimeTypeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
 
  965                             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
 
  966                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  967                                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  969                                     .addComponent(
setDescScrollPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
 
  973         jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, 
new java.awt.Component[] {copySetButton, deleteSetButton, editSetButton, exportSetButton, importSetButton, newSetButton});
 
  975         jPanel1Layout.setVerticalGroup(
 
  976             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  977             .addGroup(jPanel1Layout.createSequentialGroup()
 
  979                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  981                     .addGroup(jPanel1Layout.createSequentialGroup()
 
  982                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  983                             .addGroup(jPanel1Layout.createSequentialGroup()
 
  985                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  989                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  990                         .addComponent(
setDescScrollPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
 
  992                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
  994                             .addComponent(ingoreUnallocCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
 
  995                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
  997                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
  998                         .addComponent(
rulesListScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)
 
  999                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
 1000                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
 1004                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
 1007                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
 1013                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
 1015                             .addComponent(
fileNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
 
 1016                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
 1017                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
 1022                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
 1024                             .addComponent(
rulePathConditionTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
 
 1027                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
 1028                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
 1030                             .addComponent(
mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
 
 1031                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
 
 1032                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
 1034                             .addComponent(
equalitySignComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
 1035                             .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
 1036                             .addComponent(
fileSizeUnitComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
 
 1038                     .addGroup(jPanel1Layout.createSequentialGroup()
 
 1039                         .addComponent(
jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
 1040                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
 1042                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
 1044                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
 1045                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
 1046                             .addComponent(
newSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
 1047                             .addComponent(
editSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
 1048                             .addComponent(
deleteSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
 
 1049                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 
 1050                         .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
 
 1051                             .addComponent(
copySetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
 1052                             .addComponent(
importSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 
 1053                             .addComponent(
exportSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
 
 1057         jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, 
new java.awt.Component[] {copySetButton, deleteRuleButton, deleteSetButton, editRuleButton, editSetButton, exportSetButton, importSetButton, newRuleButton, newSetButton});
 
 1061         javax.swing.GroupLayout layout = 
new javax.swing.GroupLayout(
this);
 
 1062         this.setLayout(layout);
 
 1063         layout.setHorizontalGroup(
 
 1064             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
 1067         layout.setVerticalGroup(
 
 1068             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
 1075         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
 1084         Map<String, 
FilesSet.
Rule> rules = 
new HashMap<>(oldSet.getRules());
 
 1086         rules.remove(selectedRule.getUuid());
 
 1093         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
 1100                 if (profile.getFileIngestFilter().equals(selectedSet.
getName())) {
 
 1102                             "FilesSetDefsPanel.ingest.fileFilterInUseError",
 
 1103                             selectedSet.
getName(), profile.toString()));
 
 1109         this.filesSets.remove(selectedSet.
getName());
 
 1110         this.setsListModel.removeElement(selectedSet);
 
 1113         if (!this.filesSets.isEmpty()) {
 
 1118         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
 1123         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
 1128         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
 1133         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
 1138         firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
 1140     @NbBundle.Messages({
 
 1141         "FilesSetDefsPanel.yesOwMsg=Yes, overwrite",
 
 1142         "FilesSetDefsPanel.noSkipMsg=No, skip",
 
 1143         "FilesSetDefsPanel.cancelImportMsg=Cancel import",
 
 1144         "# {0} - FilesSet name",
 
 1145         "FilesSetDefsPanel.interesting.overwriteSetPrompt=Interesting files set <{0}> already exists locally, overwrite?",
 
 1146         "FilesSetDefsPanel.interesting.importOwConflict=Import Interesting files set conflict",
 
 1147         "FilesSetDefsPanel.interesting.failImportMsg=Interesting files set not imported",
 
 1148         "FilesSetDefsPanel.interesting.fileExtensionFilterLbl=Autopsy Interesting File Set File (xml)",
 
 1149         "FilesSetDefsPanel.interesting.importButtonAction.featureName=Interesting Files Set Import" 
 1154         JFileChooser chooser = 
new JFileChooser();
 
 1155         final String EXTENSION = 
"xml"; 
 
 1156         FileNameExtensionFilter autopsyFilter = 
new FileNameExtensionFilter(
 
 1157                 NbBundle.getMessage(
this.getClass(), 
"FilesSetDefsPanel.interesting.fileExtensionFilterLbl"), EXTENSION);
 
 1158         chooser.addChoosableFileFilter(autopsyFilter);
 
 1159         chooser.setAcceptAllFileFilterUsed(
false);
 
 1160         chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
 
 1161         int returnVal = chooser.showOpenDialog(
this);
 
 1162         if (returnVal == JFileChooser.APPROVE_OPTION) {
 
 1163             File selFile = chooser.getSelectedFile();
 
 1164             if (selFile == null) {
 
 1165                 JOptionPane.showMessageDialog(
this,
 
 1166                         NbBundle.getMessage(
this.getClass(), 
"FilesSetDefsPanel.interesting.failImportMsg"),
 
 1167                         NbBundle.getMessage(
this.getClass(), 
"FilesSetDefsPanel.interesting.importButtonAction.featureName"),
 
 1168                         JOptionPane.WARNING_MESSAGE);
 
 1169                 logger.warning(
"Selected file was null, when trying to import interesting files set definitions");
 
 1172             Collection<FilesSet> importedSets;
 
 1174                 importedSets = InterestingItemsFilesSetSettings.readDefinitionsXML(selFile).values(); 
 
 1175                 if (importedSets.isEmpty()) {
 
 1179                 JOptionPane.showMessageDialog(
this,
 
 1180                         NbBundle.getMessage(
this.getClass(), 
"FilesSetDefsPanel.interesting.failImportMsg"),
 
 1181                         NbBundle.getMessage(
this.getClass(), 
"FilesSetDefsPanel.interesting.importButtonAction.featureName"),
 
 1182                         JOptionPane.WARNING_MESSAGE);
 
 1183                 logger.log(Level.WARNING, 
"No Interesting files set definitions were read from the selected file, exception", ex);
 
 1186             for (
FilesSet set : importedSets) {
 
 1187                 int choice = JOptionPane.OK_OPTION; 
 
 1188                 if (filesSets.containsKey(set.getName())) {
 
 1189                     Object[] options = {NbBundle.getMessage(this.getClass(), 
"FilesSetDefsPanel.yesOwMsg"),
 
 1190                         NbBundle.getMessage(this.getClass(), 
"FilesSetDefsPanel.noSkipMsg"),
 
 1191                         NbBundle.getMessage(this.getClass(), 
"FilesSetDefsPanel.cancelImportMsg")};
 
 1192                     choice = JOptionPane.showOptionDialog(
this,
 
 1193                             NbBundle.getMessage(
this.getClass(), 
"FilesSetDefsPanel.interesting.overwriteSetPrompt", set.getName()),
 
 1194                             NbBundle.getMessage(
this.getClass(), 
"FilesSetDefsPanel.interesting.importOwConflict"),
 
 1195                             JOptionPane.YES_NO_CANCEL_OPTION,
 
 1196                             JOptionPane.QUESTION_MESSAGE,
 
 1201                 if (choice == JOptionPane.OK_OPTION) {
 
 1203                     this.filesSets.put(set.getName(), set);
 
 1204                 } 
else if (choice == JOptionPane.CANCEL_OPTION) {
 
 1210             for (
FilesSet set : this.filesSets.values()) {
 
 1211                 this.setsListModel.addElement(set);
 
 1216             this.
setsList.setSelectedValue(selectedSet, 
true);
 
 1217             firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
 
 1222     @NbBundle.Messages({
"FilesSetDefsPanel.interesting.exportButtonAction.featureName=Interesting Files Set Export",
 
 1223         "# {0} - file name",
 
 1224         "FilesSetDefsPanel.exportButtonActionPerformed.fileExistPrompt=File {0} exists, overwrite?",
 
 1225         "FilesSetDefsPanel.interesting.ExportedMsg=Interesting files set exported",
 
 1226         "FilesSetDefsPanel.interesting.failExportMsg=Export of interesting files set failed"})
 
 1230         JFileChooser chooser = 
new JFileChooser();
 
 1231         final String EXTENSION = 
"xml"; 
 
 1232         FileNameExtensionFilter autopsyFilter = 
new FileNameExtensionFilter(
 
 1233                 NbBundle.getMessage(
this.getClass(), 
"FilesSetDefsPanel.interesting.fileExtensionFilterLbl"), EXTENSION);
 
 1234         chooser.addChoosableFileFilter(autopsyFilter);
 
 1235         chooser.setSelectedFile(
new File(this.
setsList.getSelectedValue().getName()));
 
 1236         chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
 
 1237         int returnVal = chooser.showSaveDialog(
this);
 
 1238         if (returnVal == JFileChooser.APPROVE_OPTION) {
 
 1239             final String FEATURE_NAME = NbBundle.getMessage(this.getClass(),
 
 1240                     "FilesSetDefsPanel.interesting.exportButtonAction.featureName");
 
 1241             File selFile = chooser.getSelectedFile();
 
 1242             if (selFile == null) {
 
 1243                 JOptionPane.showMessageDialog(
this,
 
 1244                         NbBundle.getMessage(
this.getClass(), 
"FilesSetDefsPanel.interesting.failExportMsg"),
 
 1246                         JOptionPane.WARNING_MESSAGE);
 
 1247                 logger.warning(
"Selected file was null, when trying to export interesting files set definitions");
 
 1251             String fileAbs = selFile.getAbsolutePath();
 
 1252             if (!fileAbs.endsWith(
"." + EXTENSION)) {
 
 1253                 fileAbs = fileAbs + 
"." + EXTENSION;
 
 1254                 selFile = 
new File(fileAbs);
 
 1256             if (selFile.exists()) {
 
 1258                 final String FILE_EXISTS_MESSAGE = NbBundle.getMessage(this.getClass(),
 
 1259                         "FilesSetDefsPanel.exportButtonActionPerformed.fileExistPrompt", selFile.getName());
 
 1260                 boolean shouldWrite = JOptionPane.showConfirmDialog(null, FILE_EXISTS_MESSAGE, FEATURE_NAME, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION;
 
 1265             List<FilesSet> exportSets;
 
 1266             exportSets = 
new ArrayList<>();
 
 1268             exportSets.add(this.
setsList.getSelectedValue());
 
 1269             boolean written = InterestingItemsFilesSetSettings.exportXmlDefinitionsFile(selFile, exportSets);
 
 1271                 JOptionPane.showMessageDialog(
 
 1272                         WindowManager.getDefault().getMainWindow(),
 
 1273                         NbBundle.getMessage(this.getClass(), 
"FilesSetDefsPanel.interesting.ExportedMsg"),
 
 1275                         JOptionPane.INFORMATION_MESSAGE);
 
 1277                 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
 
 1278                         NbBundle.getMessage(this.getClass(), 
"FilesSetDefsPanel.interesting.failExportMsg"),
 
 1280                         JOptionPane.WARNING_MESSAGE);
 
 1281                 logger.warning(
"Export of interesting files set failed unable to write definitions xml file");
 
void deleteRuleButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JPanel jPanel1
javax.swing.JLabel jLabel4
javax.swing.JRadioButton fileNameExtensionRadioButton
javax.swing.JComboBox< String > fileSizeUnitComboBox
void valueChanged(ListSelectionEvent e)
javax.swing.JLabel jLabel6
javax.swing.JButton importSetButton
void editSetButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JTextField fileNameTextField
javax.swing.JButton copySetButton
javax.swing.JLabel jLabel1
javax.swing.JButton exportSetButton
void deleteSetButtonActionPerformed(java.awt.event.ActionEvent evt)
final DefaultListModel< FilesSet > setsListModel
void editRuleButtonActionPerformed(java.awt.event.ActionEvent evt)
void exportSetButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JScrollPane rulesListScrollPane
javax.swing.JScrollPane setDescScrollPanel
javax.swing.JButton newSetButton
javax.swing.JLabel rulesListLabel
static synchronized FilesSetsManager getInstance()
javax.swing.JScrollPane setsListScrollPane
void copySetButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JLabel jLabel7
javax.swing.JList< FilesSet > setsList
Map< String, FilesSet > getCustomFileIngestFilters()
javax.swing.JSpinner fileSizeSpinner
javax.swing.JTextArea jTextArea1
javax.swing.ButtonGroup fileNameButtonGroup
void doFilesSetRuleDialog(FilesSet.Rule selectedRule)
javax.swing.JCheckBox ignoreKnownFilesCheckbox
javax.swing.JLabel setsListLabel
javax.swing.JCheckBox ingoreUnallocCheckbox
void newRuleButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JLabel jLabel8
FilesSetDefsPanel(PANEL_TYPE panelType)
static synchronized List< IngestProfile > getIngestProfiles()
javax.swing.JLabel jLabel3
javax.swing.JButton newRuleButton
void doFileSetsDialog(FilesSet selectedSet, boolean shouldCreateNew)
javax.swing.JLabel jLabel2
void valueChanged(ListSelectionEvent e)
void importSetButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JButton deleteSetButton
javax.swing.JRadioButton filesRadioButton
javax.swing.JTextArea setDescriptionTextArea
javax.swing.JButton editSetButton
final String ruleDialogTitle
javax.swing.JCheckBox rulePathConditionRegexCheckBox
javax.swing.JSeparator separator
javax.swing.JCheckBox fileNameRegexCheckbox
void resetRuleComponents()
static synchronized SortedSet< String > getStandardDetectedTypes()
TreeMap< String, FilesSet > filesSets
javax.swing.JRadioButton dirsRadioButton
javax.swing.JRadioButton allRadioButton
javax.swing.JComboBox< String > equalitySignComboBox
synchronized static Logger getLogger(String name)
void enableButtons(boolean isEnabled)
List< String > getUserDefinedTypes()
final PANEL_TYPE panelType
javax.swing.JButton deleteRuleButton
javax.swing.JButton editRuleButton
javax.swing.JScrollPane jScrollPane2
javax.swing.JLabel ingestWarningLabel
void newSetButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JTextField rulePathConditionTextField
javax.swing.JComboBox< String > mimeTypeComboBox
final JButton cancelButton
boolean ingoresUnallocatedSpace()
javax.swing.JRadioButton fileNameRadioButton
javax.swing.JScrollPane jScrollPane1
javax.swing.JLabel jLabel5
final DefaultListModel< FilesSet.Rule > rulesListModel
javax.swing.JList< FilesSet.Rule > rulesList
static void error(String message)
javax.swing.ButtonGroup typeButtonGroup