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");
209 packageInstallers =
new ArrayList<>();
230 logger.log(Level.SEVERE,
"Failed to load file type detector.", ex);
241 int ordinal = Integer.parseInt(mode);
261 System.setProperty(
"javafx.macosx.embedded",
"true");
264 JFXPanel panel =
new JFXPanel();
265 Platform.setImplicitExit(
false);
267 }
catch (UnsatisfiedLinkError | NoClassDefFoundError | Exception e) {
269 final String msg = NbBundle.getMessage(
Installer.class,
"Installer.errorInitJavafx.msg");
270 final String details = NbBundle.getMessage(
Installer.class,
"Installer.errorInitJavafx.details");
271 logger.log(Level.SEVERE, msg
274 WindowManager.getDefault().invokeWhenUIReady(
new Runnable() {
289 if (System.getProperty(
"jna.nosys") == null) {
290 System.setProperty(
"jna.nosys",
"true");
293 Path gstreamerPath = InstalledFileLocator.getDefault().locate(
"gstreamer",
Installer.class.getPackage().getName(),
false).toPath();
295 if (gstreamerPath == null) {
296 logger.log(Level.SEVERE,
"Failed to find GStreamer.");
298 String arch =
"x86_64";
303 Path gstreamerBasePath = Paths.get(gstreamerPath.toString(),
"1.0", arch);
304 Path gstreamerBinPath = Paths.get(gstreamerBasePath.toString(),
"bin");
305 Path gstreamerLibPath = Paths.get(gstreamerBasePath.toString(),
"lib",
"gstreamer-1.0");
309 Kernel32 k32 = Kernel32.INSTANCE;
310 String path = System.getenv(
"PATH");
311 if (StringUtils.isBlank(path)) {
312 k32.SetEnvironmentVariable(
"PATH", gstreamerLibPath.toString());
319 k32.SetEnvironmentVariable(
"PATH", gstreamerBinPath.toString() + File.pathSeparator + gstreamerLibPath.toString() + path);
330 objectDetectionClassifierDir.mkdir();
339 pythonModulesDir.mkdir();
348 boolean createDirectory = ocrLanguagePacksDir.mkdir();
352 if (createDirectory) {
353 File tessdataDir = InstalledFileLocator.getDefault().locate(
354 "Tesseract-OCR/tessdata",
Installer.class.getPackage().getName(),
false);
356 FileUtils.copyDirectory(tessdataDir, ocrLanguagePacksDir);
357 }
catch (IOException ex) {
358 logger.log(Level.SEVERE,
"Copying over default language packs for Tesseract failed.", ex);
371 for (ModuleInstall mi : packageInstallers) {
374 logger.log(Level.INFO,
"{0} restore succeeded", mi.getClass().getName());
375 }
catch (Exception e) {
376 String msg = mi.getClass().getName() +
" restore failed";
377 logger.log(Level.WARNING, msg, e);
380 logger.log(Level.INFO,
"Autopsy Core restore completed");
392 SevenZip.initSevenZipFromPlatformJAR();
393 logger.log(Level.INFO,
"7zip-java bindings loaded");
394 }
catch (SevenZipNativeInitializationException e) {
395 logger.log(Level.SEVERE,
"Error loading 7zip-java bindings", e);
403 Runnable loader = () -> {
407 }
catch (Exception ex) {
410 logger.log(Level.SEVERE,
"There was an error while doing an initial load of python plugins.", ex);
414 new Thread(loader).start();
421 Runnable loader = () -> {
424 }
catch (Exception ex) {
427 logger.log(Level.SEVERE,
"There was an error while doing an initial load of translation services.", ex);
430 new Thread(loader).start();
434 public void validate() throws IllegalStateException {
437 logger.log(Level.INFO,
"validate()");
438 for (ModuleInstall mi : packageInstallers) {
439 logger.log(Level.INFO,
"{0} validate()", mi.getClass().getName());
442 }
catch (IllegalStateException e) {
443 logger.log(Level.WARNING,
"", e);
452 logger.log(Level.INFO,
"uninstalled()");
454 for (ModuleInstall mi : packageInstallers) {
455 logger.log(Level.INFO,
"{0} uninstalled()", mi.getClass().getName());
458 }
catch (Exception e) {
459 logger.log(Level.WARNING,
"", e);
465 "Installer.closing.confirmationDialog.title=Ingest is Running",
466 "Installer.closing.confirmationDialog.message=Ingest is running, are you sure you want to exit?",
467 "# {0} - exception message",
"Installer.closing.messageBox.caseCloseExceptionMessage=Error closing case: {0}"
472 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
473 FutureTask<Void> future =
new FutureTask<>(
new Callable<Void>() {
475 public Void call()
throws Exception {
480 Thread thread =
new Thread(future);
484 }
catch (InterruptedException ex) {
485 logger.log(Level.SEVERE,
"Unexpected interrupt closing the current case", ex);
486 }
catch (ExecutionException ex) {
487 logger.log(Level.SEVERE,
"Error closing the current case", ex);
490 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
502 logger.log(Level.INFO,
"close()");
509 for (ModuleInstall mi : packageInstallers) {
510 logger.log(Level.INFO,
"{0} close()", mi.getClass().getName());
513 }
catch (Exception e) {
514 logger.log(Level.WARNING,
"", e);
517 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 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 void ensureClassifierFolderExists()
static synchronized Installer getDefault()
static void error(String message)