19 package com.basistech.df.cybertriage.autopsy.ctoptions.ctcloud;
31 import java.awt.Desktop;
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.JOptionPane;
44 import javax.swing.SwingUtilities;
45 import javax.swing.SwingWorker;
46 import org.apache.commons.lang3.StringUtils;
47 import org.netbeans.spi.options.OptionsPanelController;
48 import org.openide.util.NbBundle;
49 import org.openide.util.NbBundle.Messages;
50 import org.openide.util.lookup.ServiceProvider;
51 import org.openide.windows.WindowManager;
59 @ServiceProvider(service = CTOptionsSubPanel.class)
64 private static final DateTimeFormatter LICENSE_EXPIRES_FORMAT = DateTimeFormatter
65 .ofPattern(
"MMMM d, YYYY")
68 private static final DateTimeFormatter MALWARE_SCANS_RESET_FORMAT = DateTimeFormatter
69 .ofPattern(
"MMM d, YYYY' at 'h:mma")
76 private volatile String licenseInfoMessage = null;
79 private static final String PURCHASE_URL =
"https://cybertriage.com/autopsy-malware-module";
82 private volatile String authTokenMessage = null;
91 this.addComponentListener(
new ComponentAdapter() {
93 public void componentHidden(ComponentEvent e) {
108 public void componentShown(ComponentEvent e) {
131 Optional<LicenseInfo> licenseInfoOpt = ctPersistence.
loadLicenseInfo();
132 LicenseInfo licenseInfo = licenseInfoOpt.orElse(null);
133 setLicenseDisplay(licenseInfo, null);
134 setMalwareScansDisplay(null, null);
135 if (licenseInfo != null) {
136 loadMalwareScansInfo(licenseInfo);
137 this.purchaseFromLabel.setVisible(
false);
138 this.purchaseLink.setVisible(
false);
140 this.purchaseFromLabel.setVisible(
true);
141 this.purchaseLink.setVisible(
true);
146 return "<html><span style=\"color: blue; text-decoration: underline\">" + url +
"</span></html>";
150 if (Desktop.isDesktopSupported()) {
152 Desktop.getDesktop().browse(
new URI(url));
153 }
catch (IOException | URISyntaxException e) {
154 logger.log(Level.SEVERE,
"Error opening link to: " + url, e);
157 logger.log(Level.WARNING,
"Desktop API is not supported. Link cannot be opened.");
166 this.licenseInfo = licenseInfo;
167 this.licenseInfoMessage = licenseMessage;
168 renderLicenseState();
172 this.authTokenResponse = authTokenResponse;
173 this.authTokenMessage = authTokenMessage;
174 renderLicenseState();
181 return this.licenseFetcher != null && !this.licenseFetcher.isCancelled() && !this.licenseFetcher.isDone();
188 return this.authTokenFetcher != null && !this.authTokenFetcher.isCancelled() && !this.authTokenFetcher.isDone();
192 "CTOPtionsPanel_loadLicenseInfo_loading=Loading..."
195 if (isLicenseAddRunning()) {
196 this.licenseFetcher.cancel(
true);
198 setLicenseDisplay(null, Bundle.CTOPtionsPanel_loadLicenseInfo_loading());
199 setMalwareScansDisplay(null, null);
201 this.licenseFetcher.execute();
205 "CTOPtionsPanel_loadMalwareScansInfo_loading=Loading..."
208 if (isMalwareScansRunning()) {
209 this.authTokenFetcher.cancel(
true);
213 setMalwareScansDisplay(null, null);
217 setMalwareScansDisplay(null, Bundle.CTOPtionsPanel_loadMalwareScansInfo_loading());
220 this.authTokenFetcher.execute();
228 @SuppressWarnings(
"unchecked")
230 private
void initComponents() {
231 java.awt.GridBagConstraints gridBagConstraints;
233 malwareScansPanel =
new javax.swing.JPanel();
234 javax.swing.JLabel disclaimer =
new javax.swing.JLabel();
235 javax.swing.JPanel licenseInfoPanel =
new javax.swing.JPanel();
236 licenseInfoMessageLabel =
new javax.swing.JLabel();
237 licenseInfoExpiresLabel =
new javax.swing.JLabel();
238 licenseInfoIdLabel =
new javax.swing.JLabel();
239 licenseInfoUserLabel =
new javax.swing.JLabel();
240 licenseInfoAddButton =
new javax.swing.JButton();
241 maxFileUploadsLabel =
new javax.swing.JLabel();
242 maxHashLookupsLabel =
new javax.swing.JLabel();
243 hashLookupsRemainingLabel =
new javax.swing.JLabel();
244 malwareScansMessageLabel =
new javax.swing.JLabel();
245 countersResetLabel =
new javax.swing.JLabel();
246 fileUploadsRemainingLabel =
new javax.swing.JLabel();
247 javax.swing.JPanel purchasePanel =
new javax.swing.JPanel();
248 purchaseFromLabel =
new javax.swing.JLabel();
249 purchaseLink =
new javax.swing.JLabel();
251 setLayout(
new java.awt.GridBagLayout());
253 malwareScansPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.malwareScansPanel.border.title")));
254 malwareScansPanel.setLayout(
new java.awt.GridBagLayout());
256 org.openide.awt.Mnemonics.setLocalizedText(disclaimer,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.disclaimer.text"));
257 disclaimer.setVerticalAlignment(javax.swing.SwingConstants.TOP);
258 gridBagConstraints =
new java.awt.GridBagConstraints();
259 gridBagConstraints.gridx = 0;
260 gridBagConstraints.gridy = 0;
261 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
262 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
263 gridBagConstraints.weightx = 1.0;
264 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
265 malwareScansPanel.add(disclaimer, gridBagConstraints);
267 licenseInfoPanel.setLayout(
new java.awt.GridBagLayout());
269 org.openide.awt.Mnemonics.setLocalizedText(licenseInfoMessageLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.licenseInfoMessageLabel.text"));
270 gridBagConstraints =
new java.awt.GridBagConstraints();
271 gridBagConstraints.gridx = 0;
272 gridBagConstraints.gridy = 0;
273 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
274 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
275 gridBagConstraints.weightx = 1.0;
276 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
277 licenseInfoPanel.add(licenseInfoMessageLabel, gridBagConstraints);
279 org.openide.awt.Mnemonics.setLocalizedText(licenseInfoExpiresLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.licenseInfoExpiresLabel.text"));
280 gridBagConstraints =
new java.awt.GridBagConstraints();
281 gridBagConstraints.gridx = 0;
282 gridBagConstraints.gridy = 1;
283 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
284 gridBagConstraints.weightx = 1.0;
285 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
286 licenseInfoPanel.add(licenseInfoExpiresLabel, gridBagConstraints);
288 org.openide.awt.Mnemonics.setLocalizedText(licenseInfoIdLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.licenseInfoIdLabel.text"));
289 gridBagConstraints =
new java.awt.GridBagConstraints();
290 gridBagConstraints.gridx = 1;
291 gridBagConstraints.gridy = 1;
292 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
293 gridBagConstraints.weightx = 1.0;
294 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
295 licenseInfoPanel.add(licenseInfoIdLabel, gridBagConstraints);
297 org.openide.awt.Mnemonics.setLocalizedText(licenseInfoUserLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.licenseInfoUserLabel.text"));
298 gridBagConstraints =
new java.awt.GridBagConstraints();
299 gridBagConstraints.gridx = 0;
300 gridBagConstraints.gridy = 2;
301 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
302 gridBagConstraints.weightx = 1.0;
303 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
304 licenseInfoPanel.add(licenseInfoUserLabel, gridBagConstraints);
306 org.openide.awt.Mnemonics.setLocalizedText(licenseInfoAddButton,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.licenseInfoAddButton.text"));
307 licenseInfoAddButton.addActionListener(
new java.awt.event.ActionListener() {
308 public void actionPerformed(java.awt.event.ActionEvent evt) {
309 licenseInfoAddButtonActionPerformed(evt);
312 gridBagConstraints =
new java.awt.GridBagConstraints();
313 gridBagConstraints.gridx = 2;
314 gridBagConstraints.gridy = 2;
315 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
316 gridBagConstraints.weightx = 1.0;
317 gridBagConstraints.insets =
new java.awt.Insets(0, 5, 5, 5);
318 licenseInfoPanel.add(licenseInfoAddButton, gridBagConstraints);
320 org.openide.awt.Mnemonics.setLocalizedText(maxFileUploadsLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.maxFileUploadsLabel.text"));
321 gridBagConstraints =
new java.awt.GridBagConstraints();
322 gridBagConstraints.gridx = 0;
323 gridBagConstraints.gridy = 4;
324 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
325 gridBagConstraints.weightx = 1.0;
326 gridBagConstraints.insets =
new java.awt.Insets(0, 5, 5, 5);
327 licenseInfoPanel.add(maxFileUploadsLabel, gridBagConstraints);
329 org.openide.awt.Mnemonics.setLocalizedText(maxHashLookupsLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.maxHashLookupsLabel.text"));
330 gridBagConstraints =
new java.awt.GridBagConstraints();
331 gridBagConstraints.gridx = 0;
332 gridBagConstraints.gridy = 3;
333 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
334 gridBagConstraints.weightx = 1.0;
335 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
336 licenseInfoPanel.add(maxHashLookupsLabel, gridBagConstraints);
338 org.openide.awt.Mnemonics.setLocalizedText(hashLookupsRemainingLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.hashLookupsRemainingLabel.text"));
339 gridBagConstraints =
new java.awt.GridBagConstraints();
340 gridBagConstraints.gridx = 1;
341 gridBagConstraints.gridy = 3;
342 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
343 gridBagConstraints.weightx = 1.0;
344 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
345 licenseInfoPanel.add(hashLookupsRemainingLabel, gridBagConstraints);
347 org.openide.awt.Mnemonics.setLocalizedText(malwareScansMessageLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.malwareScansMessageLabel.text"));
348 gridBagConstraints =
new java.awt.GridBagConstraints();
349 gridBagConstraints.gridx = 0;
350 gridBagConstraints.gridy = 3;
351 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
352 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
353 gridBagConstraints.weightx = 1.0;
354 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
355 licenseInfoPanel.add(malwareScansMessageLabel, gridBagConstraints);
357 org.openide.awt.Mnemonics.setLocalizedText(countersResetLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.countersResetLabel.text"));
358 gridBagConstraints =
new java.awt.GridBagConstraints();
359 gridBagConstraints.gridx = 0;
360 gridBagConstraints.gridy = 5;
361 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
362 gridBagConstraints.weightx = 1.0;
363 gridBagConstraints.insets =
new java.awt.Insets(0, 5, 5, 5);
364 licenseInfoPanel.add(countersResetLabel, gridBagConstraints);
366 org.openide.awt.Mnemonics.setLocalizedText(fileUploadsRemainingLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.fileUploadsRemainingLabel.text"));
367 gridBagConstraints =
new java.awt.GridBagConstraints();
368 gridBagConstraints.gridx = 1;
369 gridBagConstraints.gridy = 4;
370 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
371 gridBagConstraints.weightx = 1.0;
372 gridBagConstraints.insets =
new java.awt.Insets(0, 5, 5, 5);
373 licenseInfoPanel.add(fileUploadsRemainingLabel, gridBagConstraints);
375 gridBagConstraints =
new java.awt.GridBagConstraints();
376 gridBagConstraints.gridx = 0;
377 gridBagConstraints.gridy = 1;
378 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
379 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
380 gridBagConstraints.weightx = 1.0;
381 malwareScansPanel.add(licenseInfoPanel, gridBagConstraints);
383 purchasePanel.setLayout(
new java.awt.GridBagLayout());
385 org.openide.awt.Mnemonics.setLocalizedText(purchaseFromLabel,
org.openide.util.NbBundle.getMessage(
CTMalwareScannerOptionsPanel.class,
"CTMalwareScannerOptionsPanel.purchaseFromLabel.text"));
386 gridBagConstraints =
new java.awt.GridBagConstraints();
387 gridBagConstraints.gridx = 0;
388 gridBagConstraints.gridy = 0;
389 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
390 purchasePanel.add(purchaseFromLabel, gridBagConstraints);
392 org.openide.awt.Mnemonics.setLocalizedText(purchaseLink, getHtmlLink(PURCHASE_URL));
393 purchaseLink.setCursor(
new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
394 purchaseLink.addMouseListener(
new java.awt.event.MouseAdapter() {
395 public void mouseClicked(java.awt.event.MouseEvent evt) {
396 purchaseLinkMouseClicked(evt);
399 gridBagConstraints =
new java.awt.GridBagConstraints();
400 gridBagConstraints.gridx = 1;
401 gridBagConstraints.gridy = 0;
402 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
403 gridBagConstraints.weightx = 1.0;
404 gridBagConstraints.insets =
new java.awt.Insets(0, 3, 0, 0);
405 purchasePanel.add(purchaseLink, gridBagConstraints);
407 gridBagConstraints =
new java.awt.GridBagConstraints();
408 gridBagConstraints.gridx = 0;
409 gridBagConstraints.gridy = 3;
410 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
411 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
412 gridBagConstraints.weightx = 1.0;
413 gridBagConstraints.insets =
new java.awt.Insets(0, 5, 5, 5);
414 malwareScansPanel.add(purchasePanel, gridBagConstraints);
416 gridBagConstraints =
new java.awt.GridBagConstraints();
417 gridBagConstraints.gridx = 0;
418 gridBagConstraints.gridy = 2;
419 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
420 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
421 gridBagConstraints.weightx = 1.0;
422 add(malwareScansPanel, gridBagConstraints);
426 "CTMalwareScannerOptionsPanel_licenseAddDialog_title=Add a License...",
427 "CTMalwareScannerOptionsPanel_licenseAddDialog_desc=License Number:",
428 "CTMalwareScannerOptionsPanel_licenseAddDialogEnteredErr_title=License Number Already Entered",
429 "CTMalwareScannerOptionsPanel_licenseAddDialogEnteredErr_desc=The license number has already been entered",
430 "CTMalwareScannerOptionsPanel_licenseAddDialogPatternErr_title=Invalid License Number",
431 "CTMalwareScannerOptionsPanel_licenseAddDialogPatternErr_desc=Please verify that license number is of format 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'"})
433 CTLicenseDialog licenseDialog =
new CTLicenseDialog(WindowManager.getDefault().getMainWindow(),
true);
434 licenseDialog.setLocationRelativeTo(
this);
435 licenseDialog.setVisible(
true);
436 String licenseNumber = licenseDialog.getValue();
437 if (licenseNumber != null) {
438 synchronized (
this) {
440 loadLicenseInfo(licenseNumber);
445 JOptionPane.showMessageDialog(
447 Bundle.CTMalwareScannerOptionsPanel_licenseAddDialogEnteredErr_desc(),
448 Bundle.CTMalwareScannerOptionsPanel_licenseAddDialogEnteredErr_title(),
449 JOptionPane.INFORMATION_MESSAGE);
455 gotoLink(PURCHASE_URL);
461 "CTMalwareScannerOptionsPanel_licenseInfo_userInfo=<html>User: {0}<br/>Email: {1}</html>",
462 "# {0} - expiresDate",
463 "CTMalwareScannerOptionsPanel_licenseInfo_expires=Expires: {0}",
465 "CTMalwareScannerOptionsPanel_licenseInfo_id=ID: {0}",
466 "# {0} - maxDailyLookups",
467 "# {1} - resetSuffix",
468 "CTMalwareScannerOptionsPanel_malwareScans_maxDailyHashLookups=Max Hash lookups: {0}{1}",
469 "# {0} - maxDailyFileLookups",
470 "# {1} - resetSuffix",
471 "CTMalwareScannerOptionsPanel_malwareScans_maxDailyFileLookups=Max file uploads: {0}{1}",
472 "# {0} - countersResetDate",
473 "CTMalwareScannerOptionsPanel_malwareScans_countersReset=Counters reset: {0}",
474 "# {0} - hashLookupsRemaining",
475 "CTMalwareScannerOptionsPanel_malwareScans_hashLookupsRemaining=Hash lookups remaining: {0}",
476 "# {0} - fileUploadsRemaining",
477 "CTMalwareScannerOptionsPanel_malwareScans_fileUploadsRemaining=File uploads remaining: {0}"})
479 this.licenseInfoAddButton.setEnabled(!isLicenseAddRunning());
481 this.licenseInfoMessageLabel.setVisible(StringUtils.isNotBlank(
this.licenseInfoMessage));
482 this.licenseInfoMessageLabel.setText(this.licenseInfoMessage);
484 if (licenseInfo == null) {
485 this.licenseInfoExpiresLabel.setVisible(
false);
486 this.licenseInfoIdLabel.setVisible(
false);
487 this.licenseInfoUserLabel.setVisible(
false);
488 this.purchaseFromLabel.setVisible(
true);
489 this.purchaseLink.setVisible(
true);
491 this.purchaseFromLabel.setVisible(
false);
492 this.purchaseLink.setVisible(
false);
494 this.licenseInfoExpiresLabel.setVisible(
true);
495 this.licenseInfoExpiresLabel.setText(Bundle.CTMalwareScannerOptionsPanel_licenseInfo_expires(
496 this.licenseInfo.getDecryptedLicense().getExpirationDate() == null
499 this.licenseInfoIdLabel.setVisible(
true);
500 this.licenseInfoIdLabel.setText(Bundle.CTMalwareScannerOptionsPanel_licenseInfo_id(StringUtils.defaultString(
this.licenseInfo.getDecryptedLicense().getBoostLicenseId())));
501 this.licenseInfoUserLabel.setVisible(
true);
502 this.licenseInfoUserLabel.setText(Bundle.CTMalwareScannerOptionsPanel_licenseInfo_userInfo(
503 StringUtils.defaultString(
this.licenseInfo.getDecryptedLicense().getCustomerName()),
504 StringUtils.defaultString(
this.licenseInfo.getDecryptedLicense().getCustomerEmail())));
507 this.malwareScansMessageLabel.setVisible(StringUtils.isNotBlank(
this.authTokenMessage));
508 this.malwareScansMessageLabel.setText(this.authTokenMessage);
510 if (authTokenResponse == null || this.licenseInfo == null) {
511 this.maxHashLookupsLabel.setVisible(
false);
512 this.maxFileUploadsLabel.setVisible(
false);
513 this.countersResetLabel.setVisible(
false);
514 this.hashLookupsRemainingLabel.setVisible(
false);
515 this.fileUploadsRemainingLabel.setVisible(
false);
517 this.maxHashLookupsLabel.setVisible(
true);
518 this.maxHashLookupsLabel.setText(Bundle.CTMalwareScannerOptionsPanel_malwareScans_maxDailyHashLookups(
519 this.authTokenResponse.getHashLookupLimit(),
522 this.maxFileUploadsLabel.setVisible(
true);
523 this.maxFileUploadsLabel.setText(Bundle.CTMalwareScannerOptionsPanel_malwareScans_maxDailyFileLookups(
524 this.authTokenResponse.getFileUploadLimit(),
527 this.countersResetLabel.setVisible(
true);
530 this.hashLookupsRemainingLabel.setVisible(
true);
531 this.hashLookupsRemainingLabel.setText(
532 Bundle.CTMalwareScannerOptionsPanel_malwareScans_hashLookupsRemaining(
535 this.fileUploadsRemainingLabel.setVisible(
true);
536 this.fileUploadsRemainingLabel.setText(
537 Bundle.CTMalwareScannerOptionsPanel_malwareScans_fileUploadsRemaining(
546 return Bundle.CTMalwareScannerOptionsPanel_malwareScans_countersReset(
547 MALWARE_SCANS_RESET_FORMAT.format(authTokenResponse.
getResetDate()));
552 "CTMalwareScannerOptionsPanel_getResetSuffix_hourly=/hour",
553 "CTMalwareScannerOptionsPanel_getResetSuffix_daily=/day",
554 "CTMalwareScannerOptionsPanel_getResetSuffix_weekly=/week",
555 "CTMalwareScannerOptionsPanel_getResetSuffix_monthly=/month"
558 if (limitType == null) {
564 return Bundle.CTMalwareScannerOptionsPanel_getResetSuffix_hourly();
566 return Bundle.CTMalwareScannerOptionsPanel_getResetSuffix_daily();
568 return Bundle.CTMalwareScannerOptionsPanel_getResetSuffix_weekly();
570 return Bundle.CTMalwareScannerOptionsPanel_getResetSuffix_monthly();
578 total = total == null ? 0 : total;
579 used = used == null ? 0 : used;
585 final EULADialog eulaDialog =
new EULADialog(WindowManager.getDefault().getMainWindow(),
true);
586 eulaDialog.setLocationRelativeTo(
this);
587 eulaDialog.setSize(eulaDialog.getPreferredSize());
588 eulaDialog.setVisible(
true);
590 if (eulaDialog.isAcceptPressed()) {
593 this.firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
596 logger.log(Level.WARNING,
"An error occurred while fetching data", ex);
597 JOptionPane.showMessageDialog(
599 Bundle.CTMalwareScannerOptionsPanel_LicenseFetcher_localErr_desc(),
600 Bundle.CTMalwareScannerOptionsPanel_LicenseFetcher_localErr_title(),
601 JOptionPane.ERROR_MESSAGE);
603 setLicenseDisplay(this.licenseInfo, null);
604 loadMalwareScansInfo(this.licenseInfo);
609 "CTMalwareScannerOptionsPanel_LicenseFetcher_apiErr_title=Server Error",
610 "CTMalwareScannerOptionsPanel_LicenseFetcher_localErr_title=General Error",
611 "# {0} - licenseCode",
612 "CTMalwareScannerOptionsPanel_LicenseFetcher_defaultErrMsg_desc=Error activating boost license {0}",
613 "CTMalwareScannerOptionsPanel_LicenseFetcher_localErr_desc=A general error occurred while fetching license information. Please try again later.",})
619 this.licenseText = licenseText;
624 if (this.isCancelled()) {
635 if (licenseResponse == null) {
636 logger.log(Level.WARNING,
"An API error occurred while fetching license information. License fetch returned no result.");
637 JOptionPane.showMessageDialog(
640 Bundle.CTMalwareScannerOptionsPanel_LicenseFetcher_apiErr_title(),
641 JOptionPane.ERROR_MESSAGE);
642 setLicenseDisplay(licenseInfo, null);
643 loadMalwareScansInfo(licenseInfo);
648 if (!Boolean.TRUE.equals(licenseResponse.
isSuccess())) {
649 logger.log(Level.WARNING,
"An API error occurred while fetching license information. License fetch was not successful");
651 String message = Bundle.CTMalwareScannerOptionsPanel_LicenseFetcher_defaultErrMsg_desc(licenseText);
652 if (!StringUtils.isBlank(licenseResponse.
getErrorMsg())) {
655 JOptionPane.showMessageDialog(
658 Bundle.CTMalwareScannerOptionsPanel_LicenseFetcher_apiErr_title(),
659 JOptionPane.ERROR_MESSAGE);
660 setLicenseDisplay(licenseInfo, null);
661 loadMalwareScansInfo(licenseInfo);
666 SwingUtilities.invokeLater(() -> acceptEula(licenseResponse));
668 }
catch (InterruptedException | CancellationException ex) {
670 setLicenseDisplay(licenseInfo, null);
671 loadMalwareScansInfo(licenseInfo);
672 }
catch (ExecutionException ex) {
673 if (ex.getCause() != null && ex.getCause() instanceof
CTCloudException cloudEx) {
674 logger.log(Level.WARNING,
"An API error occurred while fetching license information", cloudEx);
675 JOptionPane.showMessageDialog(
677 cloudEx.getErrorCode().getDescription(),
678 Bundle.CTMalwareScannerOptionsPanel_LicenseFetcher_apiErr_title(),
679 JOptionPane.ERROR_MESSAGE);
681 logger.log(Level.WARNING,
"An error occurred while fetching data", ex);
682 JOptionPane.showMessageDialog(
684 Bundle.CTMalwareScannerOptionsPanel_LicenseFetcher_localErr_desc(),
685 Bundle.CTMalwareScannerOptionsPanel_LicenseFetcher_localErr_title(),
686 JOptionPane.ERROR_MESSAGE);
688 setLicenseDisplay(licenseInfo, null);
689 loadMalwareScansInfo(licenseInfo);
699 "CTMalwareScannerOptionsPanel_MalwareScansFetcher_apiErr_title=Server Error",
700 "CTMalwareScannerOptionsPanel_MalwareScansFetcher_localErr_title=General Error",
701 "CTMalwareScannerOptionsPanel_MalwareScansFetcher_localErr_desc=A general error occurred while fetching malware scans information. Please try again later.",})
707 this.decryptedLicense = decryptedLicense;
712 if (this.isCancelled()) {
723 authTokenResponse =
get();
724 }
catch (InterruptedException | CancellationException ex) {
726 }
catch (ExecutionException ex) {
727 if (ex.getCause() != null && ex.getCause() instanceof
CTCloudException cloudEx) {
728 logger.log(Level.WARNING,
"An API error occurred while fetching malware scans information for license", cloudEx);
729 JOptionPane.showMessageDialog(
731 cloudEx.getErrorDetails(),
732 Bundle.CTMalwareScannerOptionsPanel_MalwareScansFetcher_apiErr_title(),
733 JOptionPane.ERROR_MESSAGE);
735 logger.log(Level.WARNING,
"An error occurred while fetching data", ex);
736 JOptionPane.showMessageDialog(
738 Bundle.CTMalwareScannerOptionsPanel_MalwareScansFetcher_localErr_desc(),
739 Bundle.CTMalwareScannerOptionsPanel_MalwareScansFetcher_localErr_title(),
740 JOptionPane.ERROR_MESSAGE);
745 if (!this.isCancelled()) {
746 setMalwareScansDisplay(authTokenResponse, null);
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 void setMalwareScansDisplay(AuthTokenResponse authTokenResponse, String authTokenMessage)
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
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 loadLicenseInfo(String licenseNumber)
AuthTokenResponse getAuthToken(DecryptedLicenseResponse decrypted)
synchronized boolean isLicenseAddRunning()
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 getCountersResetText(LicenseLimitType limitType, AuthTokenResponse authTokenResponse)
void purchaseLinkMouseClicked(java.awt.event.MouseEvent evt)
String getResetSuffix(LicenseLimitType limitType)
javax.swing.JLabel purchaseLink
long remaining(Long total, Long used)