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");
268 String javaLibraryPath =
"java.library.path";
269 String jvmBinPathStr = Paths.get(System.getProperty(
"java.home"),
"bin").toAbsolutePath().toString();
270 String path = System.getProperty(javaLibraryPath);
271 System.setProperty(javaLibraryPath, StringUtils.isBlank(path) ? jvmBinPathStr : jvmBinPathStr + File.pathSeparator + path);
275 Platform.setImplicitExit(
false);
277 }
catch (UnsatisfiedLinkError | NoClassDefFoundError | Exception e) {
279 final String msg = NbBundle.getMessage(
Installer.class,
"Installer.errorInitJavafx.msg");
280 final String details = NbBundle.getMessage(
Installer.class,
"Installer.errorInitJavafx.details");
281 logger.log(Level.SEVERE, msg
284 WindowManager.getDefault().invokeWhenUIReady(
new Runnable() {
299 if (System.getProperty(
"jna.nosys") == null) {
300 System.setProperty(
"jna.nosys",
"true");
303 Path gstreamerPath = InstalledFileLocator.getDefault().locate(
"gstreamer",
Installer.class.getPackage().getName(),
false).toPath();
305 if (gstreamerPath == null) {
306 logger.log(Level.SEVERE,
"Failed to find GStreamer.");
308 String arch =
"x86_64";
313 Path gstreamerBasePath = Paths.get(gstreamerPath.toString(),
"1.0", arch);
314 Path gstreamerBinPath = Paths.get(gstreamerBasePath.toString(),
"bin");
315 Path gstreamerLibPath = Paths.get(gstreamerBasePath.toString(),
"lib",
"gstreamer-1.0");
319 Kernel32 k32 = Kernel32.INSTANCE;
320 String path = System.getenv(
"PATH");
321 if (StringUtils.isBlank(path)) {
322 k32.SetEnvironmentVariable(
"PATH", gstreamerLibPath.toString());
329 k32.SetEnvironmentVariable(
"PATH", gstreamerBinPath.toString() + File.pathSeparator + gstreamerLibPath.toString() + path);
340 objectDetectionClassifierDir.mkdir();
349 pythonModulesDir.mkdir();
358 boolean createDirectory = ocrLanguagePacksDir.mkdir();
362 if (createDirectory) {
363 File tessdataDir = InstalledFileLocator.getDefault().locate(
364 "Tesseract-OCR/tessdata",
Installer.class.getPackage().getName(),
false);
366 FileUtils.copyDirectory(tessdataDir, ocrLanguagePacksDir);
367 }
catch (IOException ex) {
368 logger.log(Level.SEVERE,
"Copying over default language packs for Tesseract failed.", ex);
381 for (ModuleInstall mi : packageInstallers) {
384 logger.log(Level.INFO,
"{0} restore succeeded", mi.getClass().getName());
385 }
catch (Exception e) {
386 String msg = mi.getClass().getName() +
" restore failed";
387 logger.log(Level.WARNING, msg, e);
390 logger.log(Level.INFO,
"Autopsy Core restore completed");
402 SevenZip.initSevenZipFromPlatformJAR();
403 logger.log(Level.INFO,
"7zip-java bindings loaded");
404 }
catch (SevenZipNativeInitializationException e) {
405 logger.log(Level.SEVERE,
"Error loading 7zip-java bindings", e);
413 Runnable loader = () -> {
418 }
catch (Exception ex) {
421 logger.log(Level.SEVERE,
"There was an error while doing an initial load of python plugins.", ex);
425 new Thread(loader).start();
432 Runnable loader = () -> {
435 }
catch (Exception ex) {
438 logger.log(Level.SEVERE,
"There was an error while doing an initial load of translation services.", ex);
441 new Thread(loader).start();
445 public void validate() throws IllegalStateException {
448 logger.log(Level.INFO,
"validate()");
449 for (ModuleInstall mi : packageInstallers) {
450 logger.log(Level.INFO,
"{0} validate()", mi.getClass().getName());
453 }
catch (IllegalStateException e) {
454 logger.log(Level.WARNING,
"", e);
463 logger.log(Level.INFO,
"uninstalled()");
465 for (ModuleInstall mi : packageInstallers) {
466 logger.log(Level.INFO,
"{0} uninstalled()", mi.getClass().getName());
469 }
catch (Exception e) {
470 logger.log(Level.WARNING,
"", e);
476 "Installer.closing.confirmationDialog.title=Ingest is Running",
477 "Installer.closing.confirmationDialog.message=Ingest is running, are you sure you want to exit?",
478 "# {0} - exception message",
"Installer.closing.messageBox.caseCloseExceptionMessage=Error closing case: {0}"
483 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
484 FutureTask<Void> future =
new FutureTask<>(
new Callable<Void>() {
486 public Void call()
throws Exception {
491 Thread thread =
new Thread(future);
495 }
catch (InterruptedException ex) {
496 logger.log(Level.SEVERE,
"Unexpected interrupt closing the current case", ex);
497 }
catch (ExecutionException ex) {
498 logger.log(Level.SEVERE,
"Error closing the current case", ex);
501 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
513 logger.log(Level.INFO,
"close()");
520 for (ModuleInstall mi : packageInstallers) {
521 logger.log(Level.INFO,
"{0} close()", mi.getClass().getName());
524 }
catch (Exception e) {
525 logger.log(Level.WARNING,
"", e);
528 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)