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 org.apache.commons.io.FileUtils;
37 import org.apache.commons.lang3.StringUtils;
38 import org.openide.modules.InstalledFileLocator;
39 import org.openide.modules.ModuleInstall;
40 import org.openide.util.NbBundle;
41 import org.openide.windows.WindowManager;
87 System.loadLibrary(
"api-ms-win-core-console-l1-1-0");
88 System.loadLibrary(
"api-ms-win-core-datetime-l1-1-0");
89 System.loadLibrary(
"api-ms-win-core-debug-l1-1-0");
90 System.loadLibrary(
"api-ms-win-core-errorhandling-l1-1-0");
91 System.loadLibrary(
"api-ms-win-core-file-l1-1-0");
92 System.loadLibrary(
"api-ms-win-core-file-l1-2-0");
93 System.loadLibrary(
"api-ms-win-core-file-l2-1-0");
94 System.loadLibrary(
"api-ms-win-core-handle-l1-1-0");
95 System.loadLibrary(
"api-ms-win-core-heap-l1-1-0");
96 System.loadLibrary(
"api-ms-win-core-interlocked-l1-1-0");
97 System.loadLibrary(
"api-ms-win-core-libraryloader-l1-1-0");
98 System.loadLibrary(
"api-ms-win-core-localization-l1-2-0");
99 System.loadLibrary(
"api-ms-win-core-memory-l1-1-0");
100 System.loadLibrary(
"api-ms-win-core-namedpipe-l1-1-0");
101 System.loadLibrary(
"api-ms-win-core-processenvironment-l1-1-0");
102 System.loadLibrary(
"api-ms-win-core-processthreads-l1-1-0");
103 System.loadLibrary(
"api-ms-win-core-processthreads-l1-1-1");
104 System.loadLibrary(
"api-ms-win-core-profile-l1-1-0");
105 System.loadLibrary(
"api-ms-win-core-rtlsupport-l1-1-0");
106 System.loadLibrary(
"api-ms-win-core-string-l1-1-0");
107 System.loadLibrary(
"api-ms-win-core-synch-l1-1-0");
108 System.loadLibrary(
"api-ms-win-core-synch-l1-2-0");
109 System.loadLibrary(
"api-ms-win-core-sysinfo-l1-1-0");
110 System.loadLibrary(
"api-ms-win-core-timezone-l1-1-0");
111 System.loadLibrary(
"api-ms-win-core-util-l1-1-0");
112 System.loadLibrary(
"api-ms-win-crt-conio-l1-1-0");
113 System.loadLibrary(
"api-ms-win-crt-convert-l1-1-0");
114 System.loadLibrary(
"api-ms-win-crt-environment-l1-1-0");
115 System.loadLibrary(
"api-ms-win-crt-filesystem-l1-1-0");
116 System.loadLibrary(
"api-ms-win-crt-heap-l1-1-0");
117 System.loadLibrary(
"api-ms-win-crt-locale-l1-1-0");
118 System.loadLibrary(
"api-ms-win-crt-math-l1-1-0");
119 System.loadLibrary(
"api-ms-win-crt-multibyte-l1-1-0");
120 System.loadLibrary(
"api-ms-win-crt-private-l1-1-0");
121 System.loadLibrary(
"api-ms-win-crt-process-l1-1-0");
122 System.loadLibrary(
"api-ms-win-crt-runtime-l1-1-0");
123 System.loadLibrary(
"api-ms-win-crt-stdio-l1-1-0");
124 System.loadLibrary(
"api-ms-win-crt-string-l1-1-0");
125 System.loadLibrary(
"api-ms-win-crt-time-l1-1-0");
126 System.loadLibrary(
"api-ms-win-crt-utility-l1-1-0");
128 System.loadLibrary(
"ucrtbase");
129 System.loadLibrary(
"vcruntime140");
130 System.loadLibrary(
"msvcp140");
132 logger.log(Level.INFO,
"Visual C Runtime libraries loaded");
133 }
catch (UnsatisfiedLinkError e) {
134 logger.log(Level.SEVERE,
"Error loading Visual C Runtime libraries, ", e);
138 System.loadLibrary(
"zlib");
139 logger.log(Level.INFO,
"ZLIB library loaded loaded");
140 }
catch (UnsatisfiedLinkError e) {
141 logger.log(Level.SEVERE,
"Error loading ZLIB library, ", e);
145 System.loadLibrary(
"libewf");
146 logger.log(Level.INFO,
"EWF library loaded");
147 }
catch (UnsatisfiedLinkError e) {
148 logger.log(Level.SEVERE,
"Error loading EWF library, ", e);
152 System.loadLibrary(
"libvmdk");
153 logger.log(Level.INFO,
"VMDK library loaded");
154 }
catch (UnsatisfiedLinkError e) {
155 logger.log(Level.SEVERE,
"Error loading VMDK library, ", e);
159 System.loadLibrary(
"libvhdi");
160 logger.log(Level.INFO,
"VHDI library loaded");
161 }
catch (UnsatisfiedLinkError e) {
162 logger.log(Level.SEVERE,
"Error loading VHDI library, ", e);
169 System.loadLibrary(
"msvcr120");
170 logger.log(Level.INFO,
"MSVCR 120 library loaded");
171 }
catch (UnsatisfiedLinkError e) {
172 logger.log(Level.SEVERE,
"Error loading MSVCR120 library, ", e);
176 System.loadLibrary(
"libeay32");
177 logger.log(Level.INFO,
"LIBEAY32 library loaded");
178 }
catch (UnsatisfiedLinkError e) {
179 logger.log(Level.SEVERE,
"Error loading LIBEAY32 library, ", e);
183 System.loadLibrary(
"ssleay32");
184 logger.log(Level.INFO,
"SSLEAY32 library loaded");
185 }
catch (UnsatisfiedLinkError e) {
186 logger.log(Level.SEVERE,
"Error loading SSLEAY32 library, ", e);
190 System.loadLibrary(
"libiconv-2");
191 logger.log(Level.INFO,
"libiconv-2 library loaded");
192 }
catch (UnsatisfiedLinkError e) {
193 logger.log(Level.SEVERE,
"Error loading libiconv-2 library, ", e);
197 System.loadLibrary(
"libintl-8");
198 logger.log(Level.INFO,
"libintl-8 library loaded");
199 }
catch (UnsatisfiedLinkError e) {
200 logger.log(Level.SEVERE,
"Error loading libintl-8 library, ", e);
204 System.loadLibrary(
"libpq");
205 logger.log(Level.INFO,
"LIBPQ library loaded");
206 }
catch (UnsatisfiedLinkError e) {
207 logger.log(Level.SEVERE,
"Error loading LIBPQ library, ", e);
213 logger.log(Level.INFO,
"core installer created");
217 System.setProperty(
"sun.java2d.dpiaware",
"false");
218 System.setProperty(
"prism.allowhidpi",
"false");
223 packageInstallers =
new ArrayList<>();
243 logger.log(Level.SEVERE,
"Failed to load file type detector.", ex);
254 int ordinal = Integer.parseInt(mode);
274 System.setProperty(
"javafx.macosx.embedded",
"true");
277 JFXPanel panel =
new JFXPanel();
278 Platform.setImplicitExit(
false);
280 }
catch (UnsatisfiedLinkError | NoClassDefFoundError | Exception e) {
282 final String msg = NbBundle.getMessage(
Installer.class,
"Installer.errorInitJavafx.msg");
283 final String details = NbBundle.getMessage(
Installer.class,
"Installer.errorInitJavafx.details");
284 logger.log(Level.SEVERE, msg
287 WindowManager.getDefault().invokeWhenUIReady(
new Runnable() {
302 if (System.getProperty(
"jna.nosys") == null) {
303 System.setProperty(
"jna.nosys",
"true");
306 Path gstreamerPath = InstalledFileLocator.getDefault().locate(
"gstreamer",
Installer.class.getPackage().getName(),
false).toPath();
308 if (gstreamerPath == null) {
309 logger.log(Level.SEVERE,
"Failed to find GStreamer.");
311 String arch =
"x86_64";
316 Path gstreamerBasePath = Paths.get(gstreamerPath.toString(),
"1.0", arch);
317 Path gstreamerBinPath = Paths.get(gstreamerBasePath.toString(),
"bin");
318 Path gstreamerLibPath = Paths.get(gstreamerBasePath.toString(),
"lib",
"gstreamer-1.0");
322 Kernel32 k32 = Kernel32.INSTANCE;
323 String path = System.getenv(
"PATH");
324 if (StringUtils.isBlank(path)) {
325 k32.SetEnvironmentVariable(
"PATH", gstreamerLibPath.toString());
332 k32.SetEnvironmentVariable(
"PATH", gstreamerBinPath.toString() + File.pathSeparator + gstreamerLibPath.toString() + path);
343 objectDetectionClassifierDir.mkdir();
352 pythonModulesDir.mkdir();
361 boolean createDirectory = ocrLanguagePacksDir.mkdir();
365 if (createDirectory) {
366 File tessdataDir = InstalledFileLocator.getDefault().locate(
367 "Tesseract-OCR/tessdata",
Installer.class.getPackage().getName(),
false);
369 FileUtils.copyDirectory(tessdataDir, ocrLanguagePacksDir);
370 }
catch (IOException ex) {
371 logger.log(Level.SEVERE,
"Copying over default language packs for Tesseract failed.", ex);
383 for (ModuleInstall mi : packageInstallers) {
386 logger.log(Level.INFO,
"{0} restore succeeded", mi.getClass().getName());
387 }
catch (Exception e) {
388 String msg = mi.getClass().getName() +
" restore failed";
389 logger.log(Level.WARNING, msg, e);
392 logger.log(Level.INFO,
"Autopsy Core restore completed");
396 public void validate() throws IllegalStateException {
399 logger.log(Level.INFO,
"validate()");
400 for (ModuleInstall mi : packageInstallers) {
401 logger.log(Level.INFO,
"{0} validate()", mi.getClass().getName());
404 }
catch (IllegalStateException e) {
405 logger.log(Level.WARNING,
"", e);
414 logger.log(Level.INFO,
"uninstalled()");
416 for (ModuleInstall mi : packageInstallers) {
417 logger.log(Level.INFO,
"{0} uninstalled()", mi.getClass().getName());
420 }
catch (Exception e) {
421 logger.log(Level.WARNING,
"", e);
427 "Installer.closing.confirmationDialog.title=Ingest is Running",
428 "Installer.closing.confirmationDialog.message=Ingest is running, are you sure you want to exit?",
429 "# {0} - exception message",
"Installer.closing.messageBox.caseCloseExceptionMessage=Error closing case: {0}"
434 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
435 FutureTask<Void> future =
new FutureTask<>(
new Callable<Void>() {
437 public Void call()
throws Exception {
442 Thread thread =
new Thread(future);
446 }
catch (InterruptedException ex) {
447 logger.log(Level.SEVERE,
"Unexpected interrupt closing the current case", ex);
448 }
catch (ExecutionException ex) {
449 logger.log(Level.SEVERE,
"Error closing the current case", ex);
452 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
464 logger.log(Level.INFO,
"close()");
471 for (ModuleInstall mi : packageInstallers) {
472 logger.log(Level.INFO,
"{0} close()", mi.getClass().getName());
475 }
catch (Exception e) {
476 logger.log(Level.WARNING,
"", e);
479 for (Handler h : logger.getHandlers()) {
static void loadDynLibraries()
static final long serialVersionUID
static boolean isJavaFxInited()
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 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 String getConfigSetting(String moduleName, String settingName)
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 void ensureClassifierFolderExists()
static synchronized Installer getDefault()
static void error(String message)