Autopsy  4.5.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
EncryptionDetectionIngestJobSettingsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2017 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.encryptiondetection;
20 
21 import org.openide.util.NbBundle;
22 import org.openide.util.NbBundle.Messages;
25 
29 final class EncryptionDetectionIngestJobSettingsPanel extends IngestModuleIngestJobSettingsPanel {
30 
31  private static final int MEGABYTE_SIZE = 1048576;
32  private static final double MINIMUM_ENTROPY_INPUT_RANGE_MIN = 6.0;
33  private static final double MINIMUM_ENTROPY_INPUT_RANGE_MAX = 8.0;
34  private static final int MINIMUM_FILE_SIZE_INPUT_RANGE_MIN = 1;
35 
41  public EncryptionDetectionIngestJobSettingsPanel(EncryptionDetectionIngestJobSettings settings) {
42  initComponents();
43  customizeComponents(settings);
44  }
45 
51  private void customizeComponents(EncryptionDetectionIngestJobSettings settings) {
52  minimumEntropyTextbox.setText(String.valueOf(settings.getMinimumEntropy()));
53  minimumFileSizeTextbox.setText(String.valueOf(settings.getMinimumFileSize() / MEGABYTE_SIZE));
54  fileSizeMultiplesEnforcedCheckbox.setSelected(settings.isFileSizeMultipleEnforced());
55  slackFilesAllowedCheckbox.setSelected(settings.isSlackFilesAllowed());
56  }
57 
58  @Override
59  public IngestModuleIngestJobSettings getSettings() {
60  validateMinimumEntropy();
61  validateMinimumFileSize();
62 
63  return new EncryptionDetectionIngestJobSettings(
64  Double.valueOf(minimumEntropyTextbox.getText()),
65  Integer.valueOf(minimumFileSizeTextbox.getText()) * MEGABYTE_SIZE,
66  fileSizeMultiplesEnforcedCheckbox.isSelected(),
67  slackFilesAllowedCheckbox.isSelected());
68  }
69 
76  @Messages({
77  "EncryptionDetectionIngestJobSettingsPanel.minimumEntropyInput.validationError.text=Minimum entropy input must be a number between 6.0 and 8.0."
78  })
79  private void validateMinimumEntropy() throws IllegalArgumentException {
80  try {
81  double minimumEntropy = Double.valueOf(minimumEntropyTextbox.getText());
82  if (minimumEntropy < MINIMUM_ENTROPY_INPUT_RANGE_MIN || minimumEntropy > MINIMUM_ENTROPY_INPUT_RANGE_MAX) {
83  throw new IllegalArgumentException(NbBundle.getMessage(this.getClass(), "EncryptionDetectionIngestJobSettingsPanel.minimumEntropyInput.validationError.text"));
84  }
85  } catch (NumberFormatException ex) {
86  throw new IllegalArgumentException(NbBundle.getMessage(this.getClass(), "EncryptionDetectionIngestJobSettingsPanel.minimumEntropyInput.validationError.text"));
87  }
88  }
89 
96  @Messages({
97  "EncryptionDetectionIngestJobSettingsPanel.minimumFileSizeInput.validationError.text=Minimum file size input must be an integer (in megabytes) of 1 or greater."
98  })
99  private void validateMinimumFileSize() throws IllegalArgumentException {
100  try {
101  int minimumFileSize = Integer.valueOf(minimumFileSizeTextbox.getText());
102  if (minimumFileSize < MINIMUM_FILE_SIZE_INPUT_RANGE_MIN) {
103  throw new IllegalArgumentException(NbBundle.getMessage(this.getClass(), "EncryptionDetectionIngestJobSettingsPanel.minimumFileSizeInput.validationError.text"));
104  }
105  } catch (NumberFormatException ex) {
106  throw new IllegalArgumentException(NbBundle.getMessage(this.getClass(), "EncryptionDetectionIngestJobSettingsPanel.minimumFileSizeInput.validationError.text"));
107  }
108  }
109 
115  @SuppressWarnings("unchecked")
116  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
117  private void initComponents() {
118 
119  minimumEntropyTextbox = new javax.swing.JTextField();
120  minimumFileSizeTextbox = new javax.swing.JTextField();
121  fileSizeMultiplesEnforcedCheckbox = new javax.swing.JCheckBox();
122  slackFilesAllowedCheckbox = new javax.swing.JCheckBox();
123  minimumEntropyLabel = new javax.swing.JLabel();
124  minimumFileSizeLabel = new javax.swing.JLabel();
125  mbLabel = new javax.swing.JLabel();
126  detectionSettingsLabel = new javax.swing.JLabel();
127 
128  minimumEntropyTextbox.setText(org.openide.util.NbBundle.getMessage(EncryptionDetectionIngestJobSettingsPanel.class, "EncryptionDetectionIngestJobSettingsPanel.minimumEntropyTextbox.text")); // NOI18N
129 
130  minimumFileSizeTextbox.setText(org.openide.util.NbBundle.getMessage(EncryptionDetectionIngestJobSettingsPanel.class, "EncryptionDetectionIngestJobSettingsPanel.minimumFileSizeTextbox.text")); // NOI18N
131 
132  org.openide.awt.Mnemonics.setLocalizedText(fileSizeMultiplesEnforcedCheckbox, org.openide.util.NbBundle.getMessage(EncryptionDetectionIngestJobSettingsPanel.class, "EncryptionDetectionIngestJobSettingsPanel.fileSizeMultiplesEnforcedCheckbox.text")); // NOI18N
133 
134  org.openide.awt.Mnemonics.setLocalizedText(slackFilesAllowedCheckbox, org.openide.util.NbBundle.getMessage(EncryptionDetectionIngestJobSettingsPanel.class, "EncryptionDetectionIngestJobSettingsPanel.slackFilesAllowedCheckbox.text")); // NOI18N
135 
136  org.openide.awt.Mnemonics.setLocalizedText(minimumEntropyLabel, org.openide.util.NbBundle.getMessage(EncryptionDetectionIngestJobSettingsPanel.class, "EncryptionDetectionIngestJobSettingsPanel.minimumEntropyLabel.text")); // NOI18N
137 
138  org.openide.awt.Mnemonics.setLocalizedText(minimumFileSizeLabel, org.openide.util.NbBundle.getMessage(EncryptionDetectionIngestJobSettingsPanel.class, "EncryptionDetectionIngestJobSettingsPanel.minimumFileSizeLabel.text")); // NOI18N
139 
140  org.openide.awt.Mnemonics.setLocalizedText(mbLabel, org.openide.util.NbBundle.getMessage(EncryptionDetectionIngestJobSettingsPanel.class, "EncryptionDetectionIngestJobSettingsPanel.mbLabel.text")); // NOI18N
141 
142  detectionSettingsLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
143  org.openide.awt.Mnemonics.setLocalizedText(detectionSettingsLabel, org.openide.util.NbBundle.getMessage(EncryptionDetectionIngestJobSettingsPanel.class, "EncryptionDetectionIngestJobSettingsPanel.detectionSettingsLabel.text")); // NOI18N
144 
145  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
146  this.setLayout(layout);
147  layout.setHorizontalGroup(
148  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
149  .addGroup(layout.createSequentialGroup()
150  .addContainerGap()
151  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
152  .addComponent(slackFilesAllowedCheckbox)
153  .addComponent(detectionSettingsLabel)
154  .addGroup(layout.createSequentialGroup()
155  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
156  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
157  .addComponent(minimumFileSizeLabel)
158  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
159  .addComponent(minimumFileSizeTextbox, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
160  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
161  .addComponent(minimumEntropyLabel)
162  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
163  .addComponent(minimumEntropyTextbox, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)))
164  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
165  .addComponent(mbLabel))
166  .addComponent(fileSizeMultiplesEnforcedCheckbox))
167  .addContainerGap(15, Short.MAX_VALUE))
168  );
169  layout.setVerticalGroup(
170  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
171  .addGroup(layout.createSequentialGroup()
172  .addContainerGap()
173  .addComponent(detectionSettingsLabel)
174  .addGap(16, 16, 16)
175  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
176  .addComponent(minimumEntropyTextbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
177  .addComponent(minimumEntropyLabel))
178  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
179  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
180  .addComponent(minimumFileSizeTextbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
181  .addComponent(mbLabel)
182  .addComponent(minimumFileSizeLabel))
183  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
184  .addComponent(fileSizeMultiplesEnforcedCheckbox)
185  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
186  .addComponent(slackFilesAllowedCheckbox)
187  .addContainerGap(160, Short.MAX_VALUE))
188  );
189  }// </editor-fold>//GEN-END:initComponents
190 
191  // Variables declaration - do not modify//GEN-BEGIN:variables
192  private javax.swing.JLabel detectionSettingsLabel;
193  private javax.swing.JCheckBox fileSizeMultiplesEnforcedCheckbox;
194  private javax.swing.JLabel mbLabel;
195  private javax.swing.JLabel minimumEntropyLabel;
196  private javax.swing.JTextField minimumEntropyTextbox;
197  private javax.swing.JLabel minimumFileSizeLabel;
198  private javax.swing.JTextField minimumFileSizeTextbox;
199  private javax.swing.JCheckBox slackFilesAllowedCheckbox;
200  // End of variables declaration//GEN-END:variables
201 }

Copyright © 2012-2016 Basis Technology. Generated on: Tue Feb 20 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.