Autopsy  4.16.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
MultiUserSettingsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-2018 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.corecomponents;
20 
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;
28 import org.sleuthkit.datamodel.CaseDbConnectionInfo;
29 import org.sleuthkit.datamodel.TskData.DbType;
34 import java.awt.Cursor;
35 import java.util.logging.Level;
36 import javax.swing.ImageIcon;
37 import org.openide.util.ImageUtilities;
38 import org.openide.util.Lookup;
44 import org.sleuthkit.datamodel.SleuthkitCase;
45 import org.sleuthkit.datamodel.TskCoreException;
46 
50 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
51 public final class MultiUserSettingsPanel extends javax.swing.JPanel {
52 
53  private static final String HOST_NAME_OR_IP_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbHostname.toolTipText");
54  private static final String PORT_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPort.toolTipText");
55  private static final String USER_NAME_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbUsername.toolTipText");
56  private static final String PASSWORD_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPassword.toolTipText");
57  private static final String USER_NAME_PROMPT_OPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgUsername.toolTipText");
58  private static final String PASSWORD_PROMPT_OPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgPassword.toolTipText");
59  private static final String INCOMPLETE_SETTINGS_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.incomplete");
60  private static final String INVALID_DB_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidDatabasePort");
61  private static final String INVALID_MESSAGE_SERVICE_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidMessageServicePort");
62  private static final String INVALID_INDEXING_SERVER_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidIndexingServerPort");
63  private static final long serialVersionUID = 1L;
65  private final Collection<JTextField> textBoxes = new ArrayList<>();
66  private final TextBoxChangedListener textBoxChangedListener;
67  private static final Logger logger = Logger.getLogger(MultiUserSettingsPanel.class.getName());
68  private final ImageIcon goodIcon;
69  private final ImageIcon badIcon;
70  private static final boolean isWindowsOS = PlatformUtil.isWindowsOS();
71 
78  initComponents();
79  controller = theController;
80  setSize(555, 600);
81 
85  Collection<TextPrompt> textPrompts = new ArrayList<>();
86  textPrompts.add(new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbDbHostname));
87  textPrompts.add(new TextPrompt(PORT_PROMPT, tbDbPort));
88  textPrompts.add(new TextPrompt(USER_NAME_PROMPT, tbDbUsername));
89  textPrompts.add(new TextPrompt(PASSWORD_PROMPT, tbDbPassword));
90  textPrompts.add(new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbMsgHostname));
91  textPrompts.add(new TextPrompt(PORT_PROMPT, tbMsgPort));
92  textPrompts.add(new TextPrompt(USER_NAME_PROMPT_OPT, tbMsgUsername));
93  textPrompts.add(new TextPrompt(PASSWORD_PROMPT_OPT, tbMsgPassword));
94  textPrompts.add(new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbSolrHostname));
95  textPrompts.add(new TextPrompt(PORT_PROMPT, tbSolrPort));
96  configureTextPrompts(textPrompts);
97 
98  /*
99  * Set each textbox with a "statusIcon" property enabling the
100  * DocumentListeners to know which icon to erase when changes are made
101  */
102  tbDbHostname.getDocument().putProperty("statusIcon", lbTestDatabase);
103  tbDbPort.getDocument().putProperty("statusIcon", lbTestDatabase);
104  tbDbUsername.getDocument().putProperty("statusIcon", lbTestDatabase);
105  tbDbPassword.getDocument().putProperty("statusIcon", lbTestDatabase);
106 
107  tbSolrHostname.getDocument().putProperty("statusIcon", lbTestSolr);
108  tbSolrPort.getDocument().putProperty("statusIcon", lbTestSolr);
109 
110  tbMsgHostname.getDocument().putProperty("statusIcon", lbTestMessageService);
111  tbMsgPort.getDocument().putProperty("statusIcon", lbTestMessageService);
112  tbMsgUsername.getDocument().putProperty("statusIcon", lbTestMessageService);
113  tbMsgPassword.getDocument().putProperty("statusIcon", lbTestMessageService);
114 
116  textBoxChangedListener = new TextBoxChangedListener();
117  textBoxes.add(tbDbHostname);
118  textBoxes.add(tbDbPort);
119  textBoxes.add(tbDbUsername);
120  textBoxes.add(tbDbPassword);
121  textBoxes.add(tbMsgHostname);
122  textBoxes.add(tbMsgPort);
123  textBoxes.add(tbMsgUsername);
124  textBoxes.add(tbMsgPassword);
125  textBoxes.add(tbSolrHostname);
126  textBoxes.add(tbSolrPort);
127 
128  addDocumentListeners(textBoxes, textBoxChangedListener);
129  goodIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/good.png", false));
130  badIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/bad.png", false));
131  enableMultiUserComponents(textBoxes, cbEnableMultiUser.isSelected());
132  }
133 
140  private static void configureTextPrompts(Collection<TextPrompt> textPrompts) {
141  float alpha = 0.9f; // Mostly opaque
142  for (TextPrompt textPrompt : textPrompts) {
143  textPrompt.setForeground(Color.LIGHT_GRAY);
144  textPrompt.changeAlpha(alpha);
145  }
146  }
147 
154  private static void addDocumentListeners(Collection<JTextField> textFields, TextBoxChangedListener listener) {
155  for (JTextField textField : textFields) {
156  textField.getDocument().addDocumentListener(listener);
157  }
158  }
159 
165  @SuppressWarnings("unchecked")
166  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
167  private void initComponents() {
168 
169  jScrollPane = new javax.swing.JScrollPane();
170  pnOverallPanel = new javax.swing.JPanel();
171  pnDatabaseSettings = new javax.swing.JPanel();
172  tbDbHostname = new javax.swing.JTextField();
173  tbDbPort = new javax.swing.JTextField();
174  tbDbUsername = new javax.swing.JTextField();
175  tbDbPassword = new javax.swing.JPasswordField();
176  lbDatabaseSettings = new javax.swing.JLabel();
177  bnTestDatabase = new javax.swing.JButton();
178  lbTestDatabase = new javax.swing.JLabel();
179  lbTestDbWarning = new javax.swing.JLabel();
180  pnSolrSettings = new javax.swing.JPanel();
181  lbSolrSettings = new javax.swing.JLabel();
182  tbSolrHostname = new javax.swing.JTextField();
183  tbSolrPort = new javax.swing.JTextField();
184  bnTestSolr = new javax.swing.JButton();
185  lbTestSolr = new javax.swing.JLabel();
186  lbTestSolrWarning = new javax.swing.JLabel();
187  pnMessagingSettings = new javax.swing.JPanel();
188  lbMessageServiceSettings = new javax.swing.JLabel();
189  tbMsgHostname = new javax.swing.JTextField();
190  tbMsgUsername = new javax.swing.JTextField();
191  tbMsgPort = new javax.swing.JTextField();
192  tbMsgPassword = new javax.swing.JPasswordField();
193  bnTestMessageService = new javax.swing.JButton();
194  lbTestMessageService = new javax.swing.JLabel();
195  lbTestMessageWarning = new javax.swing.JLabel();
196  cbEnableMultiUser = new javax.swing.JCheckBox();
197  tbOops = new javax.swing.JTextField();
198 
199  pnDatabaseSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
200 
201  tbDbHostname.setFont(tbDbHostname.getFont().deriveFont(tbDbHostname.getFont().getSize()+1f));
202  tbDbHostname.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbHostname.text")); // NOI18N
203  tbDbHostname.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbHostname.toolTipText")); // NOI18N
204 
205  tbDbPort.setFont(tbDbPort.getFont().deriveFont(tbDbPort.getFont().getSize()+1f));
206  tbDbPort.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPort.text")); // NOI18N
207  tbDbPort.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPort.toolTipText")); // NOI18N
208 
209  tbDbUsername.setFont(tbDbUsername.getFont().deriveFont(tbDbUsername.getFont().getSize()+1f));
210  tbDbUsername.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbUsername.text")); // NOI18N
211  tbDbUsername.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbUsername.toolTipText")); // NOI18N
212 
213  tbDbPassword.setFont(tbDbPassword.getFont().deriveFont(tbDbPassword.getFont().getSize()+1f));
214  tbDbPassword.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPassword.text")); // NOI18N
215  tbDbPassword.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPassword.toolTipText")); // NOI18N
216 
217  lbDatabaseSettings.setFont(lbDatabaseSettings.getFont().deriveFont(lbDatabaseSettings.getFont().getSize()+1f));
218  org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseSettings, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbDatabaseSettings.text")); // NOI18N
219  lbDatabaseSettings.setVerticalAlignment(javax.swing.SwingConstants.TOP);
220 
221  org.openide.awt.Mnemonics.setLocalizedText(bnTestDatabase, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.bnTestDatabase.text")); // NOI18N
222  bnTestDatabase.addActionListener(new java.awt.event.ActionListener() {
223  public void actionPerformed(java.awt.event.ActionEvent evt) {
224  bnTestDatabaseActionPerformed(evt);
225  }
226  });
227 
228  org.openide.awt.Mnemonics.setLocalizedText(lbTestDatabase, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestDatabase.text")); // NOI18N
229  lbTestDatabase.setAutoscrolls(true);
230 
231  lbTestDbWarning.setForeground(new java.awt.Color(255, 0, 0));
232  org.openide.awt.Mnemonics.setLocalizedText(lbTestDbWarning, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestDbWarning.text")); // NOI18N
233 
234  javax.swing.GroupLayout pnDatabaseSettingsLayout = new javax.swing.GroupLayout(pnDatabaseSettings);
235  pnDatabaseSettings.setLayout(pnDatabaseSettingsLayout);
236  pnDatabaseSettingsLayout.setHorizontalGroup(
237  pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
238  .addGroup(pnDatabaseSettingsLayout.createSequentialGroup()
239  .addContainerGap()
240  .addGroup(pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
241  .addComponent(tbDbHostname)
242  .addGroup(pnDatabaseSettingsLayout.createSequentialGroup()
243  .addComponent(lbDatabaseSettings)
244  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
245  .addComponent(bnTestDatabase)
246  .addGap(18, 18, 18)
247  .addComponent(lbTestDatabase, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
248  .addComponent(tbDbPort)
249  .addComponent(tbDbUsername)
250  .addComponent(tbDbPassword)
251  .addGroup(pnDatabaseSettingsLayout.createSequentialGroup()
252  .addComponent(lbTestDbWarning)
253  .addGap(0, 0, Short.MAX_VALUE)))
254  .addContainerGap())
255  );
256  pnDatabaseSettingsLayout.setVerticalGroup(
257  pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
258  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnDatabaseSettingsLayout.createSequentialGroup()
259  .addContainerGap()
260  .addGroup(pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
261  .addComponent(bnTestDatabase)
262  .addComponent(lbTestDatabase, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
263  .addComponent(lbDatabaseSettings))
264  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
265  .addComponent(tbDbHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
266  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
267  .addComponent(tbDbPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
268  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
269  .addComponent(tbDbUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
270  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
271  .addComponent(tbDbPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
272  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
273  .addComponent(lbTestDbWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
274  .addContainerGap())
275  );
276 
277  pnSolrSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
278 
279  lbSolrSettings.setFont(lbSolrSettings.getFont().deriveFont(lbSolrSettings.getFont().getSize()+1f));
280  org.openide.awt.Mnemonics.setLocalizedText(lbSolrSettings, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbSolrSettings.text")); // NOI18N
281 
282  tbSolrHostname.setFont(tbSolrHostname.getFont().deriveFont(tbSolrHostname.getFont().getSize()+1f));
283  tbSolrHostname.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbSolrHostname.toolTipText")); // NOI18N
284 
285  tbSolrPort.setFont(tbSolrPort.getFont().deriveFont(tbSolrPort.getFont().getSize()+1f));
286  tbSolrPort.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbSolrPort.toolTipText")); // NOI18N
287 
288  org.openide.awt.Mnemonics.setLocalizedText(bnTestSolr, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.bnTestSolr.text")); // NOI18N
289  bnTestSolr.addActionListener(new java.awt.event.ActionListener() {
290  public void actionPerformed(java.awt.event.ActionEvent evt) {
291  bnTestSolrActionPerformed(evt);
292  }
293  });
294 
295  org.openide.awt.Mnemonics.setLocalizedText(lbTestSolr, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestSolr.text")); // NOI18N
296 
297  lbTestSolrWarning.setForeground(new java.awt.Color(255, 0, 0));
298  org.openide.awt.Mnemonics.setLocalizedText(lbTestSolrWarning, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestSolrWarning.text")); // NOI18N
299 
300  javax.swing.GroupLayout pnSolrSettingsLayout = new javax.swing.GroupLayout(pnSolrSettings);
301  pnSolrSettings.setLayout(pnSolrSettingsLayout);
302  pnSolrSettingsLayout.setHorizontalGroup(
303  pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
304  .addGroup(pnSolrSettingsLayout.createSequentialGroup()
305  .addContainerGap()
306  .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
307  .addComponent(tbSolrHostname)
308  .addGroup(pnSolrSettingsLayout.createSequentialGroup()
309  .addComponent(lbSolrSettings)
310  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
311  .addComponent(bnTestSolr)
312  .addGap(18, 18, 18)
313  .addComponent(lbTestSolr, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
314  .addComponent(tbSolrPort)
315  .addGroup(pnSolrSettingsLayout.createSequentialGroup()
316  .addComponent(lbTestSolrWarning)
317  .addGap(0, 0, Short.MAX_VALUE)))
318  .addContainerGap())
319  );
320  pnSolrSettingsLayout.setVerticalGroup(
321  pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
322  .addGroup(pnSolrSettingsLayout.createSequentialGroup()
323  .addContainerGap()
324  .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
325  .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
326  .addComponent(bnTestSolr, javax.swing.GroupLayout.Alignment.TRAILING)
327  .addComponent(lbSolrSettings))
328  .addComponent(lbTestSolr, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
329  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
330  .addComponent(tbSolrHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
331  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
332  .addComponent(tbSolrPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
333  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
334  .addComponent(lbTestSolrWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
335  .addContainerGap())
336  );
337 
338  pnMessagingSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
339 
340  lbMessageServiceSettings.setFont(lbMessageServiceSettings.getFont().deriveFont((float)12));
341  org.openide.awt.Mnemonics.setLocalizedText(lbMessageServiceSettings, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbMessageServiceSettings.text")); // NOI18N
342 
343  tbMsgHostname.setFont(tbMsgHostname.getFont().deriveFont(tbMsgHostname.getFont().getSize()+1f));
344  tbMsgHostname.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgHostname.text")); // NOI18N
345  tbMsgHostname.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgHostname.toolTipText")); // NOI18N
346 
347  tbMsgUsername.setFont(tbMsgUsername.getFont().deriveFont(tbMsgUsername.getFont().getSize()+1f));
348  tbMsgUsername.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgUsername.text")); // NOI18N
349  tbMsgUsername.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgUsername.toolTipText")); // NOI18N
350 
351  tbMsgPort.setFont(tbMsgPort.getFont().deriveFont(tbMsgPort.getFont().getSize()+1f));
352  tbMsgPort.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgPort.text")); // NOI18N
353  tbMsgPort.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgPort.toolTipText")); // NOI18N
354 
355  tbMsgPassword.setFont(tbMsgPassword.getFont().deriveFont(tbMsgPassword.getFont().getSize()+1f));
356  tbMsgPassword.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgPassword.text")); // NOI18N
357  tbMsgPassword.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgPassword.toolTipText")); // NOI18N
358 
359  org.openide.awt.Mnemonics.setLocalizedText(bnTestMessageService, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.bnTestMessageService.text")); // NOI18N
360  bnTestMessageService.addActionListener(new java.awt.event.ActionListener() {
361  public void actionPerformed(java.awt.event.ActionEvent evt) {
362  bnTestMessageServiceActionPerformed(evt);
363  }
364  });
365 
366  org.openide.awt.Mnemonics.setLocalizedText(lbTestMessageService, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestMessageService.text")); // NOI18N
367 
368  lbTestMessageWarning.setForeground(new java.awt.Color(255, 0, 0));
369  org.openide.awt.Mnemonics.setLocalizedText(lbTestMessageWarning, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestMessageWarning.text")); // NOI18N
370 
371  javax.swing.GroupLayout pnMessagingSettingsLayout = new javax.swing.GroupLayout(pnMessagingSettings);
372  pnMessagingSettings.setLayout(pnMessagingSettingsLayout);
373  pnMessagingSettingsLayout.setHorizontalGroup(
374  pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
375  .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
376  .addContainerGap()
377  .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
378  .addComponent(tbMsgHostname)
379  .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
380  .addComponent(lbMessageServiceSettings)
381  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 229, Short.MAX_VALUE)
382  .addComponent(bnTestMessageService)
383  .addGap(18, 18, 18)
384  .addComponent(lbTestMessageService, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
385  .addComponent(tbMsgPort)
386  .addComponent(tbMsgUsername)
387  .addComponent(tbMsgPassword)
388  .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
389  .addComponent(lbTestMessageWarning)
390  .addGap(0, 0, Short.MAX_VALUE)))
391  .addContainerGap())
392  );
393  pnMessagingSettingsLayout.setVerticalGroup(
394  pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
395  .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
396  .addContainerGap()
397  .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
398  .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
399  .addComponent(bnTestMessageService, javax.swing.GroupLayout.Alignment.TRAILING)
400  .addComponent(lbMessageServiceSettings))
401  .addComponent(lbTestMessageService, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
402  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
403  .addComponent(tbMsgHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
404  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
405  .addComponent(tbMsgPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
406  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
407  .addComponent(tbMsgUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
408  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
409  .addComponent(tbMsgPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
410  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
411  .addComponent(lbTestMessageWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
412  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
413  );
414 
415  org.openide.awt.Mnemonics.setLocalizedText(cbEnableMultiUser, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.cbEnableMultiUser.text")); // NOI18N
416  cbEnableMultiUser.addItemListener(new java.awt.event.ItemListener() {
417  public void itemStateChanged(java.awt.event.ItemEvent evt) {
418  cbEnableMultiUserItemStateChanged(evt);
419  }
420  });
421 
422  tbOops.setEditable(false);
423  tbOops.setFont(tbOops.getFont().deriveFont(tbOops.getFont().getStyle() | java.awt.Font.BOLD, tbOops.getFont().getSize()+1));
424  tbOops.setForeground(new java.awt.Color(255, 0, 0));
425  tbOops.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbOops.text")); // NOI18N
426  tbOops.setBorder(null);
427 
428  javax.swing.GroupLayout pnOverallPanelLayout = new javax.swing.GroupLayout(pnOverallPanel);
429  pnOverallPanel.setLayout(pnOverallPanelLayout);
430  pnOverallPanelLayout.setHorizontalGroup(
431  pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
432  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnOverallPanelLayout.createSequentialGroup()
433  .addContainerGap()
434  .addGroup(pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
435  .addGroup(pnOverallPanelLayout.createSequentialGroup()
436  .addComponent(cbEnableMultiUser)
437  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
438  .addComponent(tbOops))
439  .addComponent(pnSolrSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
440  .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
441  .addComponent(pnMessagingSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
442  .addContainerGap())
443  );
444  pnOverallPanelLayout.setVerticalGroup(
445  pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
446  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnOverallPanelLayout.createSequentialGroup()
447  .addGroup(pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
448  .addComponent(tbOops, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
449  .addComponent(cbEnableMultiUser))
450  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
451  .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
452  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
453  .addComponent(pnSolrSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
454  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
455  .addComponent(pnMessagingSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
456  .addContainerGap(39, Short.MAX_VALUE))
457  );
458 
459  jScrollPane.setViewportView(pnOverallPanel);
460 
461  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
462  this.setLayout(layout);
463  layout.setHorizontalGroup(
464  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
465  .addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE)
466  );
467  layout.setVerticalGroup(
468  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
469  .addGroup(layout.createSequentialGroup()
470  .addContainerGap()
471  .addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE)
472  .addContainerGap())
473  );
474  }// </editor-fold>//GEN-END:initComponents
475 
482  private static void enableMultiUserComponents(Collection<JTextField> textFields, boolean enabled) {
483  for (JTextField textField : textFields) {
484  textField.setEnabled(enabled);
485  }
486  }
487 
488  private void cbEnableMultiUserItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbEnableMultiUserItemStateChanged
489  if (!cbEnableMultiUser.isSelected()) {
490  tbOops.setText("");
491  bnTestDatabase.setEnabled(false);
492  lbTestDatabase.setIcon(null);
493  bnTestSolr.setEnabled(false);
494  lbTestSolr.setIcon(null);
495  bnTestMessageService.setEnabled(false);
496  lbTestMessageService.setIcon(null);
497  lbTestDbWarning.setText("");
498  lbTestSolrWarning.setText("");
499  lbTestMessageWarning.setText("");
500  }
501  enableMultiUserComponents(textBoxes, cbEnableMultiUser.isSelected());
502  controller.changed();
503  }//GEN-LAST:event_cbEnableMultiUserItemStateChanged
504 
505  private void bnTestDatabaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnTestDatabaseActionPerformed
506  lbTestDatabase.setIcon(null);
507  lbTestDatabase.paintImmediately(lbTestDatabase.getVisibleRect());
508  lbTestDbWarning.setText("");
509  lbTestDbWarning.paintImmediately(lbTestDbWarning.getVisibleRect());
510  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
511  try {
512  CaseDbConnectionInfo info = new CaseDbConnectionInfo(
513  this.tbDbHostname.getText().trim(),
514  this.tbDbPort.getText().trim(),
515  this.tbDbUsername.getText().trim(),
516  new String(this.tbDbPassword.getPassword()),
517  DbType.POSTGRESQL);
518 
519  SleuthkitCase.tryConnect(info);
520  lbTestDatabase.setIcon(goodIcon);
521  lbTestDbWarning.setText("");
522  } catch (TskCoreException ex) {
523  lbTestDatabase.setIcon(badIcon);
524  lbTestDbWarning.setText(ex.getMessage());
525  } finally {
526  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
527  }
528  }//GEN-LAST:event_bnTestDatabaseActionPerformed
529 
530  private void bnTestMessageServiceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnTestMessageServiceActionPerformed
531  lbTestMessageService.setIcon(null);
532  lbTestMessageService.paintImmediately(lbTestMessageService.getVisibleRect());
533  lbTestMessageWarning.setText("");
534  lbTestMessageWarning.paintImmediately(lbTestMessageWarning.getVisibleRect());
535  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
536 
537  int port;
538  try {
539  port = Integer.parseInt(this.tbMsgPort.getText().trim());
540  } catch (NumberFormatException ex) {
541  lbTestMessageService.setIcon(badIcon);
542  lbTestMessageWarning.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.InvalidPortNumber"));
543  return;
544  }
545 
547  this.tbMsgHostname.getText().trim(),
548  port,
549  this.tbMsgUsername.getText().trim(),
550  new String(this.tbMsgPassword.getPassword()));
551  try {
552  info.tryConnect();
553  lbTestMessageService.setIcon(goodIcon);
554  lbTestMessageWarning.setText("");
555  } catch (MessageServiceException ex) {
556  lbTestMessageService.setIcon(badIcon);
557  lbTestMessageWarning.setText(ex.getMessage());
558  } finally {
559  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
560  }
561  }//GEN-LAST:event_bnTestMessageServiceActionPerformed
562 
563  private void bnTestSolrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnTestSolrActionPerformed
564  lbTestSolr.setIcon(null);
565  lbTestSolr.paintImmediately(lbTestSolr.getVisibleRect());
566  lbTestSolrWarning.setText("");
567  lbTestSolrWarning.paintImmediately(lbTestSolrWarning.getVisibleRect());
568  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
569 
570  KeywordSearchService kwsService = Lookup.getDefault().lookup(KeywordSearchService.class);
571  try {
572  if (kwsService != null) {
573  int port = Integer.parseInt(tbSolrPort.getText().trim());
574  kwsService.tryConnect(tbSolrHostname.getText().trim(), port);
575  lbTestSolr.setIcon(goodIcon);
576  lbTestSolrWarning.setText("");
577  } else {
578  lbTestSolr.setIcon(badIcon);
579  lbTestSolrWarning.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.KeywordSearchNull"));
580  }
581  } catch (NumberFormatException ex) {
582  lbTestSolr.setIcon(badIcon);
583  lbTestSolrWarning.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.InvalidPortNumber"));
584  } catch (KeywordSearchServiceException ex) {
585  lbTestSolr.setIcon(badIcon);
586  lbTestSolrWarning.setText(ex.getMessage());
587  } finally {
588  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
589  }
590  }//GEN-LAST:event_bnTestSolrActionPerformed
591 
592  void load() {
593  lbTestDatabase.setIcon(null);
594  lbTestSolr.setIcon(null);
595  lbTestMessageService.setIcon(null);
596  lbTestDbWarning.setText("");
597  lbTestSolrWarning.setText("");
598  lbTestMessageWarning.setText("");
599 
600  try {
601  CaseDbConnectionInfo dbInfo = UserPreferences.getDatabaseConnectionInfo();
602  tbDbHostname.setText(dbInfo.getHost().trim());
603  tbDbPort.setText(dbInfo.getPort().trim());
604  tbDbUsername.setText(dbInfo.getUserName().trim());
605  tbDbPassword.setText(dbInfo.getPassword());
606  } catch (UserPreferencesException ex) {
607  logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
608  }
609 
610  try {
611  MessageServiceConnectionInfo msgServiceInfo = UserPreferences.getMessageServiceConnectionInfo();
612  tbMsgHostname.setText(msgServiceInfo.getHost().trim());
613  tbMsgPort.setText(Integer.toString(msgServiceInfo.getPort()));
614  tbMsgUsername.setText(msgServiceInfo.getUserName().trim());
615  tbMsgPassword.setText(msgServiceInfo.getPassword());
616  } catch (UserPreferencesException ex) {
617  logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
618  }
619 
620  String indexingServerHost = UserPreferences.getIndexingServerHost().trim();
621  if (!indexingServerHost.isEmpty()) {
622  tbSolrHostname.setText(indexingServerHost);
623  }
624  String indexingServerPort = UserPreferences.getIndexingServerPort().trim();
625  if (portNumberIsValid(indexingServerPort)) {
626  tbSolrPort.setText(indexingServerPort);
627  }
628 
629  lbTestDatabase.setIcon(null);
630  lbTestSolr.setIcon(null);
631  lbTestMessageService.setIcon(null);
632 
633  bnTestDatabase.setEnabled(false);
634  bnTestSolr.setEnabled(false);
635  bnTestMessageService.setEnabled(false);
636 
637  cbEnableMultiUser.setSelected(UserPreferences.getIsMultiUserModeEnabled());
638  this.valid(); // trigger validation to enable buttons based on current settings
639  }
640 
647  private boolean databaseFieldsArePopulated() {
648  return !tbDbHostname.getText().trim().isEmpty()
649  && !tbDbPort.getText().trim().isEmpty()
650  && !tbDbUsername.getText().trim().isEmpty()
651  && tbDbPassword.getPassword().length != 0;
652  }
653 
660  private boolean solrFieldsArePopulated() {
661  return !tbSolrHostname.getText().trim().isEmpty()
662  && !tbSolrPort.getText().trim().isEmpty();
663  }
664 
672 
673  if ((tbMsgHostname.getText().trim().isEmpty())
674  || (tbMsgPort.getText().trim().isEmpty())) {
675  return false;
676  }
677 
678  // user name and pw are optional, but make sure they are both set or both empty
679  boolean isUserSet = (tbMsgUsername.getText().trim().isEmpty() == false);
680  boolean isPwSet = (tbMsgPassword.getPassword().length != 0);
681  return (isUserSet == isPwSet);
682  }
683 
684 
685 
686  void store() {
687  boolean prevSelected = UserPreferences.getIsMultiUserModeEnabled();
688  CaseDbConnectionInfo prevConn = null;
689  try {
691  } catch (UserPreferencesException ex) {
692  logger.log(Level.SEVERE, "There was an error while fetching previous connection settings while trying to save", ex); //NON-NLS
693  }
694 
695  boolean multiUserCasesEnabled = cbEnableMultiUser.isSelected();
696  UserPreferences.setIsMultiUserModeEnabled(multiUserCasesEnabled);
697 
698  CaseDbConnectionInfo info = null;
699 
700  if (multiUserCasesEnabled == true) {
701 
702  /*
703  * Currently only supporting multi-user cases with PostgreSQL case
704  * databases.
705  */
706  DbType dbType = DbType.POSTGRESQL;
707  info = new CaseDbConnectionInfo(
708  tbDbHostname.getText().trim(),
709  tbDbPort.getText().trim(),
710  tbDbUsername.getText().trim(),
711  new String(tbDbPassword.getPassword()),
712  dbType);
713  try {
714  UserPreferences.setDatabaseConnectionInfo(info);
715  } catch (UserPreferencesException ex) {
716  logger.log(Level.SEVERE, "Error saving case database connection info", ex); //NON-NLS
717  }
718 
719  int msgServicePort = 0;
720  try {
721  msgServicePort = Integer.parseInt(this.tbMsgPort.getText().trim());
722  } catch (NumberFormatException ex) {
723  logger.log(Level.SEVERE, "Could not parse messaging service port setting", ex);
724  }
725 
726  MessageServiceConnectionInfo msgServiceInfo = new MessageServiceConnectionInfo(
727  tbMsgHostname.getText().trim(),
728  msgServicePort,
729  tbMsgUsername.getText().trim(),
730  new String(tbMsgPassword.getPassword()));
731 
732  try {
733  UserPreferences.setMessageServiceConnectionInfo(msgServiceInfo);
734  } catch (UserPreferencesException ex) {
735  logger.log(Level.SEVERE, "Error saving messaging service connection info", ex); //NON-NLS
736  }
737 
738  UserPreferences.setIndexingServerHost(tbSolrHostname.getText().trim());
739  UserPreferences.setIndexingServerPort(Integer.parseInt(tbSolrPort.getText().trim()));
740  }
741 
742  // trigger changes to whether or not user can use multi user settings for central repository
743  if (prevSelected != multiUserCasesEnabled || !areCaseDbConnectionEqual(prevConn, info))
744  GlobalSettingsPanel.onMultiUserChange(this, prevSelected, multiUserCasesEnabled);
745  }
746 
747  private static boolean arePropsEqual(Object a, Object b) {
748  if (a == null || b == null) {
749  return (a == null && b == null);
750  }
751  else {
752  return a.equals(b);
753  }
754  }
755 
756  private static boolean areCaseDbConnectionEqual(CaseDbConnectionInfo a, CaseDbConnectionInfo b) {
757  if (a == null || b == null) {
758  return (a == null && b == null);
759  }
760 
761  return
762  arePropsEqual(a.getDbType(), b.getDbType()) &&
763  arePropsEqual(a.getHost(), b.getHost()) &&
764  arePropsEqual(a.getPassword(), b.getPassword()) &&
765  arePropsEqual(a.getPort(), b.getPort()) &&
766  arePropsEqual(a.getUserName(), b.getUserName());
767  }
768 
769 
775  boolean valid() {
776  tbOops.setText("");
777 
778  if (cbEnableMultiUser.isSelected()) {
779  return checkFieldsAndEnableButtons()
780  && databaseSettingsAreValid()
781  && indexingServerSettingsAreValid()
782  && messageServiceSettingsAreValid();
783  } else {
784  return true;
785  }
786  }
787 
794  boolean checkFieldsAndEnableButtons() {
795  boolean result = true;
796 
797  boolean dbPopulated = databaseFieldsArePopulated();
798  boolean solrPopulated = solrFieldsArePopulated();
799  boolean messageServicePopulated = messageServiceFieldsArePopulated();
800 
801  // PostgreSQL Database
802  bnTestDatabase.setEnabled(dbPopulated);
803 
804  // Solr Indexing
805  bnTestSolr.setEnabled(solrPopulated);
806 
807  // ActiveMQ Messaging
808  bnTestMessageService.setEnabled(messageServicePopulated);
809 
810  if (!dbPopulated || !solrPopulated || !messageServicePopulated) {
811  // We don't even have everything filled out
812  result = false;
813  tbOops.setText(INCOMPLETE_SETTINGS_MSG);
814  }
815  return result;
816  }
817 
823  boolean databaseSettingsAreValid() {
824  if (portNumberIsValid(tbDbPort.getText().trim())) {
825  return true;
826  } else {
827  tbOops.setText(INVALID_DB_PORT_MSG);
828  return false;
829  }
830  }
831 
837  boolean messageServiceSettingsAreValid() {
838  if (!portNumberIsValid(tbMsgPort.getText().trim())) {
839  tbOops.setText(INVALID_MESSAGE_SERVICE_PORT_MSG);
840  return false;
841  }
842 
843  return true;
844  }
845 
851  boolean indexingServerSettingsAreValid() {
852  if (!portNumberIsValid(tbSolrPort.getText().trim())) {
853  tbOops.setText(INVALID_INDEXING_SERVER_PORT_MSG);
854  return false;
855  }
856 
857  return true;
858  }
859 
868  private static boolean portNumberIsValid(String portNumber) {
869  try {
870  int value = Integer.parseInt(portNumber);
871  if (value < 0 || value > 65535) { // invalid port numbers
872  return false;
873  }
874  } catch (NumberFormatException detailsNotImportant) {
875  return false;
876  }
877  return true;
878  }
879 
880  // Variables declaration - do not modify//GEN-BEGIN:variables
881  private javax.swing.JButton bnTestDatabase;
882  private javax.swing.JButton bnTestMessageService;
883  private javax.swing.JButton bnTestSolr;
884  private javax.swing.JCheckBox cbEnableMultiUser;
885  private javax.swing.JScrollPane jScrollPane;
886  private javax.swing.JLabel lbDatabaseSettings;
887  private javax.swing.JLabel lbMessageServiceSettings;
888  private javax.swing.JLabel lbSolrSettings;
889  private javax.swing.JLabel lbTestDatabase;
890  private javax.swing.JLabel lbTestDbWarning;
891  private javax.swing.JLabel lbTestMessageService;
892  private javax.swing.JLabel lbTestMessageWarning;
893  private javax.swing.JLabel lbTestSolr;
894  private javax.swing.JLabel lbTestSolrWarning;
895  private javax.swing.JPanel pnDatabaseSettings;
896  private javax.swing.JPanel pnMessagingSettings;
897  private javax.swing.JPanel pnOverallPanel;
898  private javax.swing.JPanel pnSolrSettings;
899  private javax.swing.JTextField tbDbHostname;
900  private javax.swing.JPasswordField tbDbPassword;
901  private javax.swing.JTextField tbDbPort;
902  private javax.swing.JTextField tbDbUsername;
903  private javax.swing.JTextField tbMsgHostname;
904  private javax.swing.JPasswordField tbMsgPassword;
905  private javax.swing.JTextField tbMsgPort;
906  private javax.swing.JTextField tbMsgUsername;
907  private javax.swing.JTextField tbOops;
908  private javax.swing.JTextField tbSolrHostname;
909  private javax.swing.JTextField tbSolrPort;
910  // End of variables declaration//GEN-END:variables
911 
916  class TextBoxChangedListener implements DocumentListener {
917 
918  @Override
919  public void changedUpdate(DocumentEvent e) {
920  Object statusIcon = e.getDocument().getProperty("statusIcon");
921  if (statusIcon != null) {
922  ((javax.swing.JLabel) statusIcon).setIcon(null);
923  }
924  controller.changed();
925  }
926 
927  @Override
928  public void insertUpdate(DocumentEvent e) {
929  Object statusIcon = e.getDocument().getProperty("statusIcon");
930  if (statusIcon != null) {
931  ((javax.swing.JLabel) statusIcon).setIcon(null);
932  }
933  controller.changed();
934  }
935 
936  @Override
937  public void removeUpdate(DocumentEvent e) {
938  Object statusIcon = e.getDocument().getProperty("statusIcon");
939  if (statusIcon != null) {
940  ((javax.swing.JLabel) statusIcon).setIcon(null);
941  }
942  controller.changed();
943  }
944  }
945 }
static void configureTextPrompts(Collection< TextPrompt > textPrompts)
static boolean areCaseDbConnectionEqual(CaseDbConnectionInfo a, CaseDbConnectionInfo b)
static CaseDbConnectionInfo getDatabaseConnectionInfo()
MultiUserSettingsPanel(MultiUserSettingsPanelController theController)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static void enableMultiUserComponents(Collection< JTextField > textFields, boolean enabled)
void bnTestMessageServiceActionPerformed(java.awt.event.ActionEvent evt)
static void addDocumentListeners(Collection< JTextField > textFields, TextBoxChangedListener listener)

Copyright © 2012-2020 Basis Technology. Generated on: Tue Sep 22 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.