19 package org.sleuthkit.autopsy.core;
21 import com.sun.jna.platform.win32.Kernel32;
22 import java.awt.Cursor;
23 import java.awt.GraphicsEnvironment;
25 import java.io.IOException;
26 import java.lang.management.ManagementFactory;
27 import java.nio.file.Path;
28 import java.nio.file.Paths;
29 import java.util.ArrayList;
30 import java.util.List;
31 import java.util.concurrent.Callable;
32 import java.util.concurrent.ExecutionException;
33 import java.util.concurrent.FutureTask;
34 import java.util.logging.Handler;
35 import java.util.logging.Level;
36 import javafx.application.Platform;
37 import javafx.embed.swing.JFXPanel;
38 import javax.imageio.ImageIO;
39 import javax.swing.JOptionPane;
40 import net.sf.sevenzipjbinding.SevenZip;
41 import net.sf.sevenzipjbinding.SevenZipNativeInitializationException;
42 import org.apache.commons.io.FileUtils;
43 import org.apache.commons.lang3.StringUtils;
44 import org.openide.modules.InstalledFileLocator;
45 import org.openide.modules.ModuleInstall;
46 import org.openide.util.NbBundle;
47 import org.openide.util.NbBundle.Messages;
48 import org.openide.windows.WindowManager;
78 ImageIO.scanForPlugins();
104 System.loadLibrary(
"api-ms-win-core-console-l1-1-0");
105 System.loadLibrary(
"api-ms-win-core-datetime-l1-1-0");
106 System.loadLibrary(
"api-ms-win-core-debug-l1-1-0");
107 System.loadLibrary(
"api-ms-win-core-errorhandling-l1-1-0");
108 System.loadLibrary(
"api-ms-win-core-file-l1-1-0");
109 System.loadLibrary(
"api-ms-win-core-file-l1-2-0");
110 System.loadLibrary(
"api-ms-win-core-file-l2-1-0");
111 System.loadLibrary(
"api-ms-win-core-handle-l1-1-0");
112 System.loadLibrary(
"api-ms-win-core-heap-l1-1-0");
113 System.loadLibrary(
"api-ms-win-core-interlocked-l1-1-0");
114 System.loadLibrary(
"api-ms-win-core-libraryloader-l1-1-0");
115 System.loadLibrary(
"api-ms-win-core-localization-l1-2-0");
116 System.loadLibrary(
"api-ms-win-core-memory-l1-1-0");
117 System.loadLibrary(
"api-ms-win-core-namedpipe-l1-1-0");
118 System.loadLibrary(
"api-ms-win-core-processenvironment-l1-1-0");
119 System.loadLibrary(
"api-ms-win-core-processthreads-l1-1-0");
120 System.loadLibrary(
"api-ms-win-core-processthreads-l1-1-1");
121 System.loadLibrary(
"api-ms-win-core-profile-l1-1-0");
122 System.loadLibrary(
"api-ms-win-core-rtlsupport-l1-1-0");
123 System.loadLibrary(
"api-ms-win-core-string-l1-1-0");
124 System.loadLibrary(
"api-ms-win-core-synch-l1-1-0");
125 System.loadLibrary(
"api-ms-win-core-synch-l1-2-0");
126 System.loadLibrary(
"api-ms-win-core-sysinfo-l1-1-0");
127 System.loadLibrary(
"api-ms-win-core-timezone-l1-1-0");
128 System.loadLibrary(
"api-ms-win-core-util-l1-1-0");
129 System.loadLibrary(
"api-ms-win-crt-conio-l1-1-0");
130 System.loadLibrary(
"api-ms-win-crt-convert-l1-1-0");
131 System.loadLibrary(
"api-ms-win-crt-environment-l1-1-0");
132 System.loadLibrary(
"api-ms-win-crt-filesystem-l1-1-0");
133 System.loadLibrary(
"api-ms-win-crt-heap-l1-1-0");
134 System.loadLibrary(
"api-ms-win-crt-locale-l1-1-0");
135 System.loadLibrary(
"api-ms-win-crt-math-l1-1-0");
136 System.loadLibrary(
"api-ms-win-crt-multibyte-l1-1-0");
137 System.loadLibrary(
"api-ms-win-crt-private-l1-1-0");
138 System.loadLibrary(
"api-ms-win-crt-process-l1-1-0");
139 System.loadLibrary(
"api-ms-win-crt-runtime-l1-1-0");
140 System.loadLibrary(
"api-ms-win-crt-stdio-l1-1-0");
141 System.loadLibrary(
"api-ms-win-crt-string-l1-1-0");
142 System.loadLibrary(
"api-ms-win-crt-time-l1-1-0");
143 System.loadLibrary(
"api-ms-win-crt-utility-l1-1-0");
145 System.loadLibrary(
"ucrtbase");
146 System.loadLibrary(
"vcruntime140");
147 System.loadLibrary(
"msvcp140");
149 logger.log(Level.INFO,
"Visual C Runtime libraries loaded");
150 }
catch (UnsatisfiedLinkError e) {
151 logger.log(Level.SEVERE,
"Error loading Visual C Runtime libraries, ", e);
155 System.loadLibrary(
"zlib");
156 logger.log(Level.INFO,
"ZLIB library loaded loaded");
157 }
catch (UnsatisfiedLinkError e) {
158 logger.log(Level.SEVERE,
"Error loading ZLIB library, ", e);
162 System.loadLibrary(
"libewf");
163 logger.log(Level.INFO,
"EWF library loaded");
164 }
catch (UnsatisfiedLinkError e) {
165 logger.log(Level.SEVERE,
"Error loading EWF library, ", e);
169 System.loadLibrary(
"libvmdk");
170 logger.log(Level.INFO,
"VMDK library loaded");
171 }
catch (UnsatisfiedLinkError e) {
172 logger.log(Level.SEVERE,
"Error loading VMDK library, ", e);
176 System.loadLibrary(
"libvhdi");
177 logger.log(Level.INFO,
"VHDI library loaded");
178 }
catch (UnsatisfiedLinkError e) {
179 logger.log(Level.SEVERE,
"Error loading VHDI library, ", e);
183 if(System.getProperty(
"sun.arch.data.model").contains(
"64")) {
186 System.loadLibrary(
"libcrypto-1_1-x64");
187 logger.log(Level.INFO,
"Crypto library loaded");
188 }
catch (UnsatisfiedLinkError e) {
189 logger.log(Level.SEVERE,
"Error loading Crypto library, ", e);
193 System.loadLibrary(
"libssl-1_1-x64");
194 logger.log(Level.INFO,
"OpenSSL library loaded");
195 }
catch (UnsatisfiedLinkError e) {
196 logger.log(Level.SEVERE,
"Error loading OpenSSL library, ", e);
203 logger.log(Level.INFO,
"core installer created");
207 System.setProperty(
"sun.java2d.dpiaware",
"false");
208 System.setProperty(
"prism.allowhidpi",
"false");
214 packageInstallers =
new ArrayList<>();
237 logger.log(Level.SEVERE,
"Failed to load file type detector.", ex);
248 int ordinal = Integer.parseInt(mode);
268 System.setProperty(
"javafx.macosx.embedded",
"true");
272 String javaLibraryPath =
"java.library.path";
273 String jvmBinPathStr = Paths.get(System.getProperty(
"java.home"),
"bin").toAbsolutePath().toString();
274 String path = System.getProperty(javaLibraryPath);
275 System.setProperty(javaLibraryPath, StringUtils.isBlank(path) ? jvmBinPathStr : jvmBinPathStr + File.pathSeparator + path);
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);
386 for (ModuleInstall mi : packageInstallers) {
389 logger.log(Level.INFO,
"{0} restore succeeded", mi.getClass().getName());
390 }
catch (Exception e) {
391 String msg = mi.getClass().getName() +
" restore failed";
392 logger.log(Level.WARNING, msg, e);
395 logger.log(Level.INFO,
"Autopsy Core restore completed");
404 "# {0} - physicalMemory",
405 "Installer_checkMemoryAvailable_physicalRamExpected_desc=Physical memory: {0}, is less than the 8 GB required. Some aspects of the application may not work as expected.",
407 "Installer_checkMemoryAvailable_maxMemExpected_desc=Maximum JVM memory: {0}, is less than the 2 GB required. Some aspects of the application may not work as expected."
411 long memorySize = ((
com.sun.management.OperatingSystemMXBean) ManagementFactory
412 .getOperatingSystemMXBean()).getTotalMemorySize();
413 if (memorySize < 8_000_000_000L) {
414 String desc = Bundle.Installer_checkMemoryAvailable_physicalRamExpected_desc(
415 FileUtils.byteCountToDisplaySize(memorySize));
416 logger.log(Level.SEVERE, desc);
418 }
catch (Throwable t) {
419 logger.log(Level.SEVERE,
"There was an error fetching physical memory size", t);
423 long maxMemory = Runtime.getRuntime().maxMemory();
424 if (maxMemory < 2_000_000_000L) {
425 String desc = Bundle.Installer_checkMemoryAvailable_maxMemExpected_desc(
426 FileUtils.byteCountToDisplaySize(maxMemory));
427 logger.log(Level.SEVERE, desc);
429 }
catch (Throwable t) {
430 logger.log(Level.SEVERE,
"There was an error fetching jvm max memory", t);
441 SevenZip.initSevenZipFromPlatformJAR();
442 logger.log(Level.INFO,
"7zip-java bindings loaded");
443 }
catch (SevenZipNativeInitializationException e) {
444 logger.log(Level.SEVERE,
"Error loading 7zip-java bindings", e);
452 Runnable loader = () -> {
457 }
catch (Exception ex) {
460 logger.log(Level.SEVERE,
"There was an error while doing an initial load of python plugins.", ex);
464 new Thread(loader).start();
471 Runnable loader = () -> {
474 }
catch (Exception ex) {
477 logger.log(Level.SEVERE,
"There was an error while doing an initial load of translation services.", ex);
480 new Thread(loader).start();
484 public void validate() throws IllegalStateException {
487 logger.log(Level.INFO,
"validate()");
488 for (ModuleInstall mi : packageInstallers) {
489 logger.log(Level.INFO,
"{0} validate()", mi.getClass().getName());
492 }
catch (IllegalStateException e) {
493 logger.log(Level.WARNING,
"", e);
502 logger.log(Level.INFO,
"uninstalled()");
504 for (ModuleInstall mi : packageInstallers) {
505 logger.log(Level.INFO,
"{0} uninstalled()", mi.getClass().getName());
508 }
catch (Exception e) {
509 logger.log(Level.WARNING,
"", e);
515 "Installer.closing.confirmationDialog.title=Ingest is Running",
516 "Installer.closing.confirmationDialog.message=Ingest is running, are you sure you want to exit?",
517 "# {0} - exception message",
"Installer.closing.messageBox.caseCloseExceptionMessage=Error closing case: {0}"
522 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
523 FutureTask<Void> future =
new FutureTask<>(
new Callable<Void>() {
525 public Void call()
throws Exception {
530 Thread thread =
new Thread(future);
534 }
catch (InterruptedException ex) {
535 logger.log(Level.SEVERE,
"Unexpected interrupt closing the current case", ex);
536 }
catch (ExecutionException ex) {
537 logger.log(Level.SEVERE,
"Error closing the current case", ex);
540 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
552 logger.log(Level.INFO,
"close()");
559 for (ModuleInstall mi : packageInstallers) {
560 logger.log(Level.INFO,
"{0} close()", mi.getClass().getName());
563 }
catch (Exception e) {
564 logger.log(Level.WARNING,
"", e);
567 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()
void checkMemoryAvailable()
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)