19 package com.basistech.df.cybertriage.autopsy.ctoptions.ctcloud;
32 import java.awt.event.ComponentAdapter;
33 import java.awt.event.ComponentEvent;
34 import java.io.IOException;
36 import java.net.URISyntaxException;
37 import java.time.ZoneId;
38 import java.time.format.DateTimeFormatter;
39 import java.util.Optional;
40 import java.util.concurrent.CancellationException;
41 import java.util.concurrent.ExecutionException;
42 import java.util.logging.Level;
43 import javax.swing.SwingUtilities;
44 import javax.swing.SwingWorker;
45 import org.apache.commons.lang3.StringUtils;
46 import org.netbeans.spi.options.OptionsPanelController;
47 import org.openide.util.NbBundle;
48 import org.openide.util.NbBundle.Messages;
49 import org.openide.util.lookup.ServiceProvider;
50 import org.openide.windows.WindowManager;
58 @ServiceProvider(service = CTOptionsSubPanel.class)
63 private static final DateTimeFormatter LICENSE_EXPIRES_FORMAT = DateTimeFormatter
64 .ofPattern(
"MMMM d, YYYY")
67 private static final DateTimeFormatter MALWARE_SCANS_RESET_FORMAT = DateTimeFormatter
68 .ofPattern(
"MMM d, YYYY' at 'h:mma")
75 private volatile String licenseInfoMessage = null;
78 private static final String PURCHASE_URL =
"https://cybertriage.com/autopsy-malware-module";
81 private volatile String authTokenMessage = null;
83 private volatile String authTokenError = null;
91 this.addComponentListener(
new ComponentAdapter() {
93 public void componentHidden(ComponentEvent e) {
108 public void componentShown(ComponentEvent e) {
122 if (licenseResponse == null) {
136 Optional<LicenseInfo> licenseInfoOpt = ctPersistence.
loadLicenseInfo();
137 LicenseInfo licenseInfo = licenseInfoOpt.orElse(null);
138 setLicenseDisplay(licenseInfo, null);
139 setMalwareScansDisplay(null, null, null);
140 if (licenseInfo != null) {
141 loadMalwareScansInfo(licenseInfo);
142 this.purchaseFromLabel.setVisible(
false);
143 this.purchaseLink.setVisible(
false);
145 this.purchaseFromLabel.setVisible(
true);
146 this.purchaseLink.setVisible(
true);
151 return "<html><span style=\"color: blue; text-decoration: underline\">" + url +
"</span></html>";
158 }
catch (IOException | URISyntaxException e) {
159 logger.log(Level.SEVERE,
"Error opening link to: " + url, e);
162 logger.log(Level.WARNING,
"Desktop API is not supported. Link cannot be opened.");
171 this.licenseInfo = licenseInfo;
172 this.licenseInfoMessage = licenseMessage;
173 renderLicenseState();
177 this.authTokenResponse = authTokenResponse;
178 this.authTokenMessage = authTokenMessage;
179 this.authTokenError = authTokenError;
180 renderLicenseState();
187 return this.licenseFetcher != null && !this.licenseFetcher.isCancelled() && !this.licenseFetcher.isDone();
194 return this.authTokenFetcher != null && !this.authTokenFetcher.isCancelled() && !this.authTokenFetcher.isDone();
198 "CTOPtionsPanel_loadLicenseInfo_loading=Loading..."
201 if (isLicenseAddRunning()) {
202 this.licenseFetcher.cancel(
true);
204 setLicenseDisplay(null, Bundle.CTOPtionsPanel_loadLicenseInfo_loading());
205 setMalwareScansDisplay(null, null, null);
207 this.licenseFetcher.execute();
211 "CTOPtionsPanel_loadMalwareScansInfo_loading=Loading..."
214 if (isMalwareScansRunning()) {
215 this.authTokenFetcher.cancel(
true);
219 setMalwareScansDisplay(null, null, null);
223 setMalwareScansDisplay(null, Bundle.CTOPtionsPanel_loadMalwareScansInfo_loading(), null);
226 this.authTokenFetcher.execute();
232 :
"<html>" + msg +
"</html>";
240 @SuppressWarnings(
"unchecked")
242 private
void initComponents() {
243 java.awt.GridBagConstraints gridBagConstraints;
245 malwareScansPanel =
new javax.swing.JPanel();
246 javax.swing.JLabel disclaimer =
new javax.swing.JLabel();
247 javax.swing.JPanel licenseInfoPanel =
new javax.swing.JPanel();
248 licenseInfoMessageLabel =
new javax.swing.JLabel();
249 javax.swing.JPanel buttonSpacer =
new javax.swing.JPanel();
250 javax.swing.JPanel buttonPanel =
new javax.swing.JPanel();
251 licenseInfoAddButton =
new javax.swing.JButton();
252 licenseInfoRemoveButton =
new javax.swing.JButton();
253 licenseInfoExpiresLabel =
new javax.swing.JLabel();
254 licenseInfoIdLabel =
new javax.swing.JLabel();
255 licenseInfoUserLabel =
new javax.swing.JLabel();
256 malwareScansMessageLabel =
new javax.swing.JLabel();
257 maxHashLookupsLabel =
new javax.swing.JLabel();
258 hashLookupsRemainingLabel =
new javax.swing.JLabel();
259 maxFileUploadsLabel =
new javax.swing.JLabel();
260 fileUploadsRemainingLabel =
new javax.swing.JLabel();
261 countersResetLabel =
new javax.swing.JLabel();
262 licenseErrorLabel =
new javax.swing.JLabel();
263 javax.swing.JPanel purchasePanel =
new javax.swing.JPanel();
264 purchaseFromLabel =
new javax.swing.JLabel();
265 purchaseLink =
new javax.swing.JLabel();
267 setMaximumSize(
new java.awt.Dimension(650, 32767));
268 setLayout(
new java.awt.GridBagLayout());
270 malwareScansPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.malwareScansPanel.border.title")));
271 malwareScansPanel.setMaximumSize(
new java.awt.Dimension(650, 2147483647));
272 malwareScansPanel.setLayout(
new java.awt.GridBagLayout());
274 org.openide.awt.Mnemonics.setLocalizedText(disclaimer,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.text"));
275 disclaimer.setVerticalAlignment(javax.swing.SwingConstants.TOP);
276 disclaimer.setMaximumSize(
new java.awt.Dimension(650, 32));
277 disclaimer.setName(
"");
278 disclaimer.setPreferredSize(
new java.awt.Dimension(650, 32));
279 gridBagConstraints =
new java.awt.GridBagConstraints();
280 gridBagConstraints.gridx = 0;
281 gridBagConstraints.gridy = 0;
282 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
283 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
284 gridBagConstraints.weightx = 1.0;
285 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
286 malwareScansPanel.add(disclaimer, gridBagConstraints);
288 licenseInfoPanel.setLayout(
new java.awt.GridBagLayout());
290 org.openide.awt.Mnemonics.setLocalizedText(licenseInfoMessageLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.licenseInfoMessageLabel.text"));
291 gridBagConstraints =
new java.awt.GridBagConstraints();
292 gridBagConstraints.gridx = 0;
293 gridBagConstraints.gridy = 0;
294 gridBagConstraints.gridwidth = 3;
295 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
296 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
297 gridBagConstraints.weightx = 1.0;
298 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
299 licenseInfoPanel.add(licenseInfoMessageLabel, gridBagConstraints);
301 buttonSpacer.setMaximumSize(
new java.awt.Dimension(32767, 0));
302 buttonSpacer.setMinimumSize(
new java.awt.Dimension(5, 0));
303 buttonSpacer.setPreferredSize(
new java.awt.Dimension(5, 0));
304 gridBagConstraints =
new java.awt.GridBagConstraints();
305 gridBagConstraints.gridx = 0;
306 gridBagConstraints.gridy = 2;
307 gridBagConstraints.gridwidth = 2;
308 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
309 gridBagConstraints.weightx = 1.0;
310 licenseInfoPanel.add(buttonSpacer, gridBagConstraints);
312 buttonPanel.setLayout(
new java.awt.GridBagLayout());
314 org.openide.awt.Mnemonics.setLocalizedText(licenseInfoAddButton,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.licenseInfoAddButton.text"));
315 licenseInfoAddButton.addActionListener(
new java.awt.event.ActionListener() {
316 public void actionPerformed(java.awt.event.ActionEvent evt) {
317 licenseInfoAddButtonActionPerformed(evt);
320 gridBagConstraints =
new java.awt.GridBagConstraints();
321 gridBagConstraints.gridx = 0;
322 gridBagConstraints.gridy = 0;
323 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
324 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
325 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
326 buttonPanel.add(licenseInfoAddButton, gridBagConstraints);
328 org.openide.awt.Mnemonics.setLocalizedText(licenseInfoRemoveButton,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.licenseInfoRemoveButton.text"));
329 licenseInfoRemoveButton.addActionListener(
new java.awt.event.ActionListener() {
330 public void actionPerformed(java.awt.event.ActionEvent evt) {
331 licenseInfoRemoveButtonActionPerformed(evt);
334 gridBagConstraints =
new java.awt.GridBagConstraints();
335 gridBagConstraints.gridx = 0;
336 gridBagConstraints.gridy = 1;
337 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
338 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
339 gridBagConstraints.insets =
new java.awt.Insets(0, 5, 5, 5);
340 buttonPanel.add(licenseInfoRemoveButton, gridBagConstraints);
342 gridBagConstraints =
new java.awt.GridBagConstraints();
343 gridBagConstraints.gridx = 2;
344 gridBagConstraints.gridy = 2;
345 gridBagConstraints.gridheight = 7;
346 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
347 licenseInfoPanel.add(buttonPanel, gridBagConstraints);
349 org.openide.awt.Mnemonics.setLocalizedText(licenseInfoExpiresLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.licenseInfoExpiresLabel.text"));
350 gridBagConstraints =
new java.awt.GridBagConstraints();
351 gridBagConstraints.gridx = 0;
352 gridBagConstraints.gridy = 3;
353 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
354 gridBagConstraints.weightx = 1.0;
355 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
356 licenseInfoPanel.add(licenseInfoExpiresLabel, gridBagConstraints);
358 org.openide.awt.Mnemonics.setLocalizedText(licenseInfoIdLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.licenseInfoIdLabel.text"));
359 gridBagConstraints =
new java.awt.GridBagConstraints();
360 gridBagConstraints.gridx = 1;
361 gridBagConstraints.gridy = 3;
362 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
363 gridBagConstraints.weightx = 1.0;
364 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
365 licenseInfoPanel.add(licenseInfoIdLabel, gridBagConstraints);
367 org.openide.awt.Mnemonics.setLocalizedText(licenseInfoUserLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.licenseInfoUserLabel.text"));
368 gridBagConstraints =
new java.awt.GridBagConstraints();
369 gridBagConstraints.gridx = 0;
370 gridBagConstraints.gridy = 4;
371 gridBagConstraints.gridwidth = 2;
372 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
373 gridBagConstraints.weightx = 1.0;
374 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
375 licenseInfoPanel.add(licenseInfoUserLabel, gridBagConstraints);
377 org.openide.awt.Mnemonics.setLocalizedText(malwareScansMessageLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.malwareScansMessageLabel.text"));
378 gridBagConstraints =
new java.awt.GridBagConstraints();
379 gridBagConstraints.gridx = 0;
380 gridBagConstraints.gridy = 5;
381 gridBagConstraints.gridwidth = 2;
382 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
383 gridBagConstraints.weightx = 1.0;
384 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
385 licenseInfoPanel.add(malwareScansMessageLabel, gridBagConstraints);
387 org.openide.awt.Mnemonics.setLocalizedText(maxHashLookupsLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.maxHashLookupsLabel.text"));
388 gridBagConstraints =
new java.awt.GridBagConstraints();
389 gridBagConstraints.gridx = 0;
390 gridBagConstraints.gridy = 6;
391 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
392 gridBagConstraints.weightx = 1.0;
393 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
394 licenseInfoPanel.add(maxHashLookupsLabel, gridBagConstraints);
396 org.openide.awt.Mnemonics.setLocalizedText(hashLookupsRemainingLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.hashLookupsRemainingLabel.text"));
397 gridBagConstraints =
new java.awt.GridBagConstraints();
398 gridBagConstraints.gridx = 1;
399 gridBagConstraints.gridy = 6;
400 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
401 gridBagConstraints.weightx = 1.0;
402 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
403 licenseInfoPanel.add(hashLookupsRemainingLabel, gridBagConstraints);
405 org.openide.awt.Mnemonics.setLocalizedText(maxFileUploadsLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.maxFileUploadsLabel.text"));
406 gridBagConstraints =
new java.awt.GridBagConstraints();
407 gridBagConstraints.gridx = 0;
408 gridBagConstraints.gridy = 7;
409 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
410 gridBagConstraints.weightx = 1.0;
411 gridBagConstraints.insets =
new java.awt.Insets(0, 5, 5, 5);
412 licenseInfoPanel.add(maxFileUploadsLabel, gridBagConstraints);
414 org.openide.awt.Mnemonics.setLocalizedText(fileUploadsRemainingLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.fileUploadsRemainingLabel.text"));
415 gridBagConstraints =
new java.awt.GridBagConstraints();
416 gridBagConstraints.gridx = 1;
417 gridBagConstraints.gridy = 7;
418 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
419 gridBagConstraints.weightx = 1.0;
420 gridBagConstraints.insets =
new java.awt.Insets(0, 5, 5, 5);
421 licenseInfoPanel.add(fileUploadsRemainingLabel, gridBagConstraints);
423 org.openide.awt.Mnemonics.setLocalizedText(countersResetLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.countersResetLabel.text"));
424 gridBagConstraints =
new java.awt.GridBagConstraints();
425 gridBagConstraints.gridx = 0;
426 gridBagConstraints.gridy = 8;
427 gridBagConstraints.gridwidth = 2;
428 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
429 gridBagConstraints.weightx = 1.0;
430 gridBagConstraints.insets =
new java.awt.Insets(0, 5, 5, 5);
431 licenseInfoPanel.add(countersResetLabel, gridBagConstraints);
433 licenseErrorLabel.setForeground(java.awt.Color.RED);
434 org.openide.awt.Mnemonics.setLocalizedText(licenseErrorLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.licenseErrorLabel.text"));
435 gridBagConstraints =
new java.awt.GridBagConstraints();
436 gridBagConstraints.gridx = 0;
437 gridBagConstraints.gridy = 1;
438 gridBagConstraints.gridwidth = 3;
439 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
440 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
441 gridBagConstraints.weightx = 1.0;
442 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
443 licenseInfoPanel.add(licenseErrorLabel, gridBagConstraints);
445 gridBagConstraints =
new java.awt.GridBagConstraints();
446 gridBagConstraints.gridx = 0;
447 gridBagConstraints.gridy = 1;
448 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
449 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
450 gridBagConstraints.weightx = 1.0;
451 malwareScansPanel.add(licenseInfoPanel, gridBagConstraints);
453 purchasePanel.setLayout(
new java.awt.GridBagLayout());
455 org.openide.awt.Mnemonics.setLocalizedText(purchaseFromLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.purchaseFromLabel.text"));
456 gridBagConstraints =
new java.awt.GridBagConstraints();
457 gridBagConstraints.gridx = 0;
458 gridBagConstraints.gridy = 0;
459 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
460 purchasePanel.add(purchaseFromLabel, gridBagConstraints);
462 org.openide.awt.Mnemonics.setLocalizedText(purchaseLink, getHtmlLink(PURCHASE_URL));
463 purchaseLink.setCursor(
new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
464 purchaseLink.addMouseListener(
new java.awt.event.MouseAdapter() {
465 public void mouseClicked(java.awt.event.MouseEvent evt) {
466 purchaseLinkMouseClicked(evt);
469 gridBagConstraints =
new java.awt.GridBagConstraints();
470 gridBagConstraints.gridx = 1;
471 gridBagConstraints.gridy = 0;
472 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
473 gridBagConstraints.weightx = 1.0;
474 gridBagConstraints.insets =
new java.awt.Insets(0, 3, 0, 0);
475 purchasePanel.add(purchaseLink, gridBagConstraints);
477 gridBagConstraints =
new java.awt.GridBagConstraints();
478 gridBagConstraints.gridx = 0;
479 gridBagConstraints.gridy = 2;
480 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
481 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
482 gridBagConstraints.weightx = 1.0;
483 gridBagConstraints.insets =
new java.awt.Insets(0, 5, 5, 5);
484 malwareScansPanel.add(purchasePanel, gridBagConstraints);
486 gridBagConstraints =
new java.awt.GridBagConstraints();
487 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
488 gridBagConstraints.weightx = 1.0;
489 add(malwareScansPanel, gridBagConstraints);
493 "CTMalwareScannerOptionsPanel_licenseAddDialog_title=Add a License...",
494 "CTMalwareScannerOptionsPanel_licenseAddDialog_desc=License Number:",
495 "CTMalwareScannerOptionsPanel_licenseAddDialogEnteredErr_title=License Number Already Entered",
496 "CTMalwareScannerOptionsPanel_licenseAddDialogEnteredErr_desc=The license number has already been entered",
497 "CTMalwareScannerOptionsPanel_licenseAddDialogPatternErr_title=Invalid License Number",
498 "CTMalwareScannerOptionsPanel_licenseAddDialogPatternErr_desc=Please verify that license number is of format 'AUT-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'"})
500 CTLicenseDialog licenseDialog =
new CTLicenseDialog(WindowManager.getDefault().getMainWindow(),
true);
501 licenseDialog.setLocationRelativeTo(
this);
502 licenseDialog.setVisible(
true);
503 String licenseNumber = licenseDialog.getValue();
504 if (licenseNumber != null) {
505 synchronized (
this) {
507 loadLicenseInfo(licenseNumber);
512 setMalwareScansDisplay(null, null, htmlWrap(Bundle.CTMalwareScannerOptionsPanel_licenseAddDialogEnteredErr_desc()));
518 gotoLink(PURCHASE_URL);
522 setLicenseDisplay(null, null);
523 setMalwareScansDisplay(null, null, null);
524 this.firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
530 "CTMalwareScannerOptionsPanel_licenseInfo_userInfo=<html>User: {0}<br/>Email: {1}</html>",
531 "# {0} - expiresDate",
532 "CTMalwareScannerOptionsPanel_licenseInfo_expires=Expires: {0}",
534 "CTMalwareScannerOptionsPanel_licenseInfo_id=ID: {0}",
535 "# {0} - maxDailyLookups",
536 "# {1} - resetSuffix",
537 "CTMalwareScannerOptionsPanel_malwareScans_maxDailyHashLookups=Max Hash lookups: {0}{1}",
538 "# {0} - maxDailyFileLookups",
539 "# {1} - resetSuffix",
540 "CTMalwareScannerOptionsPanel_malwareScans_maxDailyFileLookups=Max file uploads: {0}{1}",
541 "# {0} - countersResetDate",
542 "CTMalwareScannerOptionsPanel_malwareScans_countersReset=Counters reset: {0}",
543 "# {0} - hashLookupsRemaining",
544 "CTMalwareScannerOptionsPanel_malwareScans_hashLookupsRemaining=Hash lookups remaining: {0}",
545 "# {0} - fileUploadsRemaining",
546 "CTMalwareScannerOptionsPanel_malwareScans_fileUploadsRemaining=File uploads remaining: {0}"})
548 this.licenseInfoAddButton.setEnabled(!isLicenseAddRunning());
549 this.licenseInfoRemoveButton.setEnabled(this.licenseInfo != null && !isLicenseAddRunning());
551 this.licenseInfoMessageLabel.setVisible(StringUtils.isNotBlank(
this.licenseInfoMessage));
552 this.licenseInfoMessageLabel.setText(this.licenseInfoMessage);
554 this.licenseErrorLabel.setVisible(StringUtils.isNotBlank(
this.authTokenError));
555 this.licenseErrorLabel.setText(this.authTokenError);
557 if (licenseInfo == null) {
558 this.licenseInfoExpiresLabel.setVisible(
false);
559 this.licenseInfoIdLabel.setVisible(
false);
560 this.licenseInfoUserLabel.setVisible(
false);
561 this.purchaseFromLabel.setVisible(
true);
562 this.purchaseLink.setVisible(
true);
564 this.purchaseFromLabel.setVisible(
false);
565 this.purchaseLink.setVisible(
false);
567 this.licenseInfoExpiresLabel.setVisible(
true);
568 this.licenseInfoExpiresLabel.setText(Bundle.CTMalwareScannerOptionsPanel_licenseInfo_expires(
569 this.licenseInfo.getDecryptedLicense().getExpirationDate() == null
572 this.licenseInfoIdLabel.setVisible(
true);
573 this.licenseInfoIdLabel.setText(Bundle.CTMalwareScannerOptionsPanel_licenseInfo_id(StringUtils.defaultString(
this.licenseInfo.getDecryptedLicense().getBoostLicenseId())));
574 this.licenseInfoUserLabel.setVisible(
true);
575 this.licenseInfoUserLabel.setText(Bundle.CTMalwareScannerOptionsPanel_licenseInfo_userInfo(
576 StringUtils.defaultString(
this.licenseInfo.getDecryptedLicense().getCustomerName()),
577 StringUtils.defaultString(
this.licenseInfo.getDecryptedLicense().getCustomerEmail())));
580 this.malwareScansMessageLabel.setVisible(StringUtils.isNotBlank(
this.authTokenMessage));
581 this.malwareScansMessageLabel.setText(this.authTokenMessage);
583 if (authTokenResponse == null || this.licenseInfo == null) {
584 this.maxHashLookupsLabel.setVisible(
false);
585 this.maxFileUploadsLabel.setVisible(
false);
586 this.countersResetLabel.setVisible(
false);
587 this.hashLookupsRemainingLabel.setVisible(
false);
588 this.fileUploadsRemainingLabel.setVisible(
false);
590 this.maxHashLookupsLabel.setVisible(
true);
591 this.maxHashLookupsLabel.setText(Bundle.CTMalwareScannerOptionsPanel_malwareScans_maxDailyHashLookups(
592 this.authTokenResponse.getHashLookupLimit(),
595 this.maxFileUploadsLabel.setVisible(
true);
596 this.maxFileUploadsLabel.setText(Bundle.CTMalwareScannerOptionsPanel_malwareScans_maxDailyFileLookups(
597 this.authTokenResponse.getFileUploadLimit(),
600 this.countersResetLabel.setVisible(
true);
603 this.hashLookupsRemainingLabel.setVisible(
true);
604 this.hashLookupsRemainingLabel.setText(
605 Bundle.CTMalwareScannerOptionsPanel_malwareScans_hashLookupsRemaining(
608 this.fileUploadsRemainingLabel.setVisible(
true);
609 this.fileUploadsRemainingLabel.setText(
610 Bundle.CTMalwareScannerOptionsPanel_malwareScans_fileUploadsRemaining(
619 return Bundle.CTMalwareScannerOptionsPanel_malwareScans_countersReset(
620 MALWARE_SCANS_RESET_FORMAT.format(authTokenResponse.
getResetDate()));
625 "CTMalwareScannerOptionsPanel_getResetSuffix_hourly=/hour",
626 "CTMalwareScannerOptionsPanel_getResetSuffix_daily=/day",
627 "CTMalwareScannerOptionsPanel_getResetSuffix_weekly=/week",
628 "CTMalwareScannerOptionsPanel_getResetSuffix_monthly=/month"
631 if (limitType == null) {
637 return Bundle.CTMalwareScannerOptionsPanel_getResetSuffix_hourly();
639 return Bundle.CTMalwareScannerOptionsPanel_getResetSuffix_daily();
641 return Bundle.CTMalwareScannerOptionsPanel_getResetSuffix_weekly();
643 return Bundle.CTMalwareScannerOptionsPanel_getResetSuffix_monthly();
651 total = total == null ? 0 : total;
652 used = used == null ? 0 : used;
658 final EULADialog eulaDialog =
new EULADialog(WindowManager.getDefault().getMainWindow(),
true);
659 eulaDialog.setLocationRelativeTo(
this);
660 eulaDialog.setSize(eulaDialog.getPreferredSize());
661 eulaDialog.setVisible(
true);
663 if (eulaDialog.isAcceptPressed()) {
666 this.firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
668 setLicenseDisplay(this.licenseInfo, null);
669 loadMalwareScansInfo(this.licenseInfo);
671 logger.log(Level.WARNING,
"An error occurred while fetching data", ex);
672 setLicenseDisplay(this.licenseInfo, null);
673 setMalwareScansDisplay(null, null, htmlWrap(Bundle.CTMalwareScannerOptionsPanel_LicenseFetcher_localErr_desc()));
678 "CTMalwareScannerOptionsPanel_LicenseFetcher_apiErr_title=Server Error",
679 "CTMalwareScannerOptionsPanel_LicenseFetcher_localErr_title=General Error",
680 "# {0} - licenseCode",
681 "CTMalwareScannerOptionsPanel_LicenseFetcher_defaultErrMsg_desc=Error activating boost license {0}",
682 "CTMalwareScannerOptionsPanel_LicenseFetcher_localErr_desc=A general error occurred while fetching license information. Please try again later.",})
688 this.licenseText = licenseText;
693 if (this.isCancelled()) {
704 if (licenseResponse == null) {
705 logger.log(Level.WARNING,
"An API error occurred while fetching license information. License fetch returned no result.");
706 setLicenseDisplay(null, null);
712 if (!Boolean.TRUE.equals(licenseResponse.
isSuccess())) {
713 logger.log(Level.WARNING,
"An API error occurred while fetching license information. License fetch was not successful");
715 String message = Bundle.CTMalwareScannerOptionsPanel_LicenseFetcher_defaultErrMsg_desc(licenseText);
716 if (!StringUtils.isBlank(licenseResponse.
getErrorMsg())) {
719 setLicenseDisplay(null, null);
720 setMalwareScansDisplay(null, null, htmlWrap(message));
725 SwingUtilities.invokeLater(() -> acceptEula(licenseResponse));
727 }
catch (InterruptedException | CancellationException ex) {
729 setLicenseDisplay(licenseInfo, null);
730 loadMalwareScansInfo(licenseInfo);
731 }
catch (ExecutionException ex) {
733 if (ex.getCause() != null && ex.getCause() instanceof
CTCloudException cloudEx) {
734 logger.log(Level.WARNING,
"An API error occurred while fetching license information", cloudEx);
735 errMessage = cloudEx.getErrorDetails();
737 logger.log(Level.WARNING,
"An error occurred while fetching data", ex);
738 errMessage = Bundle.CTMalwareScannerOptionsPanel_LicenseFetcher_localErr_desc();
740 setLicenseDisplay(null, null);
741 setMalwareScansDisplay(null, null, htmlWrap(errMessage));
751 "CTMalwareScannerOptionsPanel_MalwareScansFetcher_apiErr_title=Server Error",
752 "CTMalwareScannerOptionsPanel_MalwareScansFetcher_localErr_title=General Error",
753 "CTMalwareScannerOptionsPanel_MalwareScansFetcher_localErr_desc=A general error occurred while fetching malware scans information. Please try again later.",})
759 this.decryptedLicense = decryptedLicense;
764 if (this.isCancelled()) {
774 String authTokenError = null;
776 authTokenResponse =
get();
777 }
catch (InterruptedException | CancellationException ex) {
779 }
catch (ExecutionException ex) {
780 if (ex.getCause() != null && ex.getCause() instanceof
CTCloudException cloudEx) {
781 logger.log(Level.WARNING,
"An API error occurred while fetching malware scans information for license", cloudEx);
782 authTokenError = cloudEx.getErrorDetails();
784 logger.log(Level.WARNING,
"An error occurred while fetching data", ex);
785 authTokenError = Bundle.CTMalwareScannerOptionsPanel_MalwareScansFetcher_localErr_desc();
790 if (!this.isCancelled()) {
791 setMalwareScansDisplay(authTokenResponse, null, htmlWrap(authTokenError));
Long getFileUploadLimit()
DecryptedLicenseResponse getDecryptedLicense()
javax.swing.JLabel licenseInfoUserLabel
static String getInferredUserTimeZone()
void licenseInfoAddButtonActionPerformed(java.awt.event.ActionEvent evt)
volatile LicenseInfo licenseInfo
javax.swing.JLabel maxHashLookupsLabel
Long getFileUploadCount()
static CTApiDAO getInstance()
synchronized boolean saveLicenseResponse(LicenseResponse licenseResponse)
synchronized void loadSettings()
synchronized void renderLicenseState()
AuthTokenFetcher(DecryptedLicenseResponse decryptedLicense)
synchronized void saveSettings()
void acceptEula(LicenseResponse licenseResponse)
LicenseResponse doInBackground()
AuthTokenResponse doInBackground()
LicenseLimitType getLimitType()
static String getHtmlLink(String url)
javax.swing.JLabel fileUploadsRemainingLabel
LicenseFetcher(String licenseText)
javax.swing.JLabel licenseInfoExpiresLabel
synchronized Optional< LicenseInfo > loadLicenseInfo()
javax.swing.JLabel hashLookupsRemainingLabel
void licenseInfoRemoveButtonActionPerformed(java.awt.event.ActionEvent evt)
static CTLicensePersistence getInstance()
synchronized void loadMalwareScansInfo(LicenseInfo licenseInfo)
synchronized LicenseResponse getLicenseInfo()
javax.swing.JLabel licenseInfoIdLabel
javax.swing.JPanel malwareScansPanel
javax.swing.JLabel countersResetLabel
javax.swing.JButton licenseInfoAddButton
String getBoostLicenseId()
LicenseResponse getLicenseResponse()
void gotoLink(String url)
Long getHashLookupLimit()
Instant getExpirationDate()
Long getHashLookupCount()
static LicenseDecryptorUtil getInstance()
synchronized void setMalwareScansDisplay(AuthTokenResponse authTokenResponse, String authTokenMessage, String authTokenError)
synchronized void loadLicenseInfo(String licenseNumber)
javax.swing.JButton licenseInfoRemoveButton
AuthTokenResponse getAuthToken(DecryptedLicenseResponse decrypted)
synchronized boolean isLicenseAddRunning()
synchronized boolean deleteLicenseResponse()
volatile LicenseFetcher licenseFetcher
javax.swing.JLabel licenseInfoMessageLabel
CTMalwareScannerOptionsPanel()
synchronized boolean isMalwareScansRunning()
javax.swing.JLabel purchaseFromLabel
final DecryptedLicenseResponse decryptedLicense
volatile AuthTokenFetcher authTokenFetcher
synchronized static Logger getLogger(String name)
javax.swing.JLabel malwareScansMessageLabel
LicenseInfo createLicenseInfo(LicenseResponse licenseResponse)
synchronized void setLicenseDisplay(LicenseInfo licenseInfo, String licenseMessage)
javax.swing.JLabel maxFileUploadsLabel
LicenseResponse getLicenseInfo(String licenseString)
static String htmlWrap(String msg)
static String getCountersResetText(LicenseLimitType limitType, AuthTokenResponse authTokenResponse)
static boolean isDesktopSupported()
static Desktop getDesktop()
javax.swing.JLabel licenseErrorLabel
void purchaseLinkMouseClicked(java.awt.event.MouseEvent evt)
String getResetSuffix(LicenseLimitType limitType)
javax.swing.JLabel purchaseLink
long remaining(Long total, Long used)