Autopsy  4.7.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;
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;
43 import org.sleuthkit.datamodel.SleuthkitCase;
44 import org.sleuthkit.datamodel.TskCoreException;
45 
49 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
50 public final class MultiUserSettingsPanel extends javax.swing.JPanel {
51 
52  private static final String HOST_NAME_OR_IP_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbHostname.toolTipText");
53  private static final String PORT_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPort.toolTipText");
54  private static final String USER_NAME_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbUsername.toolTipText");
55  private static final String PASSWORD_PROMPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPassword.toolTipText");
56  private static final String USER_NAME_PROMPT_OPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgUsername.toolTipText");
57  private static final String PASSWORD_PROMPT_OPT = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgPassword.toolTipText");
58  private static final String INCOMPLETE_SETTINGS_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.incomplete");
59  private static final String INVALID_DB_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidDatabasePort");
60  private static final String INVALID_MESSAGE_SERVICE_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidMessageServicePort");
61  private static final String INVALID_INDEXING_SERVER_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidIndexingServerPort");
62  private static final long serialVersionUID = 1L;
64  private final Collection<JTextField> textBoxes = new ArrayList<>();
65  private final TextBoxChangedListener textBoxChangedListener;
66  private static final Logger logger = Logger.getLogger(MultiUserSettingsPanel.class.getName());
67  private final ImageIcon goodIcon;
68  private final ImageIcon badIcon;
69  private static final boolean isWindowsOS = PlatformUtil.isWindowsOS();
70 
77  initComponents();
78  controller = theController;
79  setSize(555, 600);
80 
84  Collection<TextPrompt> textPrompts = new ArrayList<>();
85  textPrompts.add(new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbDbHostname));
86  textPrompts.add(new TextPrompt(PORT_PROMPT, tbDbPort));
87  textPrompts.add(new TextPrompt(USER_NAME_PROMPT, tbDbUsername));
88  textPrompts.add(new TextPrompt(PASSWORD_PROMPT, tbDbPassword));
89  textPrompts.add(new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbMsgHostname));
90  textPrompts.add(new TextPrompt(PORT_PROMPT, tbMsgPort));
91  textPrompts.add(new TextPrompt(USER_NAME_PROMPT_OPT, tbMsgUsername));
92  textPrompts.add(new TextPrompt(PASSWORD_PROMPT_OPT, tbMsgPassword));
93  textPrompts.add(new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbSolrHostname));
94  textPrompts.add(new TextPrompt(PORT_PROMPT, tbSolrPort));
95  configureTextPrompts(textPrompts);
96 
97  /*
98  * Set each textbox with a "statusIcon" property enabling the
99  * DocumentListeners to know which icon to erase when changes are made
100  */
101  tbDbHostname.getDocument().putProperty("statusIcon", lbTestDatabase);
102  tbDbPort.getDocument().putProperty("statusIcon", lbTestDatabase);
103  tbDbUsername.getDocument().putProperty("statusIcon", lbTestDatabase);
104  tbDbPassword.getDocument().putProperty("statusIcon", lbTestDatabase);
105 
106  tbSolrHostname.getDocument().putProperty("statusIcon", lbTestSolr);
107  tbSolrPort.getDocument().putProperty("statusIcon", lbTestSolr);
108 
109  tbMsgHostname.getDocument().putProperty("statusIcon", lbTestMessageService);
110  tbMsgPort.getDocument().putProperty("statusIcon", lbTestMessageService);
111  tbMsgUsername.getDocument().putProperty("statusIcon", lbTestMessageService);
112  tbMsgPassword.getDocument().putProperty("statusIcon", lbTestMessageService);
113 
115  textBoxChangedListener = new TextBoxChangedListener();
116  textBoxes.add(tbDbHostname);
117  textBoxes.add(tbDbPort);
118  textBoxes.add(tbDbUsername);
119  textBoxes.add(tbDbPassword);
120  textBoxes.add(tbMsgHostname);
121  textBoxes.add(tbMsgPort);
122  textBoxes.add(tbMsgUsername);
123  textBoxes.add(tbMsgPassword);
124  textBoxes.add(tbSolrHostname);
125  textBoxes.add(tbSolrPort);
126 
127  addDocumentListeners(textBoxes, textBoxChangedListener);
128  goodIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/good.png", false));
129  badIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/bad.png", false));
130  enableMultiUserComponents(textBoxes, cbEnableMultiUser.isSelected());
131  }
132 
139  private static void configureTextPrompts(Collection<TextPrompt> textPrompts) {
140  float alpha = 0.9f; // Mostly opaque
141  for (TextPrompt textPrompt : textPrompts) {
142  textPrompt.setForeground(Color.LIGHT_GRAY);
143  textPrompt.changeAlpha(alpha);
144  }
145  }
146 
153  private static void addDocumentListeners(Collection<JTextField> textFields, TextBoxChangedListener listener) {
154  for (JTextField textField : textFields) {
155  textField.getDocument().addDocumentListener(listener);
156  }
157  }
158 
164  @SuppressWarnings("unchecked")
165  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
166  private void initComponents() {
167 
168  jScrollPane = new javax.swing.JScrollPane();
169  pnOverallPanel = new javax.swing.JPanel();
170  pnDatabaseSettings = new javax.swing.JPanel();
171  tbDbHostname = new javax.swing.JTextField();
172  tbDbPort = new javax.swing.JTextField();
173  tbDbUsername = new javax.swing.JTextField();
174  tbDbPassword = new javax.swing.JPasswordField();
175  lbDatabaseSettings = new javax.swing.JLabel();
176  bnTestDatabase = new javax.swing.JButton();
177  lbTestDatabase = new javax.swing.JLabel();
178  lbTestDbWarning = new javax.swing.JLabel();
179  pnSolrSettings = new javax.swing.JPanel();
180  lbSolrSettings = new javax.swing.JLabel();
181  tbSolrHostname = new javax.swing.JTextField();
182  tbSolrPort = new javax.swing.JTextField();
183  bnTestSolr = new javax.swing.JButton();
184  lbTestSolr = new javax.swing.JLabel();
185  lbTestSolrWarning = new javax.swing.JLabel();
186  pnMessagingSettings = new javax.swing.JPanel();
187  lbMessageServiceSettings = new javax.swing.JLabel();
188  tbMsgHostname = new javax.swing.JTextField();
189  tbMsgUsername = new javax.swing.JTextField();
190  tbMsgPort = new javax.swing.JTextField();
191  tbMsgPassword = new javax.swing.JPasswordField();
192  bnTestMessageService = new javax.swing.JButton();
193  lbTestMessageService = new javax.swing.JLabel();
194  lbTestMessageWarning = new javax.swing.JLabel();
195  cbEnableMultiUser = new javax.swing.JCheckBox();
196  tbOops = new javax.swing.JTextField();
197 
198  pnDatabaseSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
199 
200  tbDbHostname.setFont(tbDbHostname.getFont().deriveFont(tbDbHostname.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
201  tbDbHostname.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbHostname.text")); // NOI18N
202  tbDbHostname.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbHostname.toolTipText")); // NOI18N
203 
204  tbDbPort.setFont(tbDbPort.getFont().deriveFont(tbDbPort.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
205  tbDbPort.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPort.text")); // NOI18N
206  tbDbPort.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPort.toolTipText")); // NOI18N
207 
208  tbDbUsername.setFont(tbDbUsername.getFont().deriveFont(tbDbUsername.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
209  tbDbUsername.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbUsername.text")); // NOI18N
210  tbDbUsername.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbUsername.toolTipText")); // NOI18N
211 
212  tbDbPassword.setFont(tbDbPassword.getFont().deriveFont(tbDbPassword.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
213  tbDbPassword.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPassword.text")); // NOI18N
214  tbDbPassword.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbDbPassword.toolTipText")); // NOI18N
215 
216  lbDatabaseSettings.setFont(lbDatabaseSettings.getFont().deriveFont(lbDatabaseSettings.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
217  org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseSettings, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbDatabaseSettings.text")); // NOI18N
218  lbDatabaseSettings.setVerticalAlignment(javax.swing.SwingConstants.TOP);
219 
220  bnTestDatabase.setFont(bnTestDatabase.getFont().deriveFont(bnTestDatabase.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
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().getStyle() & ~java.awt.Font.BOLD, 12));
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().getStyle() & ~java.awt.Font.BOLD, 12));
283  tbSolrHostname.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbSolrHostname.toolTipText")); // NOI18N
284 
285  tbSolrPort.setFont(tbSolrPort.getFont().deriveFont(tbSolrPort.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
286  tbSolrPort.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbSolrPort.toolTipText")); // NOI18N
287 
288  bnTestSolr.setFont(bnTestSolr.getFont().deriveFont(bnTestSolr.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
289  org.openide.awt.Mnemonics.setLocalizedText(bnTestSolr, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.bnTestSolr.text")); // NOI18N
290  bnTestSolr.addActionListener(new java.awt.event.ActionListener() {
291  public void actionPerformed(java.awt.event.ActionEvent evt) {
292  bnTestSolrActionPerformed(evt);
293  }
294  });
295 
296  org.openide.awt.Mnemonics.setLocalizedText(lbTestSolr, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestSolr.text")); // NOI18N
297 
298  lbTestSolrWarning.setForeground(new java.awt.Color(255, 0, 0));
299  org.openide.awt.Mnemonics.setLocalizedText(lbTestSolrWarning, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestSolrWarning.text")); // NOI18N
300 
301  javax.swing.GroupLayout pnSolrSettingsLayout = new javax.swing.GroupLayout(pnSolrSettings);
302  pnSolrSettings.setLayout(pnSolrSettingsLayout);
303  pnSolrSettingsLayout.setHorizontalGroup(
304  pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
305  .addGroup(pnSolrSettingsLayout.createSequentialGroup()
306  .addContainerGap()
307  .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
308  .addComponent(tbSolrHostname)
309  .addGroup(pnSolrSettingsLayout.createSequentialGroup()
310  .addComponent(lbSolrSettings)
311  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
312  .addComponent(bnTestSolr)
313  .addGap(18, 18, 18)
314  .addComponent(lbTestSolr, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
315  .addComponent(tbSolrPort)
316  .addGroup(pnSolrSettingsLayout.createSequentialGroup()
317  .addComponent(lbTestSolrWarning)
318  .addGap(0, 0, Short.MAX_VALUE)))
319  .addContainerGap())
320  );
321  pnSolrSettingsLayout.setVerticalGroup(
322  pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
323  .addGroup(pnSolrSettingsLayout.createSequentialGroup()
324  .addContainerGap()
325  .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
326  .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
327  .addComponent(bnTestSolr, javax.swing.GroupLayout.Alignment.TRAILING)
328  .addComponent(lbSolrSettings))
329  .addComponent(lbTestSolr, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
330  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
331  .addComponent(tbSolrHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
332  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
333  .addComponent(tbSolrPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
334  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
335  .addComponent(lbTestSolrWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
336  .addContainerGap())
337  );
338 
339  pnMessagingSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
340 
341  lbMessageServiceSettings.setFont(lbMessageServiceSettings.getFont().deriveFont(lbMessageServiceSettings.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
342  org.openide.awt.Mnemonics.setLocalizedText(lbMessageServiceSettings, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbMessageServiceSettings.text")); // NOI18N
343 
344  tbMsgHostname.setFont(tbMsgHostname.getFont().deriveFont(tbMsgHostname.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
345  tbMsgHostname.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgHostname.text")); // NOI18N
346  tbMsgHostname.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgHostname.toolTipText")); // NOI18N
347 
348  tbMsgUsername.setFont(tbMsgUsername.getFont().deriveFont(tbMsgUsername.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
349  tbMsgUsername.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgUsername.text")); // NOI18N
350  tbMsgUsername.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgUsername.toolTipText")); // NOI18N
351 
352  tbMsgPort.setFont(tbMsgPort.getFont().deriveFont(tbMsgPort.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
353  tbMsgPort.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgPort.text")); // NOI18N
354  tbMsgPort.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgPort.toolTipText")); // NOI18N
355 
356  tbMsgPassword.setFont(tbMsgPassword.getFont().deriveFont(tbMsgPassword.getFont().getStyle() & ~java.awt.Font.BOLD, 12));
357  tbMsgPassword.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgPassword.text")); // NOI18N
358  tbMsgPassword.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbMsgPassword.toolTipText")); // NOI18N
359 
360  bnTestMessageService.setFont(bnTestMessageService.getFont().deriveFont(bnTestMessageService.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
361  org.openide.awt.Mnemonics.setLocalizedText(bnTestMessageService, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.bnTestMessageService.text")); // NOI18N
362  bnTestMessageService.addActionListener(new java.awt.event.ActionListener() {
363  public void actionPerformed(java.awt.event.ActionEvent evt) {
364  bnTestMessageServiceActionPerformed(evt);
365  }
366  });
367 
368  org.openide.awt.Mnemonics.setLocalizedText(lbTestMessageService, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestMessageService.text")); // NOI18N
369 
370  lbTestMessageWarning.setForeground(new java.awt.Color(255, 0, 0));
371  org.openide.awt.Mnemonics.setLocalizedText(lbTestMessageWarning, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbTestMessageWarning.text")); // NOI18N
372 
373  javax.swing.GroupLayout pnMessagingSettingsLayout = new javax.swing.GroupLayout(pnMessagingSettings);
374  pnMessagingSettings.setLayout(pnMessagingSettingsLayout);
375  pnMessagingSettingsLayout.setHorizontalGroup(
376  pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
377  .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
378  .addContainerGap()
379  .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
380  .addComponent(tbMsgHostname)
381  .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
382  .addComponent(lbMessageServiceSettings)
383  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 229, Short.MAX_VALUE)
384  .addComponent(bnTestMessageService)
385  .addGap(18, 18, 18)
386  .addComponent(lbTestMessageService, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
387  .addComponent(tbMsgPort)
388  .addComponent(tbMsgUsername)
389  .addComponent(tbMsgPassword)
390  .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
391  .addComponent(lbTestMessageWarning)
392  .addGap(0, 0, Short.MAX_VALUE)))
393  .addContainerGap())
394  );
395  pnMessagingSettingsLayout.setVerticalGroup(
396  pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
397  .addGroup(pnMessagingSettingsLayout.createSequentialGroup()
398  .addContainerGap()
399  .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
400  .addGroup(pnMessagingSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
401  .addComponent(bnTestMessageService, javax.swing.GroupLayout.Alignment.TRAILING)
402  .addComponent(lbMessageServiceSettings))
403  .addComponent(lbTestMessageService, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
404  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
405  .addComponent(tbMsgHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
406  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
407  .addComponent(tbMsgPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
408  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
409  .addComponent(tbMsgUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
410  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
411  .addComponent(tbMsgPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
412  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
413  .addComponent(lbTestMessageWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
414  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
415  );
416 
417  cbEnableMultiUser.setFont(cbEnableMultiUser.getFont().deriveFont(cbEnableMultiUser.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
418  org.openide.awt.Mnemonics.setLocalizedText(cbEnableMultiUser, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.cbEnableMultiUser.text")); // NOI18N
419  cbEnableMultiUser.addItemListener(new java.awt.event.ItemListener() {
420  public void itemStateChanged(java.awt.event.ItemEvent evt) {
421  cbEnableMultiUserItemStateChanged(evt);
422  }
423  });
424 
425  tbOops.setEditable(false);
426  tbOops.setFont(tbOops.getFont().deriveFont(tbOops.getFont().getStyle() | java.awt.Font.BOLD, 12));
427  tbOops.setForeground(new java.awt.Color(255, 0, 0));
428  tbOops.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbOops.text")); // NOI18N
429  tbOops.setBorder(null);
430 
431  javax.swing.GroupLayout pnOverallPanelLayout = new javax.swing.GroupLayout(pnOverallPanel);
432  pnOverallPanel.setLayout(pnOverallPanelLayout);
433  pnOverallPanelLayout.setHorizontalGroup(
434  pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
435  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnOverallPanelLayout.createSequentialGroup()
436  .addContainerGap()
437  .addGroup(pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
438  .addGroup(pnOverallPanelLayout.createSequentialGroup()
439  .addComponent(cbEnableMultiUser)
440  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
441  .addComponent(tbOops))
442  .addComponent(pnSolrSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
443  .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
444  .addComponent(pnMessagingSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
445  .addContainerGap())
446  );
447  pnOverallPanelLayout.setVerticalGroup(
448  pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
449  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnOverallPanelLayout.createSequentialGroup()
450  .addGroup(pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
451  .addComponent(tbOops, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
452  .addComponent(cbEnableMultiUser))
453  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
454  .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
455  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
456  .addComponent(pnSolrSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
457  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
458  .addComponent(pnMessagingSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
459  .addContainerGap(39, Short.MAX_VALUE))
460  );
461 
462  jScrollPane.setViewportView(pnOverallPanel);
463 
464  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
465  this.setLayout(layout);
466  layout.setHorizontalGroup(
467  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
468  .addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE)
469  );
470  layout.setVerticalGroup(
471  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
472  .addGroup(layout.createSequentialGroup()
473  .addContainerGap()
474  .addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE)
475  .addContainerGap())
476  );
477  }// </editor-fold>//GEN-END:initComponents
478 
485  private static void enableMultiUserComponents(Collection<JTextField> textFields, boolean enabled) {
486  for (JTextField textField : textFields) {
487  textField.setEnabled(enabled);
488  }
489  }
490 
491  private void cbEnableMultiUserItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbEnableMultiUserItemStateChanged
492  if (!cbEnableMultiUser.isSelected()) {
493  tbOops.setText("");
494  bnTestDatabase.setEnabled(false);
495  lbTestDatabase.setIcon(null);
496  bnTestSolr.setEnabled(false);
497  lbTestSolr.setIcon(null);
498  bnTestMessageService.setEnabled(false);
499  lbTestMessageService.setIcon(null);
500  lbTestDbWarning.setText("");
501  lbTestSolrWarning.setText("");
502  lbTestMessageWarning.setText("");
503  }
504  enableMultiUserComponents(textBoxes, cbEnableMultiUser.isSelected());
505  controller.changed();
506  }//GEN-LAST:event_cbEnableMultiUserItemStateChanged
507 
508  private void bnTestDatabaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnTestDatabaseActionPerformed
509  lbTestDatabase.setIcon(null);
510  lbTestDbWarning.setText("");
511  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
512  try {
513  CaseDbConnectionInfo info = new CaseDbConnectionInfo(
514  this.tbDbHostname.getText().trim(),
515  this.tbDbPort.getText().trim(),
516  this.tbDbUsername.getText().trim(),
517  new String(this.tbDbPassword.getPassword()),
518  DbType.POSTGRESQL);
519 
520  SleuthkitCase.tryConnect(info);
521  lbTestDatabase.setIcon(goodIcon);
522  lbTestDbWarning.setText("");
523  } catch (TskCoreException ex) {
524  lbTestDatabase.setIcon(badIcon);
525  lbTestDbWarning.setText(ex.getMessage());
526  } finally {
527  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
528  }
529  }//GEN-LAST:event_bnTestDatabaseActionPerformed
530 
531  private void bnTestMessageServiceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnTestMessageServiceActionPerformed
532  lbTestMessageService.setIcon(null);
533  lbTestMessageWarning.setText("");
534  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
535 
536  int port;
537  try {
538  port = Integer.parseInt(this.tbMsgPort.getText().trim());
539  } catch (NumberFormatException ex) {
540  lbTestMessageService.setIcon(badIcon);
541  lbTestMessageWarning.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.InvalidPortNumber"));
542  return;
543  }
544 
546  this.tbMsgHostname.getText().trim(),
547  port,
548  this.tbMsgUsername.getText().trim(),
549  new String(this.tbMsgPassword.getPassword()));
550  try {
551  info.tryConnect();
552  lbTestMessageService.setIcon(goodIcon);
553  lbTestMessageWarning.setText("");
554  } catch (MessageServiceException ex) {
555  lbTestMessageService.setIcon(badIcon);
556  lbTestMessageWarning.setText(ex.getMessage());
557  } finally {
558  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
559  }
560  }//GEN-LAST:event_bnTestMessageServiceActionPerformed
561 
562  private void bnTestSolrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnTestSolrActionPerformed
563  lbTestSolr.setIcon(null);
564  lbTestSolrWarning.setText("");
565  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
566 
567  KeywordSearchService kwsService = Lookup.getDefault().lookup(KeywordSearchService.class);
568  try {
569  if (kwsService != null) {
570  int port = Integer.parseInt(tbSolrPort.getText().trim());
571  kwsService.tryConnect(tbSolrHostname.getText().trim(), port);
572  lbTestSolr.setIcon(goodIcon);
573  lbTestSolrWarning.setText("");
574  } else {
575  lbTestSolr.setIcon(badIcon);
576  lbTestSolrWarning.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.KeywordSearchNull"));
577  }
578  } catch (NumberFormatException ex) {
579  lbTestSolr.setIcon(badIcon);
580  lbTestSolrWarning.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.InvalidPortNumber"));
581  } catch (KeywordSearchServiceException ex) {
582  lbTestSolr.setIcon(badIcon);
583  lbTestSolrWarning.setText(ex.getMessage());
584  } finally {
585  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
586  }
587  }//GEN-LAST:event_bnTestSolrActionPerformed
588 
589  void load() {
590  lbTestDatabase.setIcon(null);
591  lbTestSolr.setIcon(null);
592  lbTestMessageService.setIcon(null);
593  lbTestDbWarning.setText("");
594  lbTestSolrWarning.setText("");
595  lbTestMessageWarning.setText("");
596 
597  try {
598  CaseDbConnectionInfo dbInfo = UserPreferences.getDatabaseConnectionInfo();
599  tbDbHostname.setText(dbInfo.getHost().trim());
600  tbDbPort.setText(dbInfo.getPort().trim());
601  tbDbUsername.setText(dbInfo.getUserName().trim());
602  tbDbPassword.setText(dbInfo.getPassword());
603  } catch (UserPreferencesException ex) {
604  logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
605  }
606 
607  try {
608  MessageServiceConnectionInfo msgServiceInfo = UserPreferences.getMessageServiceConnectionInfo();
609  tbMsgHostname.setText(msgServiceInfo.getHost().trim());
610  tbMsgPort.setText(Integer.toString(msgServiceInfo.getPort()));
611  tbMsgUsername.setText(msgServiceInfo.getUserName().trim());
612  tbMsgPassword.setText(msgServiceInfo.getPassword());
613  } catch (UserPreferencesException ex) {
614  logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
615  }
616 
617  String indexingServerHost = UserPreferences.getIndexingServerHost().trim();
618  if (!indexingServerHost.isEmpty()) {
619  tbSolrHostname.setText(indexingServerHost);
620  }
621  String indexingServerPort = UserPreferences.getIndexingServerPort().trim();
622  if (portNumberIsValid(indexingServerPort)) {
623  tbSolrPort.setText(indexingServerPort);
624  }
625 
626  lbTestDatabase.setIcon(null);
627  lbTestSolr.setIcon(null);
628  lbTestMessageService.setIcon(null);
629 
630  bnTestDatabase.setEnabled(false);
631  bnTestSolr.setEnabled(false);
632  bnTestMessageService.setEnabled(false);
633 
634  cbEnableMultiUser.setSelected(UserPreferences.getIsMultiUserModeEnabled());
635  this.valid(); // trigger validation to enable buttons based on current settings
636  }
637 
644  private boolean databaseFieldsArePopulated() {
645  return !tbDbHostname.getText().trim().isEmpty()
646  && !tbDbPort.getText().trim().isEmpty()
647  && !tbDbUsername.getText().trim().isEmpty()
648  && tbDbPassword.getPassword().length != 0;
649  }
650 
657  private boolean solrFieldsArePopulated() {
658  return !tbSolrHostname.getText().trim().isEmpty()
659  && !tbSolrPort.getText().trim().isEmpty();
660  }
661 
669 
670  if ((tbMsgHostname.getText().trim().isEmpty())
671  || (tbMsgPort.getText().trim().isEmpty())) {
672  return false;
673  }
674 
675  // user name and pw are optional, but make sure they are both set or both empty
676  boolean isUserSet = (tbMsgUsername.getText().trim().isEmpty() == false);
677  boolean isPwSet = (tbMsgPassword.getPassword().length != 0);
678  return (isUserSet == isPwSet);
679  }
680 
681  void store() {
682 
683  boolean multiUserCasesEnabled = cbEnableMultiUser.isSelected();
684  UserPreferences.setIsMultiUserModeEnabled(multiUserCasesEnabled);
685  if (multiUserCasesEnabled == false) {
686  return;
687  }
688 
689  /*
690  * Currently only supporting multi-user cases with PostgreSQL case
691  * databases.
692  */
693  DbType dbType = DbType.POSTGRESQL;
694  CaseDbConnectionInfo info = new CaseDbConnectionInfo(
695  tbDbHostname.getText().trim(),
696  tbDbPort.getText().trim(),
697  tbDbUsername.getText().trim(),
698  new String(tbDbPassword.getPassword()),
699  dbType);
700  try {
701  UserPreferences.setDatabaseConnectionInfo(info);
702  } catch (UserPreferencesException ex) {
703  logger.log(Level.SEVERE, "Error saving case database connection info", ex); //NON-NLS
704  }
705 
706  int msgServicePort = 0;
707  try {
708  msgServicePort = Integer.parseInt(this.tbMsgPort.getText().trim());
709  } catch (NumberFormatException ex) {
710  logger.log(Level.SEVERE, "Could not parse messaging service port setting", ex);
711  }
712 
713  MessageServiceConnectionInfo msgServiceInfo = new MessageServiceConnectionInfo(
714  tbMsgHostname.getText().trim(),
715  msgServicePort,
716  tbMsgUsername.getText().trim(),
717  new String(tbMsgPassword.getPassword()));
718 
719  try {
720  UserPreferences.setMessageServiceConnectionInfo(msgServiceInfo);
721  } catch (UserPreferencesException ex) {
722  logger.log(Level.SEVERE, "Error saving messaging service connection info", ex); //NON-NLS
723  }
724 
725  UserPreferences.setIndexingServerHost(tbSolrHostname.getText().trim());
726  UserPreferences.setIndexingServerPort(Integer.parseInt(tbSolrPort.getText().trim()));
727 
728  }
729 
735  boolean valid() {
736  tbOops.setText("");
737 
738  if (cbEnableMultiUser.isSelected()) {
739  return checkFieldsAndEnableButtons()
740  && databaseSettingsAreValid()
741  && indexingServerSettingsAreValid()
742  && messageServiceSettingsAreValid();
743  } else {
744  return true;
745  }
746  }
747 
754  boolean checkFieldsAndEnableButtons() {
755  boolean result = true;
756 
757  boolean dbPopulated = databaseFieldsArePopulated();
758  boolean solrPopulated = solrFieldsArePopulated();
759  boolean messageServicePopulated = messageServiceFieldsArePopulated();
760 
761  // PostgreSQL Database
762  bnTestDatabase.setEnabled(dbPopulated);
763 
764  // Solr Indexing
765  bnTestSolr.setEnabled(solrPopulated);
766 
767  // ActiveMQ Messaging
768  bnTestMessageService.setEnabled(messageServicePopulated);
769 
770  if (!dbPopulated || !solrPopulated || !messageServicePopulated) {
771  // We don't even have everything filled out
772  result = false;
773  tbOops.setText(INCOMPLETE_SETTINGS_MSG);
774  }
775  return result;
776  }
777 
783  boolean databaseSettingsAreValid() {
784  if (portNumberIsValid(tbDbPort.getText().trim())) {
785  return true;
786  } else {
787  tbOops.setText(INVALID_DB_PORT_MSG);
788  return false;
789  }
790  }
791 
797  boolean messageServiceSettingsAreValid() {
798  if (!portNumberIsValid(tbMsgPort.getText().trim())) {
799  tbOops.setText(INVALID_MESSAGE_SERVICE_PORT_MSG);
800  return false;
801  }
802 
803  return true;
804  }
805 
811  boolean indexingServerSettingsAreValid() {
812  if (!portNumberIsValid(tbSolrPort.getText().trim())) {
813  tbOops.setText(INVALID_INDEXING_SERVER_PORT_MSG);
814  return false;
815  }
816 
817  return true;
818  }
819 
828  private static boolean portNumberIsValid(String portNumber) {
829  try {
830  int value = Integer.parseInt(portNumber);
831  if (value < 0 || value > 65535) { // invalid port numbers
832  return false;
833  }
834  } catch (NumberFormatException detailsNotImportant) {
835  return false;
836  }
837  return true;
838  }
839 
840  // Variables declaration - do not modify//GEN-BEGIN:variables
841  private javax.swing.JButton bnTestDatabase;
842  private javax.swing.JButton bnTestMessageService;
843  private javax.swing.JButton bnTestSolr;
844  private javax.swing.JCheckBox cbEnableMultiUser;
845  private javax.swing.JScrollPane jScrollPane;
846  private javax.swing.JLabel lbDatabaseSettings;
847  private javax.swing.JLabel lbMessageServiceSettings;
848  private javax.swing.JLabel lbSolrSettings;
849  private javax.swing.JLabel lbTestDatabase;
850  private javax.swing.JLabel lbTestDbWarning;
851  private javax.swing.JLabel lbTestMessageService;
852  private javax.swing.JLabel lbTestMessageWarning;
853  private javax.swing.JLabel lbTestSolr;
854  private javax.swing.JLabel lbTestSolrWarning;
855  private javax.swing.JPanel pnDatabaseSettings;
856  private javax.swing.JPanel pnMessagingSettings;
857  private javax.swing.JPanel pnOverallPanel;
858  private javax.swing.JPanel pnSolrSettings;
859  private javax.swing.JTextField tbDbHostname;
860  private javax.swing.JPasswordField tbDbPassword;
861  private javax.swing.JTextField tbDbPort;
862  private javax.swing.JTextField tbDbUsername;
863  private javax.swing.JTextField tbMsgHostname;
864  private javax.swing.JPasswordField tbMsgPassword;
865  private javax.swing.JTextField tbMsgPort;
866  private javax.swing.JTextField tbMsgUsername;
867  private javax.swing.JTextField tbOops;
868  private javax.swing.JTextField tbSolrHostname;
869  private javax.swing.JTextField tbSolrPort;
870  // End of variables declaration//GEN-END:variables
871 
876  class TextBoxChangedListener implements DocumentListener {
877 
878  @Override
879  public void changedUpdate(DocumentEvent e) {
880  Object statusIcon = e.getDocument().getProperty("statusIcon");
881  if (statusIcon != null) {
882  ((javax.swing.JLabel) statusIcon).setIcon(null);
883  }
884  controller.changed();
885  }
886 
887  @Override
888  public void insertUpdate(DocumentEvent e) {
889  Object statusIcon = e.getDocument().getProperty("statusIcon");
890  if (statusIcon != null) {
891  ((javax.swing.JLabel) statusIcon).setIcon(null);
892  }
893  controller.changed();
894  }
895 
896  @Override
897  public void removeUpdate(DocumentEvent e) {
898  Object statusIcon = e.getDocument().getProperty("statusIcon");
899  if (statusIcon != null) {
900  ((javax.swing.JLabel) statusIcon).setIcon(null);
901  }
902  controller.changed();
903  }
904  }
905 }
static void configureTextPrompts(Collection< TextPrompt > textPrompts)
static CaseDbConnectionInfo getDatabaseConnectionInfo()
MultiUserSettingsPanel(MultiUserSettingsPanelController theController)
static void setIsMultiUserModeEnabled(boolean enabled)
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-2016 Basis Technology. Generated on: Mon Jun 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.