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;
88 System.loadLibrary(
"api-ms-win-core-console-l1-1-0");
89 System.loadLibrary(
"api-ms-win-core-datetime-l1-1-0");
90 System.loadLibrary(
"api-ms-win-core-debug-l1-1-0");
91 System.loadLibrary(
"api-ms-win-core-errorhandling-l1-1-0");
92 System.loadLibrary(
"api-ms-win-core-file-l1-1-0");
93 System.loadLibrary(
"api-ms-win-core-file-l1-2-0");
94 System.loadLibrary(
"api-ms-win-core-file-l2-1-0");
95 System.loadLibrary(
"api-ms-win-core-handle-l1-1-0");
96 System.loadLibrary(
"api-ms-win-core-heap-l1-1-0");
97 System.loadLibrary(
"api-ms-win-core-interlocked-l1-1-0");
98 System.loadLibrary(
"api-ms-win-core-libraryloader-l1-1-0");
99 System.loadLibrary(
"api-ms-win-core-localization-l1-2-0");
100 System.loadLibrary(
"api-ms-win-core-memory-l1-1-0");
101 System.loadLibrary(
"api-ms-win-core-namedpipe-l1-1-0");
102 System.loadLibrary(
"api-ms-win-core-processenvironment-l1-1-0");
103 System.loadLibrary(
"api-ms-win-core-processthreads-l1-1-0");
104 System.loadLibrary(
"api-ms-win-core-processthreads-l1-1-1");
105 System.loadLibrary(
"api-ms-win-core-profile-l1-1-0");
106 System.loadLibrary(
"api-ms-win-core-rtlsupport-l1-1-0");
107 System.loadLibrary(
"api-ms-win-core-string-l1-1-0");
108 System.loadLibrary(
"api-ms-win-core-synch-l1-1-0");
109 System.loadLibrary(
"api-ms-win-core-synch-l1-2-0");
110 System.loadLibrary(
"api-ms-win-core-sysinfo-l1-1-0");
111 System.loadLibrary(
"api-ms-win-core-timezone-l1-1-0");
112 System.loadLibrary(
"api-ms-win-core-util-l1-1-0");
113 System.loadLibrary(
"api-ms-win-crt-conio-l1-1-0");
114 System.loadLibrary(
"api-ms-win-crt-convert-l1-1-0");
115 System.loadLibrary(
"api-ms-win-crt-environment-l1-1-0");
116 System.loadLibrary(
"api-ms-win-crt-filesystem-l1-1-0");
117 System.loadLibrary(
"api-ms-win-crt-heap-l1-1-0");
118 System.loadLibrary(
"api-ms-win-crt-locale-l1-1-0");
119 System.loadLibrary(
"api-ms-win-crt-math-l1-1-0");
120 System.loadLibrary(
"api-ms-win-crt-multibyte-l1-1-0");
121 System.loadLibrary(
"api-ms-win-crt-private-l1-1-0");
122 System.loadLibrary(
"api-ms-win-crt-process-l1-1-0");
123 System.loadLibrary(
"api-ms-win-crt-runtime-l1-1-0");
124 System.loadLibrary(
"api-ms-win-crt-stdio-l1-1-0");
125 System.loadLibrary(
"api-ms-win-crt-string-l1-1-0");
126 System.loadLibrary(
"api-ms-win-crt-time-l1-1-0");
127 System.loadLibrary(
"api-ms-win-crt-utility-l1-1-0");
129 System.loadLibrary(
"ucrtbase");
130 System.loadLibrary(
"vcruntime140");
131 System.loadLibrary(
"msvcp140");
133 logger.log(Level.INFO,
"Visual C Runtime libraries loaded");
134 }
catch (UnsatisfiedLinkError e) {
135 logger.log(Level.SEVERE,
"Error loading Visual C Runtime libraries, ", e);
139 System.loadLibrary(
"zlib");
140 logger.log(Level.INFO,
"ZLIB library loaded loaded");
141 }
catch (UnsatisfiedLinkError e) {
142 logger.log(Level.SEVERE,
"Error loading ZLIB library, ", e);
146 System.loadLibrary(
"libewf");
147 logger.log(Level.INFO,
"EWF library loaded");
148 }
catch (UnsatisfiedLinkError e) {
149 logger.log(Level.SEVERE,
"Error loading EWF library, ", e);
153 System.loadLibrary(
"libvmdk");
154 logger.log(Level.INFO,
"VMDK library loaded");
155 }
catch (UnsatisfiedLinkError e) {
156 logger.log(Level.SEVERE,
"Error loading VMDK library, ", e);
160 System.loadLibrary(
"libvhdi");
161 logger.log(Level.INFO,
"VHDI library loaded");
162 }
catch (UnsatisfiedLinkError e) {
163 logger.log(Level.SEVERE,
"Error loading VHDI library, ", e);
170 System.loadLibrary(
"msvcr120");
171 logger.log(Level.INFO,
"MSVCR 120 library loaded");
172 }
catch (UnsatisfiedLinkError e) {
173 logger.log(Level.SEVERE,
"Error loading MSVCR120 library, ", e);
177 System.loadLibrary(
"libeay32");
178 logger.log(Level.INFO,
"LIBEAY32 library loaded");
179 }
catch (UnsatisfiedLinkError e) {
180 logger.log(Level.SEVERE,
"Error loading LIBEAY32 library, ", e);
184 System.loadLibrary(
"ssleay32");
185 logger.log(Level.INFO,
"SSLEAY32 library loaded");
186 }
catch (UnsatisfiedLinkError e) {
187 logger.log(Level.SEVERE,
"Error loading SSLEAY32 library, ", e);
191 System.loadLibrary(
"libiconv-2");
192 logger.log(Level.INFO,
"libiconv-2 library loaded");
193 }
catch (UnsatisfiedLinkError e) {
194 logger.log(Level.SEVERE,
"Error loading libiconv-2 library, ", e);
198 System.loadLibrary(
"libintl-8");
199 logger.log(Level.INFO,
"libintl-8 library loaded");
200 }
catch (UnsatisfiedLinkError e) {
201 logger.log(Level.SEVERE,
"Error loading libintl-8 library, ", e);
205 System.loadLibrary(
"libpq");
206 logger.log(Level.INFO,
"LIBPQ library loaded");
207 }
catch (UnsatisfiedLinkError e) {
208 logger.log(Level.SEVERE,
"Error loading LIBPQ library, ", e);
214 logger.log(Level.INFO,
"core installer created");
218 System.setProperty(
"sun.java2d.dpiaware",
"false");
219 System.setProperty(
"prism.allowhidpi",
"false");
224 packageInstallers =
new ArrayList<>();
244 logger.log(Level.SEVERE,
"Failed to load file type detector.", ex);
255 int ordinal = Integer.parseInt(mode);
275 System.setProperty(
"javafx.macosx.embedded",
"true");
278 JFXPanel panel =
new JFXPanel();
279 Platform.setImplicitExit(
false);
281 }
catch (UnsatisfiedLinkError | NoClassDefFoundError | Exception e) {
283 final String msg = NbBundle.getMessage(
Installer.class,
"Installer.errorInitJavafx.msg");
284 final String details = NbBundle.getMessage(
Installer.class,
"Installer.errorInitJavafx.details");
285 logger.log(Level.SEVERE, msg
288 WindowManager.getDefault().invokeWhenUIReady(
new Runnable() {
303 if (System.getProperty(
"jna.nosys") == null) {
304 System.setProperty(
"jna.nosys",
"true");
307 Path gstreamerPath = InstalledFileLocator.getDefault().locate(
"gstreamer",
Installer.class.getPackage().getName(),
false).toPath();
309 if (gstreamerPath == null) {
310 logger.log(Level.SEVERE,
"Failed to find GStreamer.");
312 String arch =
"x86_64";
317 Path gstreamerBasePath = Paths.get(gstreamerPath.toString(),
"1.0", arch);
318 Path gstreamerBinPath = Paths.get(gstreamerBasePath.toString(),
"bin");
319 Path gstreamerLibPath = Paths.get(gstreamerBasePath.toString(),
"lib",
"gstreamer-1.0");
323 Kernel32 k32 = Kernel32.INSTANCE;
324 String path = System.getenv(
"PATH");
325 if (StringUtils.isBlank(path)) {
326 k32.SetEnvironmentVariable(
"PATH", gstreamerLibPath.toString());
333 k32.SetEnvironmentVariable(
"PATH", gstreamerBinPath.toString() + File.pathSeparator + gstreamerLibPath.toString() + path);
344 objectDetectionClassifierDir.mkdir();
353 pythonModulesDir.mkdir();
362 boolean createDirectory = ocrLanguagePacksDir.mkdir();
366 if (createDirectory) {
367 File tessdataDir = InstalledFileLocator.getDefault().locate(
368 "Tesseract-OCR/tessdata",
Installer.class.getPackage().getName(),
false);
370 FileUtils.copyDirectory(tessdataDir, ocrLanguagePacksDir);
371 }
catch (IOException ex) {
372 logger.log(Level.SEVERE,
"Copying over default language packs for Tesseract failed.", ex);
384 for (ModuleInstall mi : packageInstallers) {
387 logger.log(Level.INFO,
"{0} restore succeeded", mi.getClass().getName());
388 }
catch (Exception e) {
389 String msg = mi.getClass().getName() +
" restore failed";
390 logger.log(Level.WARNING, msg, e);
393 logger.log(Level.INFO,
"Autopsy Core restore completed");
402 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();
418 public void validate() throws IllegalStateException {
421 logger.log(Level.INFO,
"validate()");
422 for (ModuleInstall mi : packageInstallers) {
423 logger.log(Level.INFO,
"{0} validate()", mi.getClass().getName());
426 }
catch (IllegalStateException e) {
427 logger.log(Level.WARNING,
"", e);
436 logger.log(Level.INFO,
"uninstalled()");
438 for (ModuleInstall mi : packageInstallers) {
439 logger.log(Level.INFO,
"{0} uninstalled()", mi.getClass().getName());
442 }
catch (Exception e) {
443 logger.log(Level.WARNING,
"", e);
449 "Installer.closing.confirmationDialog.title=Ingest is Running",
450 "Installer.closing.confirmationDialog.message=Ingest is running, are you sure you want to exit?",
451 "# {0} - exception message",
"Installer.closing.messageBox.caseCloseExceptionMessage=Error closing case: {0}"
456 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
457 FutureTask<Void> future =
new FutureTask<>(
new Callable<Void>() {
459 public Void call()
throws Exception {
464 Thread thread =
new Thread(future);
468 }
catch (InterruptedException ex) {
469 logger.log(Level.SEVERE,
"Unexpected interrupt closing the current case", ex);
470 }
catch (ExecutionException ex) {
471 logger.log(Level.SEVERE,
"Error closing the current case", ex);
474 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
486 logger.log(Level.INFO,
"close()");
493 for (ModuleInstall mi : packageInstallers) {
494 logger.log(Level.INFO,
"{0} close()", mi.getClass().getName());
497 }
catch (Exception e) {
498 logger.log(Level.WARNING,
"", e);
501 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
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 void ensureClassifierFolderExists()
static synchronized Installer getDefault()
static void error(String message)