diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/Bundle.properties-MERGED b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/Bundle.properties-MERGED index 537ca234f9..6f5cf48e41 100644 --- a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/Bundle.properties-MERGED +++ b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/Bundle.properties-MERGED @@ -68,3 +68,4 @@ CTLicenseDialog.licenseNumberTextField.toolTipText=AUT-XXXXXXXX-XXXX-XXXX-XXXX-X CTMalwareScannerOptionsPanel.licenseErrorLabel.text= CTMalwareScannerOptionsPanel.licenseInfoRemoveButton.text=Remove License CTMalwareScannerOptionsPanel.text=The Cyber Triage Malware Scanner module uses 40+ malware scanning engines to identify if Windows executables are malicious. It requires a paid subscription to use. +Installer_LicenseCheck_cloudExceptionTitle=Cyber Triage Error 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 e3fc7c358c..a8c6d604d6 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 @@ -727,7 +727,7 @@ public class CTMalwareScannerOptionsPanel extends CTOptionsSubPanel { String errMessage; if (ex.getCause() != null && ex.getCause() instanceof CTCloudException cloudEx) { logger.log(Level.WARNING, "An API error occurred while fetching license information", cloudEx); - errMessage = cloudEx.getErrorCode().getDescription(); + errMessage = cloudEx.getErrorDetails(); } else { logger.log(Level.WARNING, "An error occurred while fetching data", ex); errMessage = Bundle.CTMalwareScannerOptionsPanel_LicenseFetcher_localErr_desc(); diff --git a/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/Installer.java b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/Installer.java new file mode 100644 index 0000000000..0cbbaca09c --- /dev/null +++ b/Core/src/com/basistech/df/cybertriage/autopsy/ctoptions/ctcloud/Installer.java @@ -0,0 +1,75 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2023 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.basistech.df.cybertriage.autopsy.ctoptions.ctcloud; + +import com.basistech.df.cybertriage.autopsy.ctapi.CTApiDAO; +import com.basistech.df.cybertriage.autopsy.ctapi.CTCloudException; +import com.basistech.df.cybertriage.autopsy.ctapi.json.AuthTokenResponse; +import com.basistech.df.cybertriage.autopsy.ctapi.json.LicenseInfo; +import java.util.Optional; +import java.util.logging.Level; +import org.openide.modules.ModuleInstall; +import org.openide.util.NbBundle.Messages; +import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; + +/** + * Installer to check for a functional license at startup. + */ +public class Installer extends ModuleInstall { + private final static Logger LOGGER = Logger.getLogger(Installer.class.getName()); + + private final static Installer INSTANCE = new Installer(); + + public static Installer getDefault() { + return INSTANCE; + } + + private Installer() {} + + @Override + public void restored() { + new Thread(new LicenseCheck()).start(); + } + + @Messages({ + "Installer_LicenseCheck_cloudExceptionTitle=Cyber Triage Error" + }) + private static class LicenseCheck implements Runnable { + + @Override + public void run() { + try { + Optional licenseInfoOpt = CTLicensePersistence.getInstance().loadLicenseInfo(); + if (licenseInfoOpt.isEmpty()) { + return; + } + + LicenseInfo licenseInfo = licenseInfoOpt.get(); + AuthTokenResponse authTokenResp = CTApiDAO.getInstance().getAuthToken(licenseInfo.getDecryptedLicense()); + // if we got this far, then it was a successful request + } catch (CTCloudException cloudEx) { + LOGGER.log(Level.WARNING, "A cloud exception occurred while fetching an auth token", cloudEx); + MessageNotifyUtil.Notify.warn(Bundle.Installer_LicenseCheck_cloudExceptionTitle(), cloudEx.getErrorDetails()); + } catch (Throwable t) { + LOGGER.log(Level.WARNING, "An error occurred while fetching license info", t); + } + } + } +} diff --git a/Core/src/org/sleuthkit/autopsy/core/Installer.java b/Core/src/org/sleuthkit/autopsy/core/Installer.java index 24c40e9967..fca2db5f30 100644 --- a/Core/src/org/sleuthkit/autopsy/core/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/core/Installer.java @@ -217,6 +217,7 @@ public class Installer extends ModuleInstall { packageInstallers.add(org.sleuthkit.autopsy.casemodule.Installer.getDefault()); packageInstallers.add(org.sleuthkit.autopsy.modules.hashdatabase.infrastructure.Installer.getDefault()); packageInstallers.add(org.sleuthkit.autopsy.report.infrastructure.Installer.getDefault()); + packageInstallers.add(com.basistech.df.cybertriage.autopsy.ctoptions.ctcloud.Installer.getDefault()); /** * This is a temporary workaround for the following bug in Tika that