24
24
import java .io .IOException ;
25
25
import java .net .URI ;
26
26
import java .net .URISyntaxException ;
27
+ import java .util .Collection ;
27
28
import java .util .Collections ;
28
29
import java .util .logging .Level ;
30
+ import java .util .stream .Stream ;
29
31
import org .sleuthkit .autopsy .coreutils .Logger ;
30
32
import javax .swing .JFileChooser ;
31
33
import javax .swing .event .DocumentEvent ;
32
34
import javax .swing .event .DocumentListener ;
33
35
import org .apache .commons .lang3 .StringUtils ;
34
36
import org .netbeans .spi .options .OptionsPanelController ;
37
+ import org .openide .util .Lookup ;
38
+ import org .openide .util .NbBundle .Messages ;
35
39
import org .openide .util .lookup .ServiceProvider ;
40
+ import org .sleuthkit .autopsy .casemodule .AutopsyContentProvider ;
36
41
import org .sleuthkit .autopsy .casemodule .Case ;
37
42
import org .sleuthkit .autopsy .guiutils .JFileChooserFactory ;
38
43
@@ -46,6 +51,8 @@ public class CTIncidentImportOptionsPanel extends CTOptionsSubPanel {
46
51
47
52
private static final String CT_IMPORTER_DOC_LINK = "https://docs.cybertriage.com/en/latest/chapters/integrations/autopsy.html" ;
48
53
54
+ private static final String CT_STANDARD_CONTENT_PROVIDER_NAME = "CTStandardContentProvider" ;
55
+
49
56
private final JFileChooserFactory fileRepoChooserFactory = new JFileChooserFactory ();
50
57
private final CTSettingsPersistence ctPersistence = CTSettingsPersistence .getInstance ();
51
58
@@ -93,8 +100,23 @@ public synchronized void saveSettings() {
93
100
public synchronized void loadSettings () {
94
101
CTSettings ctSettings = ctPersistence .loadCTSettings ();
95
102
setCTSettingsDisplay (ctSettings );
103
+ setModuleDetected ();
96
104
setEnabledItems (Case .isCaseOpen ());
97
105
}
106
+
107
+ @ Messages ({
108
+ "CTIncidentImportOptionsPanel_setModuleDetected_detected=Detected" ,
109
+ "CTIncidentImportOptionsPanel_setModuleDetected_notDetected=Not Detected"
110
+ })
111
+ private void setModuleDetected () {
112
+ Collection <? extends AutopsyContentProvider > contentProviders = Lookup .getDefault ().lookupAll (AutopsyContentProvider .class );
113
+ boolean detected = ((Collection <? extends AutopsyContentProvider >) (contentProviders != null ? contentProviders : Collections .emptyList ())).stream ()
114
+ .anyMatch (p -> p != null && StringUtils .defaultString (p .getName ()).toUpperCase ().startsWith (CT_STANDARD_CONTENT_PROVIDER_NAME .toUpperCase ()));
115
+
116
+ this .importModuleDetected .setText (detected
117
+ ? Bundle .CTIncidentImportOptionsPanel_setModuleDetected_detected ()
118
+ : Bundle .CTIncidentImportOptionsPanel_setModuleDetected_notDetected ());
119
+ }
98
120
99
121
private void setEnabledItems (boolean caseOpen ) {
100
122
this .caseOpenWarningLabel .setVisible (caseOpen );
@@ -127,6 +149,8 @@ private void initComponents() {
127
149
128
150
incidentTextPanel = new javax .swing .JPanel ();
129
151
incidentTextLabel = new javax .swing .JLabel ();
152
+ javax .swing .JLabel importModule = new javax .swing .JLabel ();
153
+ importModuleDetected = new javax .swing .JLabel ();
130
154
instructionsPanel = new javax .swing .JPanel ();
131
155
instructionsTextLabel = new javax .swing .JLabel ();
132
156
instructionsLinkLabel = new javax .swing .JLabel ();
@@ -145,10 +169,28 @@ private void initComponents() {
145
169
gridBagConstraints = new java .awt .GridBagConstraints ();
146
170
gridBagConstraints .gridx = 0 ;
147
171
gridBagConstraints .gridy = 0 ;
172
+ gridBagConstraints .gridwidth = 2 ;
148
173
gridBagConstraints .anchor = java .awt .GridBagConstraints .NORTHWEST ;
174
+ gridBagConstraints .weightx = 1.0 ;
149
175
gridBagConstraints .insets = new java .awt .Insets (5 , 5 , 5 , 5 );
150
176
incidentTextPanel .add (incidentTextLabel , gridBagConstraints );
151
177
178
+ org .openide .awt .Mnemonics .setLocalizedText (importModule , org .openide .util .NbBundle .getMessage (CTIncidentImportOptionsPanel .class , "CTIncidentImportOptionsPanel.importModule.text" )); // NOI18N
179
+ gridBagConstraints = new java .awt .GridBagConstraints ();
180
+ gridBagConstraints .gridx = 0 ;
181
+ gridBagConstraints .gridy = 1 ;
182
+ gridBagConstraints .insets = new java .awt .Insets (5 , 5 , 5 , 3 );
183
+ incidentTextPanel .add (importModule , gridBagConstraints );
184
+
185
+ org .openide .awt .Mnemonics .setLocalizedText (importModuleDetected , org .openide .util .NbBundle .getMessage (CTIncidentImportOptionsPanel .class , "CTIncidentImportOptionsPanel.importModuleDetected.text" )); // NOI18N
186
+ gridBagConstraints = new java .awt .GridBagConstraints ();
187
+ gridBagConstraints .gridx = 1 ;
188
+ gridBagConstraints .gridy = 1 ;
189
+ gridBagConstraints .anchor = java .awt .GridBagConstraints .NORTHWEST ;
190
+ gridBagConstraints .weightx = 1.0 ;
191
+ gridBagConstraints .insets = new java .awt .Insets (5 , 0 , 5 , 5 );
192
+ incidentTextPanel .add (importModuleDetected , gridBagConstraints );
193
+
152
194
gridBagConstraints = new java .awt .GridBagConstraints ();
153
195
gridBagConstraints .gridx = 0 ;
154
196
gridBagConstraints .gridy = 0 ;
@@ -161,7 +203,7 @@ private void initComponents() {
161
203
gridBagConstraints .gridx = 0 ;
162
204
gridBagConstraints .gridy = 0 ;
163
205
gridBagConstraints .anchor = java .awt .GridBagConstraints .NORTHWEST ;
164
- gridBagConstraints .insets = new java .awt .Insets (0 , 5 , 0 , 0 );
206
+ gridBagConstraints .insets = new java .awt .Insets (5 , 5 , 5 , 0 );
165
207
instructionsPanel .add (instructionsTextLabel , gridBagConstraints );
166
208
instructionsTextLabel .getAccessibleContext ().setAccessibleName ("For instructions on obtaining the module refer to:" );
167
209
@@ -176,7 +218,7 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {
176
218
gridBagConstraints .gridx = 1 ;
177
219
gridBagConstraints .gridy = 0 ;
178
220
gridBagConstraints .anchor = java .awt .GridBagConstraints .NORTHWEST ;
179
- gridBagConstraints .insets = new java .awt .Insets (0 , 5 , 5 , 5 );
221
+ gridBagConstraints .insets = new java .awt .Insets (5 , 5 , 5 , 5 );
180
222
instructionsPanel .add (instructionsLinkLabel , gridBagConstraints );
181
223
182
224
gridBagConstraints = new java .awt .GridBagConstraints ();
@@ -283,6 +325,7 @@ private void gotoLink(String url) {
283
325
private javax .swing .JLabel caseOpenWarningLabel ;
284
326
private javax .swing .JButton fileRepoBrowseButton ;
285
327
private javax .swing .JTextField fileRepoPathField ;
328
+ private javax .swing .JLabel importModuleDetected ;
286
329
private javax .swing .JLabel incidentTextLabel ;
287
330
private javax .swing .JPanel incidentTextPanel ;
288
331
private javax .swing .JLabel instructionsLinkLabel ;
0 commit comments