19 package org.sleuthkit.autopsy.core;
21 import com.sun.jna.platform.win32.Kernel32;
22 import java.awt.Cursor;
24 import java.io.IOException;
25 import java.nio.file.Path;
26 import java.nio.file.Paths;
27 import java.util.ArrayList;
28 import java.util.List;
29 import java.util.concurrent.Callable;
30 import java.util.concurrent.ExecutionException;
31 import java.util.concurrent.FutureTask;
32 import java.util.logging.Handler;
33 import java.util.logging.Level;
34 import javafx.application.Platform;
35 import javafx.embed.swing.JFXPanel;
36 import javax.imageio.ImageIO;
37 import net.sf.sevenzipjbinding.SevenZip;
38 import net.sf.sevenzipjbinding.SevenZipNativeInitializationException;
39 import org.apache.commons.io.FileUtils;
40 import org.apache.commons.lang3.StringUtils;
41 import org.openide.modules.InstalledFileLocator;
42 import org.openide.modules.ModuleInstall;
43 import org.openide.util.NbBundle;
44 import org.openide.windows.WindowManager;
74 ImageIO.scanForPlugins();
100 System.loadLibrary(
"api-ms-win-core-console-l1-1-0");
101 System.loadLibrary(
"api-ms-win-core-datetime-l1-1-0");
102 System.loadLibrary(
"api-ms-win-core-debug-l1-1-0");
103 System.loadLibrary(
"api-ms-win-core-errorhandling-l1-1-0");
104 System.loadLibrary(
"api-ms-win-core-file-l1-1-0");
105 System.loadLibrary(
"api-ms-win-core-file-l1-2-0");
106 System.loadLibrary(
"api-ms-win-core-file-l2-1-0");
107 System.loadLibrary(
"api-ms-win-core-handle-l1-1-0");
108 System.loadLibrary(
"api-ms-win-core-heap-l1-1-0");
109 System.loadLibrary(
"api-ms-win-core-interlocked-l1-1-0");
110 System.loadLibrary(
"api-ms-win-core-libraryloader-l1-1-0");
111 System.loadLibrary(
"api-ms-win-core-localization-l1-2-0");
112 System.loadLibrary(
"api-ms-win-core-memory-l1-1-0");
113 System.loadLibrary(
"api-ms-win-core-namedpipe-l1-1-0");
114 System.loadLibrary(
"api-ms-win-core-processenvironment-l1-1-0");
115 System.loadLibrary(
"api-ms-win-core-processthreads-l1-1-0");
116 System.loadLibrary(
"api-ms-win-core-processthreads-l1-1-1");
117 System.loadLibrary(
"api-ms-win-core-profile-l1-1-0");
118 System.loadLibrary(
"api-ms-win-core-rtlsupport-l1-1-0");
119 System.loadLibrary(
"api-ms-win-core-string-l1-1-0");
120 System.loadLibrary(
"api-ms-win-core-synch-l1-1-0");
121 System.loadLibrary(
"api-ms-win-core-synch-l1-2-0");
122 System.loadLibrary(
"api-ms-win-core-sysinfo-l1-1-0");
123 System.loadLibrary(
"api-ms-win-core-timezone-l1-1-0");
124 System.loadLibrary(
"api-ms-win-core-util-l1-1-0");
125 System.loadLibrary(
"api-ms-win-crt-conio-l1-1-0");
126 System.loadLibrary(
"api-ms-win-crt-convert-l1-1-0");
127 System.loadLibrary(
"api-ms-win-crt-environment-l1-1-0");
128 System.loadLibrary(
"api-ms-win-crt-filesystem-l1-1-0");
129 System.loadLibrary(
"api-ms-win-crt-heap-l1-1-0");
130 System.loadLibrary(
"api-ms-win-crt-locale-l1-1-0");
131 System.loadLibrary(
"api-ms-win-crt-math-l1-1-0");
132 System.loadLibrary(
"api-ms-win-crt-multibyte-l1-1-0");
133 System.loadLibrary(
"api-ms-win-crt-private-l1-1-0");
134 System.loadLibrary(
"api-ms-win-crt-process-l1-1-0");
135 System.loadLibrary(
"api-ms-win-crt-runtime-l1-1-0");
136 System.loadLibrary(
"api-ms-win-crt-stdio-l1-1-0");
137 System.loadLibrary(
"api-ms-win-crt-string-l1-1-0");
138 System.loadLibrary(
"api-ms-win-crt-time-l1-1-0");
139 System.loadLibrary(
"api-ms-win-crt-utility-l1-1-0");
141 System.loadLibrary(
"ucrtbase");
142 System.loadLibrary(
"vcruntime140");
143 System.loadLibrary(
"msvcp140");
145 logger.log(Level.INFO,
"Visual C Runtime libraries loaded");
146 }
catch (UnsatisfiedLinkError e) {
147 logger.log(Level.SEVERE,
"Error loading Visual C Runtime libraries, ", e);
151 System.loadLibrary(
"zlib");
152 logger.log(Level.INFO,
"ZLIB library loaded loaded");
153 }
catch (UnsatisfiedLinkError e) {
154 logger.log(Level.SEVERE,
"Error loading ZLIB library, ", e);
158 System.loadLibrary(
"libewf");
159 logger.log(Level.INFO,
"EWF library loaded");
160 }
catch (UnsatisfiedLinkError e) {
161 logger.log(Level.SEVERE,
"Error loading EWF library, ", e);
165 System.loadLibrary(
"libvmdk");
166 logger.log(Level.INFO,
"VMDK library loaded");
167 }
catch (UnsatisfiedLinkError e) {
168 logger.log(Level.SEVERE,
"Error loading VMDK library, ", e);
172 System.loadLibrary(
"libvhdi");
173 logger.log(Level.INFO,
"VHDI library loaded");
174 }
catch (UnsatisfiedLinkError e) {
175 logger.log(Level.SEVERE,
"Error loading VHDI library, ", e);
179 if(System.getProperty(
"sun.arch.data.model").contains(
"64")) {
182 System.loadLibrary(
"libcrypto-1_1-x64");
183 logger.log(Level.INFO,
"Crypto library loaded");
184 }
catch (UnsatisfiedLinkError e) {
185 logger.log(Level.SEVERE,
"Error loading Crypto library, ", e);
189 System.loadLibrary(
"libssl-1_1-x64");
190 logger.log(Level.INFO,
"OpenSSL library loaded");
191 }
catch (UnsatisfiedLinkError e) {
192 logger.log(Level.SEVERE,
"Error loading OpenSSL library, ", e);
199 logger.log(Level.INFO,
"core installer created");
203 System.setProperty(
"sun.java2d.dpiaware",
"false");
204 System.setProperty(
"prism.allowhidpi",
"false");
210 packageInstallers =
new ArrayList<>();
233 logger.log(Level.SEVERE,
"Failed to load file type detector.", ex);
244 int ordinal = Integer.parseInt(mode);
264 System.setProperty(
"javafx.macosx.embedded",
"true");
267 JFXPanel panel =
new JFXPanel();
268 Platform.setImplicitExit(
false);
270 }
catch (UnsatisfiedLinkError | NoClassDefFoundError | Exception e) {
272 final String msg = NbBundle.getMessage(
Installer.class,
"Installer.errorInitJavafx.msg");
273 final String details = NbBundle.getMessage(
Installer.class,
"Installer.errorInitJavafx.details");
274 logger.log(Level.SEVERE, msg
277 WindowManager.getDefault().invokeWhenUIReady(
new Runnable() {
292 if (System.getProperty(
"jna.nosys") == null) {
293 System.setProperty(
"jna.nosys",
"true");
296 Path gstreamerPath = InstalledFileLocator.getDefault().locate(
"gstreamer",
Installer.class.getPackage().getName(),
false).toPath();
298 if (gstreamerPath == null) {
299 logger.log(Level.SEVERE,
"Failed to find GStreamer.");
301 String arch =
"x86_64";
306 Path gstreamerBasePath = Paths.get(gstreamerPath.toString(),
"1.0", arch);
307 Path gstreamerBinPath = Paths.get(gstreamerBasePath.toString(),
"bin");
308 Path gstreamerLibPath = Paths.get(gstreamerBasePath.toString(),
"lib",
"gstreamer-1.0");
312 Kernel32 k32 = Kernel32.INSTANCE;
313 String path = System.getenv(
"PATH");
314 if (StringUtils.isBlank(path)) {
315 k32.SetEnvironmentVariable(
"PATH", gstreamerLibPath.toString());
322 k32.SetEnvironmentVariable(
"PATH", gstreamerBinPath.toString() + File.pathSeparator + gstreamerLibPath.toString() + path);
333 objectDetectionClassifierDir.mkdir();
342 pythonModulesDir.mkdir();
351 boolean createDirectory = ocrLanguagePacksDir.mkdir();
355 if (createDirectory) {
356 File tessdataDir = InstalledFileLocator.getDefault().locate(
357 "Tesseract-OCR/tessdata",
Installer.class.getPackage().getName(),
false);
359 FileUtils.copyDirectory(tessdataDir, ocrLanguagePacksDir);
360 }
catch (IOException ex) {
361 logger.log(Level.SEVERE,
"Copying over default language packs for Tesseract failed.", ex);
374 for (ModuleInstall mi : packageInstallers) {
377 logger.log(Level.INFO,
"{0} restore succeeded", mi.getClass().getName());
378 }
catch (Exception e) {
379 String msg = mi.getClass().getName() +
" restore failed";
380 logger.log(Level.WARNING, msg, e);
383 logger.log(Level.INFO,
"Autopsy Core restore completed");
395 SevenZip.initSevenZipFromPlatformJAR();
396 logger.log(Level.INFO,
"7zip-java bindings loaded");
397 }
catch (SevenZipNativeInitializationException e) {
398 logger.log(Level.SEVERE,
"Error loading 7zip-java bindings", e);
406 Runnable loader = () -> {
411 }
catch (Exception ex) {
414 logger.log(Level.SEVERE,
"There was an error while doing an initial load of python plugins.", ex);
418 new Thread(loader).start();
425 Runnable loader = () -> {
428 }
catch (Exception ex) {
431 logger.log(Level.SEVERE,
"There was an error while doing an initial load of translation services.", ex);
434 new Thread(loader).start();
438 public void validate() throws IllegalStateException {
441 logger.log(Level.INFO,
"validate()");
442 for (ModuleInstall mi : packageInstallers) {
443 logger.log(Level.INFO,
"{0} validate()", mi.getClass().getName());
446 }
catch (IllegalStateException e) {
447 logger.log(Level.WARNING,
"", e);
456 logger.log(Level.INFO,
"uninstalled()");
458 for (ModuleInstall mi : packageInstallers) {
459 logger.log(Level.INFO,
"{0} uninstalled()", mi.getClass().getName());
462 }
catch (Exception e) {
463 logger.log(Level.WARNING,
"", e);
469 "Installer.closing.confirmationDialog.title=Ingest is Running",
470 "Installer.closing.confirmationDialog.message=Ingest is running, are you sure you want to exit?",
471 "# {0} - exception message",
"Installer.closing.messageBox.caseCloseExceptionMessage=Error closing case: {0}"
476 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
477 FutureTask<Void> future =
new FutureTask<>(
new Callable<Void>() {
479 public Void call()
throws Exception {
484 Thread thread =
new Thread(future);
488 }
catch (InterruptedException ex) {
489 logger.log(Level.SEVERE,
"Unexpected interrupt closing the current case", ex);
490 }
catch (ExecutionException ex) {
491 logger.log(Level.SEVERE,
"Error closing the current case", ex);
494 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
506 logger.log(Level.INFO,
"close()");
513 for (ModuleInstall mi : packageInstallers) {
514 logger.log(Level.INFO,
"{0} close()", mi.getClass().getName());
517 }
catch (Exception e) {
518 logger.log(Level.WARNING,
"", e);
521 for (Handler h : logger.getHandlers()) {
static void loadDynLibraries()
static synchronized String getConfigSetting(String moduleName, String settingName)
static final long serialVersionUID
static void initializeSevenZip()
static boolean isJavaFxInited()
static synchronized List< IngestModuleFactory > getIngestModuleFactories()
static void preloadTranslationServices()
static void closeCurrentCase()
static synchronized Installer getDefault()
static boolean checkAndConfirmProceed(String optionsDlgTitle, String optionsDlgMessage)
static void setMode(SelectedMode mode)
static final Logger logger
static final String SETTINGS_PROPERTIES
static synchronized Installer getDefault()
static synchronized Installer getDefault()
static TextTranslationService getInstance()
static synchronized List< GeneralReportModule > getGeneralReportModules()
static boolean openCvIsLoaded()
static synchronized void setConfigSetting(String moduleName, String settingName, String settingVal)
static volatile boolean javaFxInit
static synchronized Installer getDefault()
static synchronized Installer getDefault()
static void ensureOcrLanguagePacksFolderExists()
static void addGstreamerPathsToEnv()
static void ensurePythonModulesFolderExists()
static void preloadJython()
static synchronized Installer getDefault()
static void error(String title, String message)
synchronized static Logger getLogger(String name)
final List< ModuleInstall > packageInstallers
static synchronized Installer getDefault()
static synchronized Installer getDefault()
static synchronized List< DataSourceProcessor > getDataSourceProcessorModules()
static void ensureClassifierFolderExists()
static synchronized Installer getDefault()
static void error(String message)