diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/CTOptionsPanel.java b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/CTOptionsPanel.java index fd235b580e..31fa00cb75 100644 --- a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/CTOptionsPanel.java +++ b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/CTOptionsPanel.java @@ -33,6 +33,7 @@ import org.sleuthkit.autopsy.ingest.IngestModuleGlobalSettingsPanel; * Options panel for CyberTriage. */ public class CTOptionsPanel extends IngestModuleGlobalSettingsPanel { + private static final int MAX_SUBPANEL_WIDTH = 500; private static final Logger logger = Logger.getLogger(CTOptionsPanel.class.getName()); @@ -47,6 +48,16 @@ public class CTOptionsPanel extends IngestModuleGlobalSettingsPanel { Collection coll = Lookup.getDefault().lookupAll(CTOptionsSubPanel.class); Stream panelStream = coll != null ? coll.stream() : Stream.empty(); this.subPanels = panelStream + .map(panel -> { + try { + // lookup is returning singleton instances which means this panel gets messed up when accessed + // from multiple places because the panel's children are being added to a different CTOptionsPanel + return (CTOptionsSubPanel) panel.getClass().getConstructor().newInstance(); + } catch (Exception ex) { + return null; + } + }) + .filter(item -> item != null) .sorted(Comparator.comparing(p -> p.getClass().getSimpleName().toUpperCase())) .collect(Collectors.toList()); addSubOptionsPanels(this.subPanels); @@ -64,7 +75,7 @@ public class CTOptionsPanel extends IngestModuleGlobalSettingsPanel { } } }); - + GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = i; @@ -76,29 +87,28 @@ public class CTOptionsPanel extends IngestModuleGlobalSettingsPanel { contentPane.add(subPanel, gridBagConstraints); } - - GridBagConstraints verticalConstraints = new GridBagConstraints(); - verticalConstraints.gridx = 0; - verticalConstraints.gridy = subPanels.size(); - verticalConstraints.weighty = 1; - verticalConstraints.weightx = 0; - - JPanel verticalSpacer = new JPanel(); - - verticalSpacer.setMinimumSize(new Dimension(MAX_SUBPANEL_WIDTH, 0)); - verticalSpacer.setPreferredSize(new Dimension(MAX_SUBPANEL_WIDTH, 0)); - verticalSpacer.setMaximumSize(new Dimension(MAX_SUBPANEL_WIDTH, Short.MAX_VALUE)); - contentPane.add(verticalSpacer, verticalConstraints); - - - GridBagConstraints horizontalConstraints = new GridBagConstraints(); - horizontalConstraints.gridx = 1; - horizontalConstraints.gridy = 0; - horizontalConstraints.weighty = 0; - horizontalConstraints.weightx = 1; - - JPanel horizontalSpacer = new JPanel(); - contentPane.add(horizontalSpacer, horizontalConstraints); + + GridBagConstraints verticalConstraints = new GridBagConstraints(); + verticalConstraints.gridx = 0; + verticalConstraints.gridy = subPanels.size(); + verticalConstraints.weighty = 1; + verticalConstraints.weightx = 0; + + JPanel verticalSpacer = new JPanel(); + + verticalSpacer.setMinimumSize(new Dimension(MAX_SUBPANEL_WIDTH, 0)); + verticalSpacer.setPreferredSize(new Dimension(MAX_SUBPANEL_WIDTH, 0)); + verticalSpacer.setMaximumSize(new Dimension(MAX_SUBPANEL_WIDTH, Short.MAX_VALUE)); + contentPane.add(verticalSpacer, verticalConstraints); + + GridBagConstraints horizontalConstraints = new GridBagConstraints(); + horizontalConstraints.gridx = 1; + horizontalConstraints.gridy = 0; + horizontalConstraints.weighty = 0; + horizontalConstraints.weightx = 1; + + JPanel horizontalSpacer = new JPanel(); + contentPane.add(horizontalSpacer, horizontalConstraints); } /** diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTMalwareScannerOptionsPanel.java b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTMalwareScannerOptionsPanel.java index a1eb7d9386..f4e0728312 100644 --- a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTMalwareScannerOptionsPanel.java +++ b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/CTMalwareScannerOptionsPanel.java @@ -50,7 +50,7 @@ public class CTMalwareScannerOptionsPanel extends CTOptionsSubPanel { private static final DateTimeFormatter LICENSE_EXPIRES_FORMAT = DateTimeFormatter .ofPattern("MMMM d, YYYY") .withZone(ZoneId.of(UserPreferences.getTimeZoneForDisplays())); - + private static final DateTimeFormatter MALWARE_SCANS_RESET_FORMAT = DateTimeFormatter .ofPattern("MMM d, YYYY' at 'h:mma") .withZone(ZoneId.of(UserPreferences.getTimeZoneForDisplays())); @@ -175,11 +175,9 @@ public class CTMalwareScannerOptionsPanel extends CTOptionsSubPanel { setMalwareScansDisplay(null, null); return; } - + setMalwareScansDisplay(null, Bundle.CTOPtionsPanel_loadMalwareScansInfo_loading()); - - this.authTokenFetcher = new AuthTokenFetcher(licenseInfo.getDecryptedLicense()); this.authTokenFetcher.execute(); } @@ -452,8 +450,20 @@ public class CTMalwareScannerOptionsPanel extends CTOptionsSubPanel { @Override protected LicenseInfo doInBackground() throws Exception { + if (this.isCancelled()) { + return null; + } LicenseResponse licenseResponse = ctApiDAO.getLicenseInfo(licenseText); + + if (this.isCancelled()) { + return null; + } + ctPersistence.saveLicenseResponse(licenseResponse); + + if (this.isCancelled()) { + return null; + } return LicenseDecryptorUtil.getInstance().createLicenseInfo(licenseResponse); } @@ -508,6 +518,10 @@ public class CTMalwareScannerOptionsPanel extends CTOptionsSubPanel { @Override protected AuthTokenResponse doInBackground() throws Exception { + if (this.isCancelled()) { + return null; + } + return ctApiDAO.getAuthToken(decryptedLicense); }