19 package org.sleuthkit.autopsy.corecomponents;
21 import java.awt.Color;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import javax.swing.JTextField;
25 import javax.swing.event.DocumentEvent;
26 import javax.swing.event.DocumentListener;
27 import org.openide.util.NbBundle;
33 import java.awt.Cursor;
34 import java.util.logging.Level;
35 import javax.swing.ImageIcon;
36 import org.openide.util.ImageUtilities;
37 import org.openide.util.Lookup;
61 private final Collection<JTextField>
textBoxes =
new ArrayList<>();
75 controller = theController;
81 Collection<TextPrompt> textPrompts =
new ArrayList<>();
112 textBoxChangedListener =
new TextBoxChangedListener();
125 goodIcon =
new ImageIcon(ImageUtilities.loadImage(
"org/sleuthkit/autopsy/images/good.png",
false));
126 badIcon =
new ImageIcon(ImageUtilities.loadImage(
"org/sleuthkit/autopsy/images/bad.png",
false));
143 textPrompt.setForeground(Color.LIGHT_GRAY);
144 textPrompt.changeAlpha(alpha);
155 for (JTextField textField : textFields) {
156 textField.getDocument().addDocumentListener(listener);
165 @SuppressWarnings(
"unchecked")
173 tbDbPort =
new javax.swing.JTextField();
191 tbMsgPort =
new javax.swing.JTextField();
197 tbOops =
new javax.swing.JTextField();
223 bnTestDatabase.addActionListener(
new java.awt.event.ActionListener() {
224 public void actionPerformed(java.awt.event.ActionEvent evt) {
235 javax.swing.GroupLayout pnDatabaseSettingsLayout =
new javax.swing.GroupLayout(
pnDatabaseSettings);
237 pnDatabaseSettingsLayout.setHorizontalGroup(
238 pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
239 .addGroup(pnDatabaseSettingsLayout.createSequentialGroup()
241 .addGroup(pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
243 .addGroup(pnDatabaseSettingsLayout.createSequentialGroup()
245 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
248 .addComponent(
lbTestDatabase, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
252 .addGroup(pnDatabaseSettingsLayout.createSequentialGroup()
254 .addGap(0, 0, Short.MAX_VALUE)))
257 pnDatabaseSettingsLayout.setVerticalGroup(
258 pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
259 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnDatabaseSettingsLayout.createSequentialGroup()
261 .addGroup(pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
263 .addComponent(
lbTestDatabase, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
265 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
266 .addComponent(
tbDbHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
267 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
268 .addComponent(
tbDbPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
269 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
270 .addComponent(
tbDbUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
271 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
272 .addComponent(
tbDbPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
273 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
274 .addComponent(
lbTestDbWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
278 pnSolrSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
291 bnTestSolr.addActionListener(
new java.awt.event.ActionListener() {
292 public void actionPerformed(java.awt.event.ActionEvent evt) {
302 javax.swing.GroupLayout pnSolrSettingsLayout =
new javax.swing.GroupLayout(
pnSolrSettings);
304 pnSolrSettingsLayout.setHorizontalGroup(
305 pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
306 .addGroup(pnSolrSettingsLayout.createSequentialGroup()
308 .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
310 .addGroup(pnSolrSettingsLayout.createSequentialGroup()
312 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
315 .addComponent(
lbTestSolr, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
317 .addGroup(pnSolrSettingsLayout.createSequentialGroup()
319 .addGap(0, 0, Short.MAX_VALUE)))
322 pnSolrSettingsLayout.setVerticalGroup(
323 pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
324 .addGroup(pnSolrSettingsLayout.createSequentialGroup()
326 .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
327 .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
328 .addComponent(
bnTestSolr, javax.swing.GroupLayout.Alignment.TRAILING)
330 .addComponent(
lbTestSolr, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
331 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
332 .addComponent(
tbSolrHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
333 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
334 .addComponent(
tbSolrPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
335 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
336 .addComponent(
lbTestSolrWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
364 public void actionPerformed(java.awt.event.ActionEvent evt) {
374 javax.swing.GroupLayout pnMessagingSettingsLayout =
new javax.swing.GroupLayout(
pnMessagingSettings);
376 pnMessagingSettingsLayout.setHorizontalGroup(
377 pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
378 .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
380 .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
382 .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
384 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 229, Short.MAX_VALUE)
387 .addComponent(
lbTestMessageService, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
391 .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
393 .addGap(0, 0, Short.MAX_VALUE)))
396 pnMessagingSettingsLayout.setVerticalGroup(
397 pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
398 .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
400 .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
401 .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
404 .addComponent(
lbTestMessageService, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
405 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
406 .addComponent(
tbMsgHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
407 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
408 .addComponent(
tbMsgPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
409 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
410 .addComponent(
tbMsgUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
411 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
412 .addComponent(
tbMsgPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
413 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
414 .addComponent(
lbTestMessageWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
415 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
421 public void itemStateChanged(java.awt.event.ItemEvent evt) {
426 tbOops.setEditable(
false);
427 tbOops.setFont(
tbOops.getFont().deriveFont(
tbOops.getFont().getStyle() | java.awt.Font.BOLD, 12));
428 tbOops.setForeground(
new java.awt.Color(255, 0, 0));
432 javax.swing.GroupLayout pnOverallPanelLayout =
new javax.swing.GroupLayout(
pnOverallPanel);
434 pnOverallPanelLayout.setHorizontalGroup(
435 pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
436 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnOverallPanelLayout.createSequentialGroup()
438 .addGroup(pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
439 .addGroup(pnOverallPanelLayout.createSequentialGroup()
441 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
443 .addComponent(
pnSolrSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
444 .addComponent(
pnDatabaseSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
445 .addComponent(
pnMessagingSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
448 pnOverallPanelLayout.setVerticalGroup(
449 pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
450 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnOverallPanelLayout.createSequentialGroup()
451 .addGroup(pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
452 .addComponent(
tbOops, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
454 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
455 .addComponent(
pnDatabaseSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
456 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
457 .addComponent(
pnSolrSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
458 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
459 .addComponent(
pnMessagingSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
460 .addContainerGap(39, Short.MAX_VALUE))
465 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
466 this.setLayout(layout);
467 layout.setHorizontalGroup(
468 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
469 .addComponent(
jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE)
471 layout.setVerticalGroup(
472 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
473 .addGroup(layout.createSequentialGroup()
475 .addComponent(
jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE)
487 for (JTextField textField : textFields) {
488 textField.setEnabled(enabled);
495 tbOops.setText(NON_WINDOWS_OS_MSG);
516 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
532 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
539 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
543 port = Integer.parseInt(this.
tbMsgPort.getText().trim());
544 }
catch (NumberFormatException ex) {
563 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
570 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
574 if (kwsService != null) {
575 int port = Integer.parseInt(
tbSolrPort.getText().trim());
583 }
catch (NumberFormatException ex) {
590 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
608 }
catch (UserPreferencesException ex) {
609 logger.log(Level.SEVERE,
"Error accessing case database connection info", ex);
613 MessageServiceConnectionInfo msgServiceInfo = UserPreferences.getMessageServiceConnectionInfo();
615 tbMsgPort.setText(Integer.toString(msgServiceInfo.getPort()));
618 }
catch (UserPreferencesException ex) {
619 logger.log(Level.SEVERE,
"Error accessing case database connection info", ex);
622 String indexingServerHost = UserPreferences.getIndexingServerHost().trim();
623 if (!indexingServerHost.isEmpty()) {
626 String indexingServerPort = UserPreferences.getIndexingServerPort().trim();
651 && !
tbDbPort.getText().trim().isEmpty()
676 || (
tbMsgPort.getText().trim().isEmpty())) {
681 boolean isUserSet = (
tbMsgUsername.getText().trim().isEmpty() ==
false);
683 return (isUserSet == isPwSet);
692 UserPreferences.setIsMultiUserModeEnabled(multiUserCasesEnabled);
693 if (multiUserCasesEnabled ==
false) {
701 DbType dbType = DbType.POSTGRESQL;
702 CaseDbConnectionInfo info =
new CaseDbConnectionInfo(
709 UserPreferences.setDatabaseConnectionInfo(info);
710 }
catch (UserPreferencesException ex) {
711 logger.log(Level.SEVERE,
"Error saving case database connection info", ex);
714 int msgServicePort = 0;
716 msgServicePort = Integer.parseInt(this.
tbMsgPort.getText().trim());
717 }
catch (NumberFormatException ex) {
718 logger.log(Level.SEVERE,
"Could not parse messaging service port setting", ex);
721 MessageServiceConnectionInfo msgServiceInfo =
new MessageServiceConnectionInfo(
728 UserPreferences.setMessageServiceConnectionInfo(msgServiceInfo);
729 }
catch (UserPreferencesException ex) {
730 logger.log(Level.SEVERE,
"Error saving messaging service connection info", ex);
733 UserPreferences.setIndexingServerHost(
tbSolrHostname.getText().trim());
734 UserPreferences.setIndexingServerPort(Integer.parseInt(
tbSolrPort.getText().trim()));
745 tbOops.setText(NON_WINDOWS_OS_MSG);
751 return checkFieldsAndEnableButtons()
752 && databaseSettingsAreValid()
753 && indexingServerSettingsAreValid()
754 && messageServiceSettingsAreValid();
766 boolean checkFieldsAndEnableButtons() {
767 boolean result =
true;
782 if (!dbPopulated || !solrPopulated || !messageServicePopulated) {
785 tbOops.setText(INCOMPLETE_SETTINGS_MSG);
795 boolean databaseSettingsAreValid() {
799 tbOops.setText(INVALID_DB_PORT_MSG);
809 boolean messageServiceSettingsAreValid() {
811 tbOops.setText(INVALID_MESSAGE_SERVICE_PORT_MSG);
823 boolean indexingServerSettingsAreValid() {
825 tbOops.setText(INVALID_INDEXING_SERVER_PORT_MSG);
842 int value = Integer.parseInt(portNumber);
843 if (value < 0 || value > 65535) {
846 }
catch (NumberFormatException detailsNotImportant) {
888 class TextBoxChangedListener
implements DocumentListener {
891 public void changedUpdate(DocumentEvent e) {
892 Object statusIcon = e.getDocument().getProperty(
"statusIcon");
893 if (statusIcon != null) {
894 ((javax.swing.JLabel) statusIcon).setIcon(null);
900 public void insertUpdate(DocumentEvent e) {
901 Object statusIcon = e.getDocument().getProperty(
"statusIcon");
902 if (statusIcon != null) {
903 ((javax.swing.JLabel) statusIcon).setIcon(null);
909 public void removeUpdate(DocumentEvent e) {
910 Object statusIcon = e.getDocument().getProperty(
"statusIcon");
911 if (statusIcon != null) {
912 ((javax.swing.JLabel) statusIcon).setIcon(null);
void cbEnableMultiUserItemStateChanged(java.awt.event.ItemEvent evt)
static void configureTextPrompts(Collection< TextPrompt > textPrompts)
static final String INCOMPLETE_SETTINGS_MSG
javax.swing.JPanel pnSolrSettings
javax.swing.JLabel lbTestDatabase
javax.swing.JTextField tbSolrHostname
static final long serialVersionUID
javax.swing.JPanel pnMessagingSettings
javax.swing.JPanel pnDatabaseSettings
static final String PASSWORD_PROMPT_OPT
javax.swing.JTextField tbDbUsername
void tryConnect(String host, int port)
javax.swing.JLabel lbTestDbWarning
javax.swing.JLabel lbDatabaseSettings
javax.swing.JLabel lbTestSolrWarning
static final String HOST_NAME_OR_IP_PROMPT
final TextBoxChangedListener textBoxChangedListener
javax.swing.JPanel pnOverallPanel
javax.swing.JTextField tbMsgHostname
static final String PORT_PROMPT
static final String INVALID_MESSAGE_SERVICE_PORT_MSG
javax.swing.JCheckBox cbEnableMultiUser
void bnTestDatabaseActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JTextField tbSolrPort
static CaseDbConnectionInfo getDatabaseConnectionInfo()
javax.swing.JTextField tbOops
static final String USER_NAME_PROMPT
MultiUserSettingsPanel(MultiUserSettingsPanelController theController)
javax.swing.JTextField tbDbPort
javax.swing.JButton bnTestSolr
javax.swing.JLabel lbTestMessageWarning
javax.swing.JTextField tbMsgPort
static boolean portNumberIsValid(String portNumber)
javax.swing.JLabel lbTestMessageService
static final String NON_WINDOWS_OS_MSG
boolean messageServiceFieldsArePopulated()
javax.swing.JTextField tbDbHostname
boolean databaseFieldsArePopulated()
void bnTestSolrActionPerformed(java.awt.event.ActionEvent evt)
final MultiUserSettingsPanelController controller
static final boolean isWindowsOS
static final String PASSWORD_PROMPT
javax.swing.JTextField tbMsgUsername
synchronized static Logger getLogger(String name)
static void tryConnect(CaseDbConnectionInfo info)
boolean solrFieldsArePopulated()
static void enableMultiUserComponents(Collection< JTextField > textFields, boolean enabled)
javax.swing.JButton bnTestMessageService
static final String USER_NAME_PROMPT_OPT
void bnTestMessageServiceActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JPasswordField tbDbPassword
javax.swing.JLabel lbSolrSettings
final Collection< JTextField > textBoxes
javax.swing.JPasswordField tbMsgPassword
javax.swing.JLabel lbMessageServiceSettings
static final String INVALID_DB_PORT_MSG
static final Logger logger
javax.swing.JScrollPane jScrollPane
javax.swing.JButton bnTestDatabase
static final String INVALID_INDEXING_SERVER_PORT_MSG
static void addDocumentListeners(Collection< JTextField > textFields, TextBoxChangedListener listener)
javax.swing.JLabel lbTestSolr