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;
69 private static final String
JAVA_TEMP =
"java.io.tmpdir";
71 private static final String
TSK_TEMP =
"tsk.tmpdir";
84 ImageIO.scanForPlugins();
95 String curTemp = System.getProperty(JAVA_TEMP,
"");
97 String tskTemp = Paths.get(StringUtils.defaultString(curTemp), autopsyTempDir).toString();
98 System.setProperty(TSK_TEMP, tskTemp);
99 File tskTempDir =
new File(tskTemp);
101 if (!tskTempDir.isDirectory()) {
102 throw new IOException(
"Unable to create directory at " + tskTemp);
104 }
catch (Exception ex) {
105 logger.log(Level.WARNING,
"There was an error setting up tsk temp directory", ex);
129 System.loadLibrary(
"api-ms-win-core-console-l1-1-0");
130 System.loadLibrary(
"api-ms-win-core-datetime-l1-1-0");
131 System.loadLibrary(
"api-ms-win-core-debug-l1-1-0");
132 System.loadLibrary(
"api-ms-win-core-errorhandling-l1-1-0");
133 System.loadLibrary(
"api-ms-win-core-file-l1-1-0");
134 System.loadLibrary(
"api-ms-win-core-file-l1-2-0");
135 System.loadLibrary(
"api-ms-win-core-file-l2-1-0");
136 System.loadLibrary(
"api-ms-win-core-handle-l1-1-0");
137 System.loadLibrary(
"api-ms-win-core-heap-l1-1-0");
138 System.loadLibrary(
"api-ms-win-core-interlocked-l1-1-0");
139 System.loadLibrary(
"api-ms-win-core-libraryloader-l1-1-0");
140 System.loadLibrary(
"api-ms-win-core-localization-l1-2-0");
141 System.loadLibrary(
"api-ms-win-core-memory-l1-1-0");
142 System.loadLibrary(
"api-ms-win-core-namedpipe-l1-1-0");
143 System.loadLibrary(
"api-ms-win-core-processenvironment-l1-1-0");
144 System.loadLibrary(
"api-ms-win-core-processthreads-l1-1-0");
145 System.loadLibrary(
"api-ms-win-core-processthreads-l1-1-1");
146 System.loadLibrary(
"api-ms-win-core-profile-l1-1-0");
147 System.loadLibrary(
"api-ms-win-core-rtlsupport-l1-1-0");
148 System.loadLibrary(
"api-ms-win-core-string-l1-1-0");
149 System.loadLibrary(
"api-ms-win-core-synch-l1-1-0");
150 System.loadLibrary(
"api-ms-win-core-synch-l1-2-0");
151 System.loadLibrary(
"api-ms-win-core-sysinfo-l1-1-0");
152 System.loadLibrary(
"api-ms-win-core-timezone-l1-1-0");
153 System.loadLibrary(
"api-ms-win-core-util-l1-1-0");
154 System.loadLibrary(
"api-ms-win-crt-conio-l1-1-0");
155 System.loadLibrary(
"api-ms-win-crt-convert-l1-1-0");
156 System.loadLibrary(
"api-ms-win-crt-environment-l1-1-0");
157 System.loadLibrary(
"api-ms-win-crt-filesystem-l1-1-0");
158 System.loadLibrary(
"api-ms-win-crt-heap-l1-1-0");
159 System.loadLibrary(
"api-ms-win-crt-locale-l1-1-0");
160 System.loadLibrary(
"api-ms-win-crt-math-l1-1-0");
161 System.loadLibrary(
"api-ms-win-crt-multibyte-l1-1-0");
162 System.loadLibrary(
"api-ms-win-crt-private-l1-1-0");
163 System.loadLibrary(
"api-ms-win-crt-process-l1-1-0");
164 System.loadLibrary(
"api-ms-win-crt-runtime-l1-1-0");
165 System.loadLibrary(
"api-ms-win-crt-stdio-l1-1-0");
166 System.loadLibrary(
"api-ms-win-crt-string-l1-1-0");
167 System.loadLibrary(
"api-ms-win-crt-time-l1-1-0");
168 System.loadLibrary(
"api-ms-win-crt-utility-l1-1-0");
170 System.loadLibrary(
"ucrtbase");
171 System.loadLibrary(
"vcruntime140");
172 System.loadLibrary(
"msvcp140");
174 logger.log(Level.INFO,
"Visual C Runtime libraries loaded");
175 }
catch (UnsatisfiedLinkError e) {
176 logger.log(Level.SEVERE,
"Error loading Visual C Runtime libraries, ", e);
180 System.loadLibrary(
"zlib");
181 logger.log(Level.INFO,
"ZLIB library loaded loaded");
182 }
catch (UnsatisfiedLinkError e) {
183 logger.log(Level.SEVERE,
"Error loading ZLIB library, ", e);
187 System.loadLibrary(
"libewf");
188 logger.log(Level.INFO,
"EWF library loaded");
189 }
catch (UnsatisfiedLinkError e) {
190 logger.log(Level.SEVERE,
"Error loading EWF library, ", e);
194 System.loadLibrary(
"libvmdk");
195 logger.log(Level.INFO,
"VMDK library loaded");
196 }
catch (UnsatisfiedLinkError e) {
197 logger.log(Level.SEVERE,
"Error loading VMDK library, ", e);
201 System.loadLibrary(
"libvhdi");
202 logger.log(Level.INFO,
"VHDI library loaded");
203 }
catch (UnsatisfiedLinkError e) {
204 logger.log(Level.SEVERE,
"Error loading VHDI library, ", e);
208 if(System.getProperty(
"sun.arch.data.model").contains(
"64")) {
211 System.loadLibrary(
"libcrypto-1_1-x64");
212 logger.log(Level.INFO,
"Crypto library loaded");
213 }
catch (UnsatisfiedLinkError e) {
214 logger.log(Level.SEVERE,
"Error loading Crypto library, ", e);
218 System.loadLibrary(
"libssl-1_1-x64");
219 logger.log(Level.INFO,
"OpenSSL library loaded");
220 }
catch (UnsatisfiedLinkError e) {
221 logger.log(Level.SEVERE,
"Error loading OpenSSL library, ", e);
228 logger.log(Level.INFO,
"core installer created");
232 System.setProperty(
"sun.java2d.dpiaware",
"false");
233 System.setProperty(
"prism.allowhidpi",
"false");
239 packageInstallers =
new ArrayList<>();
263 logger.log(Level.SEVERE,
"Failed to load file type detector.", ex);
274 int ordinal = Integer.parseInt(mode);
294 System.setProperty(
"javafx.macosx.embedded",
"true");
298 String javaLibraryPath =
"java.library.path";
299 String jvmBinPathStr = Paths.get(System.getProperty(
"java.home"),
"bin").toAbsolutePath().toString();
300 String path = System.getProperty(javaLibraryPath);
301 System.setProperty(javaLibraryPath, StringUtils.isBlank(path) ? jvmBinPathStr : jvmBinPathStr + File.pathSeparator + path);
305 Platform.setImplicitExit(
false);
307 }
catch (UnsatisfiedLinkError | NoClassDefFoundError | Exception e) {
309 final String msg = NbBundle.getMessage(
Installer.class,
"Installer.errorInitJavafx.msg");
310 final String details = NbBundle.getMessage(
Installer.class,
"Installer.errorInitJavafx.details");
311 logger.log(Level.SEVERE, msg
314 WindowManager.getDefault().invokeWhenUIReady(
new Runnable() {
329 if (System.getProperty(
"jna.nosys") == null) {
330 System.setProperty(
"jna.nosys",
"true");
333 Path gstreamerPath = InstalledFileLocator.getDefault().locate(
"gstreamer",
Installer.class.getPackage().getName(),
false).toPath();
335 if (gstreamerPath == null) {
336 logger.log(Level.SEVERE,
"Failed to find GStreamer.");
338 String arch =
"x86_64";
343 Path gstreamerBasePath = Paths.get(gstreamerPath.toString(),
"1.0", arch);
344 Path gstreamerBinPath = Paths.get(gstreamerBasePath.toString(),
"bin");
345 Path gstreamerLibPath = Paths.get(gstreamerBasePath.toString(),
"lib",
"gstreamer-1.0");
349 Kernel32 k32 = Kernel32.INSTANCE;
350 String path = System.getenv(
"PATH");
351 if (StringUtils.isBlank(path)) {
352 k32.SetEnvironmentVariable(
"PATH", gstreamerLibPath.toString());
359 k32.SetEnvironmentVariable(
"PATH", gstreamerBinPath.toString() + File.pathSeparator + gstreamerLibPath.toString() + path);
370 objectDetectionClassifierDir.mkdir();
379 pythonModulesDir.mkdir();
388 boolean createDirectory = ocrLanguagePacksDir.mkdir();
392 if (createDirectory) {
393 File tessdataDir = InstalledFileLocator.getDefault().locate(
394 "Tesseract-OCR/tessdata",
Installer.class.getPackage().getName(),
false);
396 FileUtils.copyDirectory(tessdataDir, ocrLanguagePacksDir);
397 }
catch (IOException ex) {
398 logger.log(Level.SEVERE,
"Copying over default language packs for Tesseract failed.", ex);
411 if (!GraphicsEnvironment.isHeadless()) {
416 for (ModuleInstall mi : packageInstallers) {
419 logger.log(Level.INFO,
"{0} restore succeeded", mi.getClass().getName());
420 }
catch (Exception e) {
421 String msg = mi.getClass().getName() +
" restore failed";
422 logger.log(Level.WARNING, msg, e);
425 logger.log(Level.INFO,
"Autopsy Core restore completed");
434 "# {0} - physicalMemory",
435 "Installer_checkMemoryAvailable_physicalRamExpected_desc=Physical memory: {0}, is less than the 8 GB required. Some aspects of the application may not work as expected.",
437 "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."
441 long memorySize = ((
com.sun.management.OperatingSystemMXBean) ManagementFactory
442 .getOperatingSystemMXBean()).getTotalMemorySize();
443 if (memorySize < 8_000_000_000L) {
444 String desc = Bundle.Installer_checkMemoryAvailable_physicalRamExpected_desc(
445 FileUtils.byteCountToDisplaySize(memorySize));
446 logger.log(Level.SEVERE, desc);
448 }
catch (Throwable t) {
449 logger.log(Level.SEVERE,
"There was an error fetching physical memory size", t);
453 long maxMemory = Runtime.getRuntime().maxMemory();
454 if (maxMemory < 2_000_000_000L) {
455 String desc = Bundle.Installer_checkMemoryAvailable_maxMemExpected_desc(
456 FileUtils.byteCountToDisplaySize(maxMemory));
457 logger.log(Level.SEVERE, desc);
459 }
catch (Throwable t) {
460 logger.log(Level.SEVERE,
"There was an error fetching jvm max memory", t);
471 SevenZip.initSevenZipFromPlatformJAR();
472 logger.log(Level.INFO,
"7zip-java bindings loaded");
473 }
catch (SevenZipNativeInitializationException e) {
474 logger.log(Level.SEVERE,
"Error loading 7zip-java bindings", e);
482 Runnable loader = () -> {
487 }
catch (Exception ex) {
490 logger.log(Level.SEVERE,
"There was an error while doing an initial load of python plugins.", ex);
494 new Thread(loader).start();
501 Runnable loader = () -> {
504 }
catch (Exception ex) {
507 logger.log(Level.SEVERE,
"There was an error while doing an initial load of translation services.", ex);
510 new Thread(loader).start();
514 public void validate() throws IllegalStateException {
517 logger.log(Level.INFO,
"validate()");
518 for (ModuleInstall mi : packageInstallers) {
519 logger.log(Level.INFO,
"{0} validate()", mi.getClass().getName());
522 }
catch (IllegalStateException e) {
523 logger.log(Level.WARNING,
"", e);
532 logger.log(Level.INFO,
"uninstalled()");
534 for (ModuleInstall mi : packageInstallers) {
535 logger.log(Level.INFO,
"{0} uninstalled()", mi.getClass().getName());
538 }
catch (Exception e) {
539 logger.log(Level.WARNING,
"", e);
545 "Installer.closing.confirmationDialog.title=Ingest is Running",
546 "Installer.closing.confirmationDialog.message=Ingest is running, are you sure you want to exit?",
547 "# {0} - exception message",
"Installer.closing.messageBox.caseCloseExceptionMessage=Error closing case: {0}"
553 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
556 FutureTask<Void> future =
new FutureTask<>(
new Callable<Void>() {
558 public Void call()
throws Exception {
563 Thread thread =
new Thread(future);
567 }
catch (InterruptedException ex) {
568 logger.log(Level.SEVERE,
"Unexpected interrupt closing the current case", ex);
569 }
catch (ExecutionException ex) {
570 logger.log(Level.SEVERE,
"Error closing the current case", ex);
574 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
587 logger.log(Level.INFO,
"close()");
589 for (ModuleInstall mi : packageInstallers) {
590 logger.log(Level.INFO,
"{0} close()", mi.getClass().getName());
593 }
catch (Exception e) {
594 logger.log(Level.WARNING,
"", e);
597 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 boolean runningWithGUI
static void closeCurrentCase()
static final String JAVA_TEMP
static synchronized Installer getDefault()
static Installer getDefault()
void checkMemoryAvailable()
static String getAppName()
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)
static final String AUTOPSY_TEMP_DIR_SUFFIX
synchronized static Logger getLogger(String name)
final List< ModuleInstall > packageInstallers
static synchronized Installer getDefault()
static final String TSK_TEMP
static synchronized Installer getDefault()
static synchronized List< DataSourceProcessor > getDataSourceProcessorModules()
static void ensureClassifierFolderExists()
static synchronized Installer getDefault()
static void error(String message)