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 net.sf.sevenzipjbinding.SevenZip;
37 import net.sf.sevenzipjbinding.SevenZipNativeInitializationException;
38 import org.apache.commons.io.FileUtils;
39 import org.apache.commons.lang3.StringUtils;
40 import org.openide.modules.InstalledFileLocator;
41 import org.openide.modules.ModuleInstall;
42 import org.openide.util.NbBundle;
43 import org.openide.windows.WindowManager;
90 System.loadLibrary(
"api-ms-win-core-console-l1-1-0");
91 System.loadLibrary(
"api-ms-win-core-datetime-l1-1-0");
92 System.loadLibrary(
"api-ms-win-core-debug-l1-1-0");
93 System.loadLibrary(
"api-ms-win-core-errorhandling-l1-1-0");
94 System.loadLibrary(
"api-ms-win-core-file-l1-1-0");
95 System.loadLibrary(
"api-ms-win-core-file-l1-2-0");
96 System.loadLibrary(
"api-ms-win-core-file-l2-1-0");
97 System.loadLibrary(
"api-ms-win-core-handle-l1-1-0");
98 System.loadLibrary(
"api-ms-win-core-heap-l1-1-0");
99 System.loadLibrary(
"api-ms-win-core-interlocked-l1-1-0");
100 System.loadLibrary(
"api-ms-win-core-libraryloader-l1-1-0");
101 System.loadLibrary(
"api-ms-win-core-localization-l1-2-0");
102 System.loadLibrary(
"api-ms-win-core-memory-l1-1-0");
103 System.loadLibrary(
"api-ms-win-core-namedpipe-l1-1-0");
104 System.loadLibrary(
"api-ms-win-core-processenvironment-l1-1-0");
105 System.loadLibrary(
"api-ms-win-core-processthreads-l1-1-0");
106 System.loadLibrary(
"api-ms-win-core-processthreads-l1-1-1");
107 System.loadLibrary(
"api-ms-win-core-profile-l1-1-0");
108 System.loadLibrary(
"api-ms-win-core-rtlsupport-l1-1-0");
109 System.loadLibrary(
"api-ms-win-core-string-l1-1-0");
110 System.loadLibrary(
"api-ms-win-core-synch-l1-1-0");
111 System.loadLibrary(
"api-ms-win-core-synch-l1-2-0");
112 System.loadLibrary(
"api-ms-win-core-sysinfo-l1-1-0");
113 System.loadLibrary(
"api-ms-win-core-timezone-l1-1-0");
114 System.loadLibrary(
"api-ms-win-core-util-l1-1-0");
115 System.loadLibrary(
"api-ms-win-crt-conio-l1-1-0");
116 System.loadLibrary(
"api-ms-win-crt-convert-l1-1-0");
117 System.loadLibrary(
"api-ms-win-crt-environment-l1-1-0");
118 System.loadLibrary(
"api-ms-win-crt-filesystem-l1-1-0");
119 System.loadLibrary(
"api-ms-win-crt-heap-l1-1-0");
120 System.loadLibrary(
"api-ms-win-crt-locale-l1-1-0");
121 System.loadLibrary(
"api-ms-win-crt-math-l1-1-0");
122 System.loadLibrary(
"api-ms-win-crt-multibyte-l1-1-0");
123 System.loadLibrary(
"api-ms-win-crt-private-l1-1-0");
124 System.loadLibrary(
"api-ms-win-crt-process-l1-1-0");
125 System.loadLibrary(
"api-ms-win-crt-runtime-l1-1-0");
126 System.loadLibrary(
"api-ms-win-crt-stdio-l1-1-0");
127 System.loadLibrary(
"api-ms-win-crt-string-l1-1-0");
128 System.loadLibrary(
"api-ms-win-crt-time-l1-1-0");
129 System.loadLibrary(
"api-ms-win-crt-utility-l1-1-0");
131 System.loadLibrary(
"ucrtbase");
132 System.loadLibrary(
"vcruntime140");
133 System.loadLibrary(
"msvcp140");
135 logger.log(Level.INFO,
"Visual C Runtime libraries loaded");
136 }
catch (UnsatisfiedLinkError e) {
137 logger.log(Level.SEVERE,
"Error loading Visual C Runtime libraries, ", e);
141 System.loadLibrary(
"zlib");
142 logger.log(Level.INFO,
"ZLIB library loaded loaded");
143 }
catch (UnsatisfiedLinkError e) {
144 logger.log(Level.SEVERE,
"Error loading ZLIB library, ", e);
148 System.loadLibrary(
"libewf");
149 logger.log(Level.INFO,
"EWF library loaded");
150 }
catch (UnsatisfiedLinkError e) {
151 logger.log(Level.SEVERE,
"Error loading EWF library, ", e);
155 System.loadLibrary(
"libvmdk");
156 logger.log(Level.INFO,
"VMDK library loaded");
157 }
catch (UnsatisfiedLinkError e) {
158 logger.log(Level.SEVERE,
"Error loading VMDK library, ", e);
162 System.loadLibrary(
"libvhdi");
163 logger.log(Level.INFO,
"VHDI library loaded");
164 }
catch (UnsatisfiedLinkError e) {
165 logger.log(Level.SEVERE,
"Error loading VHDI library, ", e);
169 if(System.getProperty(
"sun.arch.data.model").contains(
"64")) {
172 System.loadLibrary(
"libcrypto-1_1-x64");
173 logger.log(Level.INFO,
"Crypto library loaded");
174 }
catch (UnsatisfiedLinkError e) {
175 logger.log(Level.SEVERE,
"Error loading Crypto library, ", e);
179 System.loadLibrary(
"libssl-1_1-x64");
180 logger.log(Level.INFO,
"OpenSSL library loaded");
181 }
catch (UnsatisfiedLinkError e) {
182 logger.log(Level.SEVERE,
"Error loading OpenSSL library, ", e);
189 logger.log(Level.INFO,
"core installer created");
193 System.setProperty(
"sun.java2d.dpiaware",
"false");
194 System.setProperty(
"prism.allowhidpi",
"false");
199 packageInstallers =
new ArrayList<>();
220 logger.log(Level.SEVERE,
"Failed to load file type detector.", ex);
231 int ordinal = Integer.parseInt(mode);
251 System.setProperty(
"javafx.macosx.embedded",
"true");
254 JFXPanel panel =
new JFXPanel();
255 Platform.setImplicitExit(
false);
257 }
catch (UnsatisfiedLinkError | NoClassDefFoundError | Exception e) {
259 final String msg = NbBundle.getMessage(
Installer.class,
"Installer.errorInitJavafx.msg");
260 final String details = NbBundle.getMessage(
Installer.class,
"Installer.errorInitJavafx.details");
261 logger.log(Level.SEVERE, msg
264 WindowManager.getDefault().invokeWhenUIReady(
new Runnable() {
279 if (System.getProperty(
"jna.nosys") == null) {
280 System.setProperty(
"jna.nosys",
"true");
283 Path gstreamerPath = InstalledFileLocator.getDefault().locate(
"gstreamer",
Installer.class.getPackage().getName(),
false).toPath();
285 if (gstreamerPath == null) {
286 logger.log(Level.SEVERE,
"Failed to find GStreamer.");
288 String arch =
"x86_64";
293 Path gstreamerBasePath = Paths.get(gstreamerPath.toString(),
"1.0", arch);
294 Path gstreamerBinPath = Paths.get(gstreamerBasePath.toString(),
"bin");
295 Path gstreamerLibPath = Paths.get(gstreamerBasePath.toString(),
"lib",
"gstreamer-1.0");
299 Kernel32 k32 = Kernel32.INSTANCE;
300 String path = System.getenv(
"PATH");
301 if (StringUtils.isBlank(path)) {
302 k32.SetEnvironmentVariable(
"PATH", gstreamerLibPath.toString());
309 k32.SetEnvironmentVariable(
"PATH", gstreamerBinPath.toString() + File.pathSeparator + gstreamerLibPath.toString() + path);
320 objectDetectionClassifierDir.mkdir();
329 pythonModulesDir.mkdir();
338 boolean createDirectory = ocrLanguagePacksDir.mkdir();
342 if (createDirectory) {
343 File tessdataDir = InstalledFileLocator.getDefault().locate(
344 "Tesseract-OCR/tessdata",
Installer.class.getPackage().getName(),
false);
346 FileUtils.copyDirectory(tessdataDir, ocrLanguagePacksDir);
347 }
catch (IOException ex) {
348 logger.log(Level.SEVERE,
"Copying over default language packs for Tesseract failed.", ex);
361 for (ModuleInstall mi : packageInstallers) {
364 logger.log(Level.INFO,
"{0} restore succeeded", mi.getClass().getName());
365 }
catch (Exception e) {
366 String msg = mi.getClass().getName() +
" restore failed";
367 logger.log(Level.WARNING, msg, e);
370 logger.log(Level.INFO,
"Autopsy Core restore completed");
381 SevenZip.initSevenZipFromPlatformJAR();
382 logger.log(Level.INFO,
"7zip-java bindings loaded");
383 }
catch (SevenZipNativeInitializationException e) {
384 logger.log(Level.SEVERE,
"Error loading 7zip-java bindings", e);
392 Runnable loader = () -> {
396 }
catch (Exception ex) {
399 logger.log(Level.SEVERE,
"There was an error while doing an initial load of python plugins.", ex);
403 new Thread(loader).start();
407 public void validate() throws IllegalStateException {
410 logger.log(Level.INFO,
"validate()");
411 for (ModuleInstall mi : packageInstallers) {
412 logger.log(Level.INFO,
"{0} validate()", mi.getClass().getName());
415 }
catch (IllegalStateException e) {
416 logger.log(Level.WARNING,
"", e);
425 logger.log(Level.INFO,
"uninstalled()");
427 for (ModuleInstall mi : packageInstallers) {
428 logger.log(Level.INFO,
"{0} uninstalled()", mi.getClass().getName());
431 }
catch (Exception e) {
432 logger.log(Level.WARNING,
"", e);
438 "Installer.closing.confirmationDialog.title=Ingest is Running",
439 "Installer.closing.confirmationDialog.message=Ingest is running, are you sure you want to exit?",
440 "# {0} - exception message",
"Installer.closing.messageBox.caseCloseExceptionMessage=Error closing case: {0}"
445 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
446 FutureTask<Void> future =
new FutureTask<>(
new Callable<Void>() {
448 public Void call()
throws Exception {
453 Thread thread =
new Thread(future);
457 }
catch (InterruptedException ex) {
458 logger.log(Level.SEVERE,
"Unexpected interrupt closing the current case", ex);
459 }
catch (ExecutionException ex) {
460 logger.log(Level.SEVERE,
"Error closing the current case", ex);
463 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
475 logger.log(Level.INFO,
"close()");
482 for (ModuleInstall mi : packageInstallers) {
483 logger.log(Level.INFO,
"{0} close()", mi.getClass().getName());
486 }
catch (Exception e) {
487 logger.log(Level.WARNING,
"", e);
490 for (Handler h : logger.getHandlers()) {
static void loadDynLibraries()
static synchronized String getConfigSetting(String moduleName, String settingName)
static final long serialVersionUID
static boolean isJavaFxInited()
static synchronized List< IngestModuleFactory > getIngestModuleFactories()
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 synchronized List< GeneralReportModule > getGeneralReportModules()
static synchronized void setConfigSetting(String moduleName, String settingName, String settingVal)
static volatile boolean javaFxInit
void initializeSevenZip()
static synchronized Installer getDefault()
static synchronized Installer getDefault()
static void ensureOcrLanguagePacksFolderExists()
static void addGstreamerPathsToEnv()
static void ensurePythonModulesFolderExists()
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)