Autopsy  4.20.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
GlobalSettingsPanel.java
Go to the documentation of this file.
1 /*
2  * Central Repository
3  *
4  * Copyright 2015-2020 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.centralrepository.optionspanel;
20 
21 import java.awt.EventQueue;
23 import java.beans.PropertyChangeEvent;
24 import java.beans.PropertyChangeListener;
25 import java.util.EnumSet;
26 import java.util.Set;
27 import javax.swing.JOptionPane;
28 import javax.swing.SwingUtilities;
29 import org.netbeans.spi.options.OptionsPanelController;
30 import org.openide.util.NbBundle;
31 import org.openide.util.NbBundle.Messages;
44 import java.awt.Component;
45 import java.beans.PropertyChangeSupport;
46 import java.util.logging.Level;
47 import javax.swing.ImageIcon;
48 import org.openide.util.ImageUtilities;
51 
52 
53 
57 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
58 public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel implements OptionsPanel {
59 
60  private static final long serialVersionUID = 1L;
61  private static final Logger logger = Logger.getLogger(GlobalSettingsPanel.class.getName());
63 
64  // this allows property change events to be fired at a static level but listened to by instances
65  private static final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(GlobalSettingsPanel.class);
66 
67  // tracks the last known instance property change listener so that only one GlobalSettingsPanel is listening for events
68  private static PropertyChangeListener lastRegistered = null;
69 
71 
72  private final ImageIcon goodIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/good.png", false));
73  private final ImageIcon badIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/bad.png", false));
74 
75 
80  ingestJobEventListener = new IngestJobEventPropertyChangeListener();
81  initComponents();
82  customizeComponents();
83  setupSettingsChangeListeners();
84  addIngestJobEventsListener();
85  Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), (PropertyChangeEvent evt) -> {
86  //disable when case is open, enable when case is closed
87  ingestStateUpdated(evt.getNewValue() != null);
88  });
89  }
90 
91 
96  // listen for change events in currently saved choice
97  if (lastRegistered != null) {
99  GlobalSettingsPanel.propertyChangeSupport.removePropertyChangeListener(lastRegistered);
100  }
101 
102  lastRegistered = this::onSettingsChange;
104  GlobalSettingsPanel.propertyChangeSupport.addPropertyChangeListener(lastRegistered);
105  }
106 
107 
108  private void onSettingsChange(PropertyChangeEvent evt) {
109  ingestStateUpdated(Case.isCaseOpen());
110  clearStatus();
111  }
112 
113 
114  private void customizeComponents() {
115  setName(NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.pnCorrelationProperties.border.title"));
116  }
117 
118  private void addIngestJobEventsListener() {
119  IngestManager.getInstance().addIngestJobEventListener(INGEST_JOB_EVENTS_OF_INTEREST, ingestJobEventListener);
120  ingestStateUpdated(Case.isCaseOpen());
121  }
122 
134  private static boolean invokeCrChoice(Component parent, CentralRepoDbChoice initialSelection) {
135  EamDbSettingsDialog dialog = (initialSelection != null)
136  ? new EamDbSettingsDialog(initialSelection)
137  : new EamDbSettingsDialog();
138  return dialog.wasConfigurationChanged();
139  }
140 
154  @NbBundle.Messages({
155  "GlobalSettingsPanel.onMultiUserChange.enable.title=Central Repository",
156  "# {0} - server name",
157  "GlobalSettingsPanel.onMultiUserChange.enable.description=Do you want to update the Central Repository to use the PostgreSQL server on {0}?",
158  "GlobalSettingsPanel.onMultiUserChange.enable.description2=Any data in an existing SQLite Central Repository will not be transferred to the new database."
159  })
160  public static void onMultiUserChange(Component parent, boolean muPreviouslySelected, boolean muCurrentlySelected) {
161  boolean crEnabled = CentralRepoDbUtil.allowUseOfCentralRepository();
163 
164  if (!muPreviouslySelected && muCurrentlySelected) {
165  SwingUtilities.invokeLater(() -> {
166  PostgresCentralRepoSettings multiUserSettings
168  if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(parent,
169  "<html><body>"
170  + "<div style='width: 400px;'>"
171  + "<p>" + Bundle.GlobalSettingsPanel_onMultiUserChange_enable_description(multiUserSettings.getHost()) + "</p>"
172  + "<p style='margin-top: 10px'>" + Bundle.GlobalSettingsPanel_onMultiUserChange_enable_description2() + "</p>"
173  + "</div>"
174  + "</body></html>",
175  Bundle.GlobalSettingsPanel_onMultiUserChange_enable_title(),
176  JOptionPane.YES_NO_OPTION)) {
177 
178  // setup database for CR
181  checkStatusAndCreateDb(parent);
182  }
183  });
184  } // moving from selected to not selected && 'PostgreSQL using multi-user settings' is selected
185  else if (muPreviouslySelected && !muCurrentlySelected && crEnabled && crMultiUser) {
186  SwingUtilities.invokeLater(() -> {
187  askForCentralRepoDbChoice(parent);
188  });
189  } // changing multi-user settings connection && 'PostgreSQL using multi-user settings' is selected &&
190  // central repo either enabled or was disabled due to error
191  else if (muPreviouslySelected && muCurrentlySelected && crEnabled && crMultiUser) {
192  GlobalSettingsPanel.propertyChangeSupport.firePropertyChange("multiuserSettingsChanged", null, null);
193  checkStatusAndCreateDb(parent);
194  }
195  }
196 
197 
203  private static void checkStatusAndCreateDb(Component parent) {
204  SwingUtilities.invokeLater(() -> {
206  });
207  }
208 
216  @NbBundle.Messages({
217  "GlobalSettingsPanel.onMultiUserChange.disabledMu.title=Central Repository Change Necessary",
218  "GlobalSettingsPanel.onMultiUserChange.disabledMu.description=The Central Repository will be reconfigured to use a local SQLite database.",
219  "GlobalSettingsPanel.onMultiUserChange.disabledMu.description2=Press Configure PostgreSQL to change to a PostgreSQL database.",
220  "GlobalSettingsPanel.askForCentralRepoDbChoice.sqliteChoice.text=Use SQLite",
221  "GlobalSettingsPanel.askForCentralRepoDbChoice.customPostgrestChoice.text=Configure PostgreSQL",
222  "GlobalSettingsPanel.askForCentralRepoDbChoice.disableChoice.text=Disable Central Repository"
223  })
224  private static void askForCentralRepoDbChoice(Component parent) {
225  Object[] options = {
226  Bundle.GlobalSettingsPanel_askForCentralRepoDbChoice_sqliteChoice_text(),
227  Bundle.GlobalSettingsPanel_askForCentralRepoDbChoice_customPostgrestChoice_text(),
228  Bundle.GlobalSettingsPanel_askForCentralRepoDbChoice_disableChoice_text()
229  };
230 
231  int result = JOptionPane.showOptionDialog(
232  parent,
233  "<html><body>"
234  + "<div style='width: 400px;'>"
235  + "<p>" + Bundle.GlobalSettingsPanel_onMultiUserChange_disabledMu_description() + "</p>"
236  + "<p style='margin-top: 10px'>" + Bundle.GlobalSettingsPanel_onMultiUserChange_disabledMu_description2() + "</p>"
237  + "</div>"
238  + "</body></html>",
239  Bundle.GlobalSettingsPanel_onMultiUserChange_disabledMu_title(),
240  JOptionPane.YES_NO_CANCEL_OPTION,
241  JOptionPane.PLAIN_MESSAGE,
242  null,
243  options,
244  options[0]
245  );
246 
247  if (JOptionPane.YES_OPTION == result) {
248  invokeCrChoice(parent, CentralRepoDbChoice.SQLITE);
249  } else if (JOptionPane.NO_OPTION == result) {
250  invokeCrChoice(parent, CentralRepoDbChoice.POSTGRESQL_CUSTOM);
251  }
252  }
253 
254  @NbBundle.Messages({
255  "GlobalSettingsPanel.testCurrentConfiguration.dbDoesNotExist.message=Database does not exist.",
256  })
257  private boolean testCurrentConfiguration() {
258  if (CentralRepoDbManager.getSavedDbChoice() == null ||
261  return false;
262 
264  DatabaseTestResult testResult = manager.testStatus();
265 
266  // if database doesn't exist, prompt user to create database
267  if (testResult == DatabaseTestResult.DB_DOES_NOT_EXIST) {
268  boolean success = EamDbSettingsDialog.promptCreateDatabase(manager, null);
269  if (success)
270  testResult = DatabaseTestResult.TESTED_OK;
271  }
272 
273  // display to the user the status
274  switch (testResult) {
275  case TESTED_OK: return showStatusOkay();
276  case DB_DOES_NOT_EXIST: return showStatusFail(Bundle.GlobalSettingsPanel_testCurrentConfiguration_dbDoesNotExist_message());
277  case SCHEMA_INVALID: return showStatusFail(Bundle.EamDbSettingsDialog_okButton_corruptDatabaseExists_message());
278  case CONNECTION_FAILED:
279  default:
280  return showStatusFail(Bundle.EamDbSettingsDialog_okButton_databaseConnectionFailed_message());
281  }
282  }
283 
284  private boolean showStatusOkay() {
285  return setStatus(goodIcon, " ");
286  }
287 
288  private boolean showStatusFail(String message) {
289  return setStatus(badIcon, message);
290  }
291 
292  private void clearStatus() {
293  setStatus(null, " ");
294  }
295 
296  private boolean setStatus(ImageIcon icon, String text) {
297  synchronized (testStatusLabel) {
298  testStatusLabel.setIcon(icon);
299  testStatusLabel.setText(text);
300  return true;
301  }
302  }
303 
309  @SuppressWarnings("unchecked")
310  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
311  private void initComponents() {
312 
313  jScrollPane1 = new javax.swing.JScrollPane();
314  jPanel1 = new javax.swing.JPanel();
315  lbCentralRepository = new javax.swing.JLabel();
316  cbUseCentralRepo = new javax.swing.JCheckBox();
317  pnDatabaseConfiguration = new javax.swing.JPanel();
318  lbDbPlatformTypeLabel = new javax.swing.JLabel();
319  lbDbNameLabel = new javax.swing.JLabel();
320  lbDbLocationLabel = new javax.swing.JLabel();
321  bnDbConfigure = new javax.swing.JButton();
322  lbDbPlatformValue = new javax.swing.JLabel();
323  lbDbNameValue = new javax.swing.JLabel();
324  lbDbLocationValue = new javax.swing.JLabel();
325  bnTestConfigure = new javax.swing.JButton();
326  testStatusLabel = new javax.swing.JLabel();
327  pnCorrelationProperties = new javax.swing.JPanel();
328  bnManageTypes = new javax.swing.JButton();
329  correlationPropertiesScrollPane = new javax.swing.JScrollPane();
330  correlationPropertiesTextArea = new javax.swing.JTextArea();
331  organizationPanel = new javax.swing.JPanel();
332  manageOrganizationButton = new javax.swing.JButton();
333  organizationScrollPane = new javax.swing.JScrollPane();
334  organizationTextArea = new javax.swing.JTextArea();
335  casesPanel = new javax.swing.JPanel();
336  showCasesButton = new javax.swing.JButton();
337  casesScrollPane = new javax.swing.JScrollPane();
338  casesTextArea = new javax.swing.JTextArea();
339  tbOops = new javax.swing.JTextField();
340  ingestRunningWarningLabel = new javax.swing.JLabel();
341 
342  setName(""); // NOI18N
343  setPreferredSize(new java.awt.Dimension(1022, 488));
344 
345  jScrollPane1.setBorder(null);
346  jScrollPane1.setPreferredSize(new java.awt.Dimension(1022, 407));
347 
348  jPanel1.setMinimumSize(new java.awt.Dimension(0, 0));
349  jPanel1.setPreferredSize(new java.awt.Dimension(1020, 407));
350 
351  org.openide.awt.Mnemonics.setLocalizedText(lbCentralRepository, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.lbCentralRepository.text")); // NOI18N
352 
353  org.openide.awt.Mnemonics.setLocalizedText(cbUseCentralRepo, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.cbUseCentralRepo.text")); // NOI18N
354  cbUseCentralRepo.addActionListener(new java.awt.event.ActionListener() {
355  public void actionPerformed(java.awt.event.ActionEvent evt) {
356  cbUseCentralRepoActionPerformed(evt);
357  }
358  });
359 
360  pnDatabaseConfiguration.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.pnDatabaseConfiguration.title"))); // NOI18N
361 
362  org.openide.awt.Mnemonics.setLocalizedText(lbDbPlatformTypeLabel, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.lbDbPlatformTypeLabel.text")); // NOI18N
363 
364  org.openide.awt.Mnemonics.setLocalizedText(lbDbNameLabel, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.lbDbNameLabel.text")); // NOI18N
365 
366  org.openide.awt.Mnemonics.setLocalizedText(lbDbLocationLabel, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.lbDbLocationLabel.text")); // NOI18N
367 
368  org.openide.awt.Mnemonics.setLocalizedText(bnDbConfigure, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.bnDbConfigure.text")); // NOI18N
369  bnDbConfigure.addActionListener(new java.awt.event.ActionListener() {
370  public void actionPerformed(java.awt.event.ActionEvent evt) {
371  bnDbConfigureActionPerformed(evt);
372  }
373  });
374 
375  org.openide.awt.Mnemonics.setLocalizedText(bnTestConfigure, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.bnTestConfigure.text")); // NOI18N
376  bnTestConfigure.addActionListener(new java.awt.event.ActionListener() {
377  public void actionPerformed(java.awt.event.ActionEvent evt) {
378  bnTestConfigureActionPerformed(evt);
379  }
380  });
381 
382  testStatusLabel.setFont(testStatusLabel.getFont().deriveFont(testStatusLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
383  testStatusLabel.setForeground(new java.awt.Color(255, 0, 0));
384  org.openide.awt.Mnemonics.setLocalizedText(testStatusLabel, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.testStatusLabel.text")); // NOI18N
385  testStatusLabel.setToolTipText(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.testStatusLabel.toolTipText")); // NOI18N
386  testStatusLabel.setMaximumSize(new java.awt.Dimension(387, 16));
387  testStatusLabel.setPreferredSize(new java.awt.Dimension(387, 16));
388 
389  javax.swing.GroupLayout pnDatabaseConfigurationLayout = new javax.swing.GroupLayout(pnDatabaseConfiguration);
390  pnDatabaseConfiguration.setLayout(pnDatabaseConfigurationLayout);
391  pnDatabaseConfigurationLayout.setHorizontalGroup(
392  pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
393  .addGroup(pnDatabaseConfigurationLayout.createSequentialGroup()
394  .addContainerGap()
395  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
396  .addGroup(pnDatabaseConfigurationLayout.createSequentialGroup()
397  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
398  .addComponent(lbDbPlatformTypeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
399  .addComponent(lbDbNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
400  .addComponent(lbDbLocationLabel))
401  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
402  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
403  .addComponent(lbDbNameValue, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
404  .addComponent(lbDbPlatformValue, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
405  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnDatabaseConfigurationLayout.createSequentialGroup()
406  .addComponent(lbDbLocationValue, javax.swing.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE)
407  .addGap(681, 681, 681))))
408  .addGroup(pnDatabaseConfigurationLayout.createSequentialGroup()
409  .addComponent(bnDbConfigure)
410  .addGap(18, 18, 18)
411  .addComponent(bnTestConfigure)
412  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
413  .addComponent(testStatusLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 675, javax.swing.GroupLayout.PREFERRED_SIZE)
414  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
415  );
416  pnDatabaseConfigurationLayout.setVerticalGroup(
417  pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
418  .addGroup(pnDatabaseConfigurationLayout.createSequentialGroup()
419  .addGap(7, 7, 7)
420  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
421  .addComponent(lbDbPlatformTypeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
422  .addComponent(lbDbPlatformValue, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
423  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
424  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
425  .addComponent(lbDbNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
426  .addComponent(lbDbNameValue, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
427  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
428  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
429  .addComponent(lbDbLocationLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
430  .addComponent(lbDbLocationValue, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
431  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
432  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
433  .addComponent(testStatusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
434  .addGroup(pnDatabaseConfigurationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
435  .addComponent(bnDbConfigure)
436  .addComponent(bnTestConfigure)))
437  .addGap(8, 8, 8))
438  );
439 
440  pnCorrelationProperties.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.pnCorrelationProperties.border.title"))); // NOI18N
441  pnCorrelationProperties.setPreferredSize(new java.awt.Dimension(674, 93));
442 
443  org.openide.awt.Mnemonics.setLocalizedText(bnManageTypes, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.bnManageProperties.text")); // NOI18N
444  bnManageTypes.addActionListener(new java.awt.event.ActionListener() {
445  public void actionPerformed(java.awt.event.ActionEvent evt) {
446  bnManageTypesActionPerformed(evt);
447  }
448  });
449 
450  correlationPropertiesScrollPane.setBorder(null);
451 
452  correlationPropertiesTextArea.setEditable(false);
453  correlationPropertiesTextArea.setBackground(new java.awt.Color(240, 240, 240));
454  correlationPropertiesTextArea.setColumns(20);
455  correlationPropertiesTextArea.setLineWrap(true);
456  correlationPropertiesTextArea.setRows(1);
457  correlationPropertiesTextArea.setText(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.correlationPropertiesTextArea.text")); // NOI18N
458  correlationPropertiesTextArea.setToolTipText("");
459  correlationPropertiesTextArea.setWrapStyleWord(true);
460  correlationPropertiesTextArea.setBorder(null);
461  correlationPropertiesTextArea.setOpaque(false);
462  correlationPropertiesScrollPane.setViewportView(correlationPropertiesTextArea);
463 
464  javax.swing.GroupLayout pnCorrelationPropertiesLayout = new javax.swing.GroupLayout(pnCorrelationProperties);
465  pnCorrelationProperties.setLayout(pnCorrelationPropertiesLayout);
466  pnCorrelationPropertiesLayout.setHorizontalGroup(
467  pnCorrelationPropertiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
468  .addGroup(pnCorrelationPropertiesLayout.createSequentialGroup()
469  .addContainerGap()
470  .addGroup(pnCorrelationPropertiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
471  .addGroup(pnCorrelationPropertiesLayout.createSequentialGroup()
472  .addComponent(bnManageTypes)
473  .addGap(0, 0, Short.MAX_VALUE))
474  .addComponent(correlationPropertiesScrollPane))
475  .addContainerGap())
476  );
477  pnCorrelationPropertiesLayout.setVerticalGroup(
478  pnCorrelationPropertiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
479  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnCorrelationPropertiesLayout.createSequentialGroup()
480  .addComponent(correlationPropertiesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
481  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
482  .addComponent(bnManageTypes)
483  .addGap(8, 8, 8))
484  );
485 
486  organizationPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.organizationPanel.border.title"))); // NOI18N
487 
488  org.openide.awt.Mnemonics.setLocalizedText(manageOrganizationButton, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.manageOrganizationButton.text")); // NOI18N
489  manageOrganizationButton.addActionListener(new java.awt.event.ActionListener() {
490  public void actionPerformed(java.awt.event.ActionEvent evt) {
491  manageOrganizationButtonActionPerformed(evt);
492  }
493  });
494 
495  organizationScrollPane.setBorder(null);
496 
497  organizationTextArea.setEditable(false);
498  organizationTextArea.setBackground(new java.awt.Color(240, 240, 240));
499  organizationTextArea.setColumns(20);
500  organizationTextArea.setLineWrap(true);
501  organizationTextArea.setRows(2);
502  organizationTextArea.setText(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.organizationTextArea.text")); // NOI18N
503  organizationTextArea.setWrapStyleWord(true);
504  organizationTextArea.setBorder(null);
505  organizationTextArea.setOpaque(false);
506  organizationScrollPane.setViewportView(organizationTextArea);
507 
508  javax.swing.GroupLayout organizationPanelLayout = new javax.swing.GroupLayout(organizationPanel);
509  organizationPanel.setLayout(organizationPanelLayout);
510  organizationPanelLayout.setHorizontalGroup(
511  organizationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
512  .addGroup(organizationPanelLayout.createSequentialGroup()
513  .addContainerGap()
514  .addGroup(organizationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
515  .addComponent(organizationScrollPane)
516  .addGroup(organizationPanelLayout.createSequentialGroup()
517  .addComponent(manageOrganizationButton)
518  .addGap(0, 0, Short.MAX_VALUE)))
519  .addContainerGap())
520  );
521  organizationPanelLayout.setVerticalGroup(
522  organizationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
523  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, organizationPanelLayout.createSequentialGroup()
524  .addContainerGap()
525  .addComponent(organizationScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
526  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
527  .addComponent(manageOrganizationButton)
528  .addGap(8, 8, 8))
529  );
530 
531  casesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.casesPanel.border.title"))); // NOI18N
532  casesPanel.setName("Case Details"); // NOI18N
533 
534  org.openide.awt.Mnemonics.setLocalizedText(showCasesButton, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.showCasesButton.text")); // NOI18N
535  showCasesButton.addActionListener(new java.awt.event.ActionListener() {
536  public void actionPerformed(java.awt.event.ActionEvent evt) {
537  showCasesButtonActionPerformed(evt);
538  }
539  });
540 
541  casesScrollPane.setBorder(null);
542 
543  casesTextArea.setEditable(false);
544  casesTextArea.setBackground(new java.awt.Color(240, 240, 240));
545  casesTextArea.setColumns(20);
546  casesTextArea.setLineWrap(true);
547  casesTextArea.setRows(2);
548  casesTextArea.setText(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.casesTextArea.text")); // NOI18N
549  casesTextArea.setWrapStyleWord(true);
550  casesTextArea.setBorder(null);
551  casesTextArea.setOpaque(false);
552  casesScrollPane.setViewportView(casesTextArea);
553 
554  javax.swing.GroupLayout casesPanelLayout = new javax.swing.GroupLayout(casesPanel);
555  casesPanel.setLayout(casesPanelLayout);
556  casesPanelLayout.setHorizontalGroup(
557  casesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
558  .addGroup(casesPanelLayout.createSequentialGroup()
559  .addContainerGap()
560  .addGroup(casesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
561  .addComponent(casesScrollPane)
562  .addGroup(casesPanelLayout.createSequentialGroup()
563  .addComponent(showCasesButton)
564  .addGap(0, 0, Short.MAX_VALUE)))
565  .addContainerGap())
566  );
567  casesPanelLayout.setVerticalGroup(
568  casesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
569  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, casesPanelLayout.createSequentialGroup()
570  .addContainerGap()
571  .addComponent(casesScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
572  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
573  .addComponent(showCasesButton)
574  .addGap(8, 8, 8))
575  );
576 
577  tbOops.setEditable(false);
578  tbOops.setFont(tbOops.getFont().deriveFont(tbOops.getFont().getStyle() | java.awt.Font.BOLD, tbOops.getFont().getSize()-1));
579  tbOops.setText(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.tbOops.text")); // NOI18N
580  tbOops.setBorder(null);
581 
582  ingestRunningWarningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/filetypeid/warning16.png"))); // NOI18N
583  org.openide.awt.Mnemonics.setLocalizedText(ingestRunningWarningLabel, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.ingestRunningWarningLabel.text")); // NOI18N
584 
585  javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
586  jPanel1.setLayout(jPanel1Layout);
587  jPanel1Layout.setHorizontalGroup(
588  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
589  .addComponent(lbCentralRepository, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
590  .addGroup(jPanel1Layout.createSequentialGroup()
591  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
592  .addComponent(pnDatabaseConfiguration, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
593  .addComponent(pnCorrelationProperties, javax.swing.GroupLayout.DEFAULT_SIZE, 1016, Short.MAX_VALUE)
594  .addComponent(organizationPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
595  .addComponent(casesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
596  .addGroup(jPanel1Layout.createSequentialGroup()
597  .addComponent(cbUseCentralRepo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
598  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
599  .addComponent(ingestRunningWarningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 840, Short.MAX_VALUE))
600  .addGroup(jPanel1Layout.createSequentialGroup()
601  .addContainerGap()
602  .addComponent(tbOops, javax.swing.GroupLayout.PREFERRED_SIZE, 974, javax.swing.GroupLayout.PREFERRED_SIZE)))
603  .addContainerGap())
604  );
605  jPanel1Layout.setVerticalGroup(
606  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
607  .addGroup(jPanel1Layout.createSequentialGroup()
608  .addComponent(lbCentralRepository)
609  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
610  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
611  .addComponent(cbUseCentralRepo)
612  .addComponent(ingestRunningWarningLabel))
613  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
614  .addComponent(pnDatabaseConfiguration, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
615  .addGap(0, 0, 0)
616  .addComponent(pnCorrelationProperties, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
617  .addGap(0, 0, 0)
618  .addComponent(organizationPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
619  .addGap(0, 0, 0)
620  .addComponent(casesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
621  .addGap(0, 0, 0)
622  .addComponent(tbOops, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
623  .addContainerGap())
624  );
625 
626  casesPanel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.Case Details.AccessibleContext.accessibleName")); // NOI18N
627 
628  jScrollPane1.setViewportView(jPanel1);
629 
630  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
631  this.setLayout(layout);
632  layout.setHorizontalGroup(
633  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
634  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
635  );
636  layout.setVerticalGroup(
637  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
638  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 512, Short.MAX_VALUE)
639  );
640  }// </editor-fold>//GEN-END:initComponents
641 
642  private void bnManageTypesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnManageTypesActionPerformed
643  store();
644  ManageCorrelationPropertiesDialog manageCorrelationDialog = new ManageCorrelationPropertiesDialog();
645  firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
646  }//GEN-LAST:event_bnManageTypesActionPerformed
647 
648  private void bnDbConfigureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnDbConfigureActionPerformed
649  store();
650  boolean changed = invokeCrChoice(this, null);
651  if (changed) {
652  load(); // reload db settings content and update buttons
653  }
654  }//GEN-LAST:event_bnDbConfigureActionPerformed
655 
656  private void manageOrganizationButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manageOrganizationButtonActionPerformed
657  store();
658  ManageOrganizationsDialog manageOrganizationsDialog = new ManageOrganizationsDialog();
659  }//GEN-LAST:event_manageOrganizationButtonActionPerformed
660 
661  private void showCasesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showCasesButtonActionPerformed
662  store();
663  ManageCasesDialog.displayManageCasesDialog();
664  }//GEN-LAST:event_showCasesButtonActionPerformed
665 
666  private void cbUseCentralRepoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbUseCentralRepoActionPerformed
667  //if saved setting is disabled checkbox should be disabled already
668  store();
669  load();
670  this.ingestStateUpdated(Case.isCaseOpen());
671  }//GEN-LAST:event_cbUseCentralRepoActionPerformed
672 
673  private void bnTestConfigureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnTestConfigureActionPerformed
674  testCurrentConfiguration();
675  }//GEN-LAST:event_bnTestConfigureActionPerformed
676 
677  @Override
678  @Messages({"GlobalSettingsPanel.validationerrMsg.mustConfigure=Configure the database to enable this module."})
679  public void load() {
680  tbOops.setText("");
681  enableButtonSubComponents(false);
683  cbUseCentralRepo.setSelected(CentralRepoDbUtil.allowUseOfCentralRepository()); // NON-NLS
684 
685  lbDbPlatformValue.setText(selectedChoice.getTitle());
686  CentralRepoPlatforms selectedDb = selectedChoice.getDbPlatform();
687 
688  if (selectedChoice == null || selectedDb == CentralRepoPlatforms.DISABLED) {
689  lbDbNameValue.setText("");
690  lbDbLocationValue.setText("");
691  tbOops.setText(Bundle.GlobalSettingsPanel_validationerrMsg_mustConfigure());
692  } else {
693  enableButtonSubComponents(cbUseCentralRepo.isSelected());
694  if (selectedDb == CentralRepoPlatforms.POSTGRESQL) {
695  try {
697  lbDbNameValue.setText(dbSettingsPg.getDbName());
698  lbDbLocationValue.setText(dbSettingsPg.getHost());
699  } catch (CentralRepoException e) {
700  logger.log(Level.WARNING, "Unable to load settings into global panel for postgres settings", e);
701  }
702  } else if (selectedDb == CentralRepoPlatforms.SQLITE) {
703  SqliteCentralRepoSettings dbSettingsSqlite = new SqliteCentralRepoSettings();
704  lbDbNameValue.setText(dbSettingsSqlite.getDbName());
705  lbDbLocationValue.setText(dbSettingsSqlite.getDbDirectory());
706  }
707  }
708  }
709 
710  @Override
711  public void store() { // Click OK or Apply on Options Panel
712  CentralRepoDbUtil.setUseCentralRepo(cbUseCentralRepo.isSelected());
713  }
714 
721  public boolean valid() {
722  return !cbUseCentralRepo.isSelected() || !lbDbPlatformValue.getText().equals(CentralRepoDbChoice.DISABLED.toString());
723  }
724 
725  @Override
726  public void saveSettings() { // Click OK on Global Settings Panel
727  store();
728  }
729 
730  @Override
731  @SuppressWarnings("FinalizeDeclaration")
732  protected void finalize() throws Throwable {
733  IngestManager.getInstance().removeIngestJobEventListener(ingestJobEventListener);
734  super.finalize();
735 
736  }
737 
742  private class IngestJobEventPropertyChangeListener implements PropertyChangeListener {
743 
750  @Override
751  public void propertyChange(PropertyChangeEvent event) {
752  if (isLocalIngestJobEvent(event)) {
753  EventQueue.invokeLater(new Runnable() {
754  @Override
755  public void run() {
756  ingestStateUpdated(Case.isCaseOpen());
757  }
758  });
759  }
760  }
761  };
762 
772  private boolean isLocalIngestJobEvent(PropertyChangeEvent event) {
773  if (event instanceof AutopsyEvent) {
774  if (((AutopsyEvent) event).getSourceType() == AutopsyEvent.SourceType.LOCAL) {
775  String eventType = event.getPropertyName();
776  return (eventType.equals(IngestManager.IngestJobEvent.STARTED.toString())
777  || eventType.equals(IngestManager.IngestJobEvent.CANCELLED.toString())
778  || eventType.equals(IngestManager.IngestJobEvent.COMPLETED.toString()));
779  }
780  }
781  return false;
782  }
783 
784  @Messages({"GlobalSettingsPanel.validationErrMsg.ingestRunning=You cannot change settings while ingest is running."})
785  private void ingestStateUpdated(boolean caseIsOpen) {
786  if (!SwingUtilities.isEventDispatchThread()) {
787  SwingUtilities.invokeLater(() -> {
788  ingestStateUpdated(caseIsOpen);
789  });
790 
791  return;
792  }
793 
794  cbUseCentralRepo.setEnabled(!caseIsOpen);
796  tbOops.setText(Bundle.GlobalSettingsPanel_validationErrMsg_ingestRunning());
797  tbOops.setVisible(true);
798  enableButtonSubComponents(cbUseCentralRepo.isSelected());
799  } else {
800  load();
801  }
802 
803  enableDatabaseConfigureButton(cbUseCentralRepo.isSelected() && !caseIsOpen);
804  }
805 
806 
807 
815  private void enableDatabaseConfigureButton(Boolean enable) {
816  boolean ingestRunning = IngestManager.getInstance().isIngestRunning();
817  ingestRunningWarningLabel.setVisible(ingestRunning);
818 
819  pnDatabaseConfiguration.setEnabled(enable && !ingestRunning);
820  bnDbConfigure.setEnabled(enable && !ingestRunning);
821  bnTestConfigure.setEnabled(enable && !ingestRunning);
822  lbDbLocationLabel.setEnabled(enable && !ingestRunning);
823  lbDbLocationValue.setEnabled(enable && !ingestRunning);
824  lbDbNameLabel.setEnabled(enable && !ingestRunning);
825  lbDbNameValue.setEnabled(enable && !ingestRunning);
826  lbDbPlatformTypeLabel.setEnabled(enable && !ingestRunning);
827  lbDbPlatformValue.setEnabled(enable && !ingestRunning);
828  tbOops.setEnabled(enable && !ingestRunning);
829  }
830 
839  private boolean enableButtonSubComponents(Boolean enable) {
840  boolean ingestRunning = IngestManager.getInstance().isIngestRunning();
841  pnCorrelationProperties.setEnabled(enable && !ingestRunning);
842  bnManageTypes.setEnabled(enable && !ingestRunning);
843  correlationPropertiesTextArea.setEnabled(enable && !ingestRunning);
844  organizationPanel.setEnabled(enable && !ingestRunning);
845  organizationTextArea.setEnabled(enable && !ingestRunning);
846  manageOrganizationButton.setEnabled(enable && !ingestRunning);
847  showCasesButton.setEnabled(enable && !ingestRunning);
848  casesPanel.setEnabled(enable && !ingestRunning);
849  casesTextArea.setEnabled(enable && !ingestRunning);
850  return true;
851  }
852 
853  // Variables declaration - do not modify//GEN-BEGIN:variables
854  private javax.swing.JButton bnDbConfigure;
855  private javax.swing.JButton bnManageTypes;
856  private javax.swing.JButton bnTestConfigure;
857  private javax.swing.JPanel casesPanel;
858  private javax.swing.JScrollPane casesScrollPane;
859  private javax.swing.JTextArea casesTextArea;
860  private javax.swing.JCheckBox cbUseCentralRepo;
861  private javax.swing.JScrollPane correlationPropertiesScrollPane;
862  private javax.swing.JTextArea correlationPropertiesTextArea;
863  private javax.swing.JLabel ingestRunningWarningLabel;
864  private javax.swing.JPanel jPanel1;
865  private javax.swing.JScrollPane jScrollPane1;
866  private javax.swing.JLabel lbCentralRepository;
867  private javax.swing.JLabel lbDbLocationLabel;
868  private javax.swing.JLabel lbDbLocationValue;
869  private javax.swing.JLabel lbDbNameLabel;
870  private javax.swing.JLabel lbDbNameValue;
871  private javax.swing.JLabel lbDbPlatformTypeLabel;
872  private javax.swing.JLabel lbDbPlatformValue;
873  private javax.swing.JButton manageOrganizationButton;
874  private javax.swing.JPanel organizationPanel;
875  private javax.swing.JScrollPane organizationScrollPane;
876  private javax.swing.JTextArea organizationTextArea;
877  private javax.swing.JPanel pnCorrelationProperties;
878  private javax.swing.JPanel pnDatabaseConfiguration;
879  private javax.swing.JButton showCasesButton;
880  private javax.swing.JTextField tbOops;
881  private javax.swing.JLabel testStatusLabel;
882  // End of variables declaration//GEN-END:variables
883 }
static synchronized IngestManager getInstance()
static void onMultiUserChange(Component parent, boolean muPreviouslySelected, boolean muCurrentlySelected)
static void setUseCentralRepo(boolean centralRepoCheckBoxIsSelected)
static CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice)
void removeIngestJobEventListener(final PropertyChangeListener listener)
void addIngestJobEventListener(final PropertyChangeListener listener)
static boolean promptCreateDatabase(CentralRepoDbManager manager, EamDbSettingsDialog dialog)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
Definition: Case.java:704
static boolean testStatusAndCreate(Component parent, CentralRepoDbManager manager)
static boolean invokeCrChoice(Component parent, CentralRepoDbChoice initialSelection)

Copyright © 2012-2022 Basis Technology. Generated on: Tue Aug 1 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.