Autopsy  4.7.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
Installer.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.core;
20 
21 import java.awt.Cursor;
22 import java.io.File;
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.concurrent.Callable;
26 import java.util.concurrent.ExecutionException;
27 import java.util.concurrent.FutureTask;
28 import java.util.logging.Handler;
29 import java.util.logging.Level;
30 import javafx.application.Platform;
31 import javafx.embed.swing.JFXPanel;
32 import org.openide.modules.ModuleInstall;
33 import org.openide.util.NbBundle;
34 import org.openide.windows.WindowManager;
42 
47 public class Installer extends ModuleInstall {
48 
49  private static final long serialVersionUID = 1L;
50 
51  private final List<ModuleInstall> packageInstallers;
52  private static final Logger logger = Logger.getLogger(Installer.class.getName());
53  private static volatile boolean javaFxInit = false;
54 
55  static {
57  }
58 
59  private static void loadDynLibraries() {
60  /*
61  * On Windows, we distribute dlls that libtsk_jni depend on. If
62  * libtsk_jni tries to load them, they will not be found by Windows
63  * because they are in special NetBeans folders. So, we manually load
64  * them from within Autopsy so that they are found via the NetBeans
65  * loading setup. These are copied by the build script when making the
66  * ZIP file. In a development environment they will need to be loaded
67  * from standard places in your system.
68  *
69  * On non-Windows platforms, we assume the dependncies are all installed
70  * and loadable (i.e. a 'make install' was done).
71  */
72  if (PlatformUtil.isWindowsOS()) {
73  try {
74  //Note: if shipping with a different CRT version, this will only print a warning
75  //and try to use linker mechanism to find the correct versions of libs.
76  //We should update this if we officially switch to a new version of CRT/compiler
77  System.loadLibrary("api-ms-win-core-console-l1-1-0"); //NON-NLS
78  System.loadLibrary("api-ms-win-core-datetime-l1-1-0"); //NON-NLS
79  System.loadLibrary("api-ms-win-core-debug-l1-1-0"); //NON-NLS
80  System.loadLibrary("api-ms-win-core-errorhandling-l1-1-0"); //NON-NLS
81  System.loadLibrary("api-ms-win-core-file-l1-1-0"); //NON-NLS
82  System.loadLibrary("api-ms-win-core-file-l1-2-0"); //NON-NLS
83  System.loadLibrary("api-ms-win-core-file-l2-1-0"); //NON-NLS
84  System.loadLibrary("api-ms-win-core-handle-l1-1-0"); //NON-NLS
85  System.loadLibrary("api-ms-win-core-heap-l1-1-0"); //NON-NLS
86  System.loadLibrary("api-ms-win-core-interlocked-l1-1-0"); //NON-NLS
87  System.loadLibrary("api-ms-win-core-libraryloader-l1-1-0"); //NON-NLS
88  System.loadLibrary("api-ms-win-core-localization-l1-2-0"); //NON-NLS
89  System.loadLibrary("api-ms-win-core-memory-l1-1-0"); //NON-NLS
90  System.loadLibrary("api-ms-win-core-namedpipe-l1-1-0"); //NON-NLS
91  System.loadLibrary("api-ms-win-core-processenvironment-l1-1-0"); //NON-NLS
92  System.loadLibrary("api-ms-win-core-processthreads-l1-1-0"); //NON-NLS
93  System.loadLibrary("api-ms-win-core-processthreads-l1-1-1"); //NON-NLS
94  System.loadLibrary("api-ms-win-core-profile-l1-1-0"); //NON-NLS
95  System.loadLibrary("api-ms-win-core-rtlsupport-l1-1-0"); //NON-NLS
96  System.loadLibrary("api-ms-win-core-string-l1-1-0"); //NON-NLS
97  System.loadLibrary("api-ms-win-core-synch-l1-1-0"); //NON-NLS
98  System.loadLibrary("api-ms-win-core-synch-l1-2-0"); //NON-NLS
99  System.loadLibrary("api-ms-win-core-sysinfo-l1-1-0"); //NON-NLS
100  System.loadLibrary("api-ms-win-core-timezone-l1-1-0"); //NON-NLS
101  System.loadLibrary("api-ms-win-core-util-l1-1-0"); //NON-NLS
102  System.loadLibrary("api-ms-win-crt-conio-l1-1-0"); //NON-NLS
103  System.loadLibrary("api-ms-win-crt-convert-l1-1-0"); //NON-NLS
104  System.loadLibrary("api-ms-win-crt-environment-l1-1-0"); //NON-NLS
105  System.loadLibrary("api-ms-win-crt-filesystem-l1-1-0"); //NON-NLS
106  System.loadLibrary("api-ms-win-crt-heap-l1-1-0"); //NON-NLS
107  System.loadLibrary("api-ms-win-crt-locale-l1-1-0"); //NON-NLS
108  System.loadLibrary("api-ms-win-crt-math-l1-1-0"); //NON-NLS
109  System.loadLibrary("api-ms-win-crt-multibyte-l1-1-0"); //NON-NLS
110  System.loadLibrary("api-ms-win-crt-private-l1-1-0"); //NON-NLS
111  System.loadLibrary("api-ms-win-crt-process-l1-1-0"); //NON-NLS
112  System.loadLibrary("api-ms-win-crt-runtime-l1-1-0"); //NON-NLS
113  System.loadLibrary("api-ms-win-crt-stdio-l1-1-0"); //NON-NLS
114  System.loadLibrary("api-ms-win-crt-string-l1-1-0"); //NON-NLS
115  System.loadLibrary("api-ms-win-crt-time-l1-1-0"); //NON-NLS
116  System.loadLibrary("api-ms-win-crt-utility-l1-1-0"); //NON-NLS
117 
118  System.loadLibrary("ucrtbase"); //NON-NLS
119  System.loadLibrary("vcruntime140"); //NON-NLS
120  System.loadLibrary("msvcp140"); //NON-NLS
121 
122  logger.log(Level.INFO, "Visual C Runtime libraries loaded"); //NON-NLS
123  } catch (UnsatisfiedLinkError e) {
124  logger.log(Level.SEVERE, "Error loading Visual C Runtime libraries, ", e); //NON-NLS
125  }
126 
127  try {
128  System.loadLibrary("zlib"); //NON-NLS
129  logger.log(Level.INFO, "ZLIB library loaded loaded"); //NON-NLS
130  } catch (UnsatisfiedLinkError e) {
131  logger.log(Level.SEVERE, "Error loading ZLIB library, ", e); //NON-NLS
132  }
133 
134  try {
135  System.loadLibrary("libewf"); //NON-NLS
136  logger.log(Level.INFO, "EWF library loaded"); //NON-NLS
137  } catch (UnsatisfiedLinkError e) {
138  logger.log(Level.SEVERE, "Error loading EWF library, ", e); //NON-NLS
139  }
140 
141  try {
142  System.loadLibrary("libvmdk"); //NON-NLS
143  logger.log(Level.INFO, "VMDK library loaded"); //NON-NLS
144  } catch (UnsatisfiedLinkError e) {
145  logger.log(Level.SEVERE, "Error loading VMDK library, ", e); //NON-NLS
146  }
147 
148  try {
149  System.loadLibrary("libvhdi"); //NON-NLS
150  logger.log(Level.INFO, "VHDI library loaded"); //NON-NLS
151  } catch (UnsatisfiedLinkError e) {
152  logger.log(Level.SEVERE, "Error loading VHDI library, ", e); //NON-NLS
153  }
154 
155  /*
156  * PostgreSQL
157  */
158  try {
159  System.loadLibrary("msvcr120"); //NON-NLS
160  logger.log(Level.INFO, "MSVCR 120 library loaded"); //NON-NLS
161  } catch (UnsatisfiedLinkError e) {
162  logger.log(Level.SEVERE, "Error loading MSVCR120 library, ", e); //NON-NLS
163  }
164 
165  try {
166  System.loadLibrary("libeay32"); //NON-NLS
167  logger.log(Level.INFO, "LIBEAY32 library loaded"); //NON-NLS
168  } catch (UnsatisfiedLinkError e) {
169  logger.log(Level.SEVERE, "Error loading LIBEAY32 library, ", e); //NON-NLS
170  }
171 
172  try {
173  System.loadLibrary("ssleay32"); //NON-NLS
174  logger.log(Level.INFO, "SSLEAY32 library loaded"); //NON-NLS
175  } catch (UnsatisfiedLinkError e) {
176  logger.log(Level.SEVERE, "Error loading SSLEAY32 library, ", e); //NON-NLS
177  }
178 
179  try {
180  System.loadLibrary("libiconv-2"); //NON-NLS
181  logger.log(Level.INFO, "libiconv-2 library loaded"); //NON-NLS
182  } catch (UnsatisfiedLinkError e) {
183  logger.log(Level.SEVERE, "Error loading libiconv-2 library, ", e); //NON-NLS
184  }
185 
186  try {
187  System.loadLibrary("libintl-8"); //NON-NLS
188  logger.log(Level.INFO, "libintl-8 library loaded"); //NON-NLS
189  } catch (UnsatisfiedLinkError e) {
190  logger.log(Level.SEVERE, "Error loading libintl-8 library, ", e); //NON-NLS
191  }
192 
193  try {
194  System.loadLibrary("libpq"); //NON-NLS
195  logger.log(Level.INFO, "LIBPQ library loaded"); //NON-NLS
196  } catch (UnsatisfiedLinkError e) {
197  logger.log(Level.SEVERE, "Error loading LIBPQ library, ", e); //NON-NLS
198  }
199  }
200  }
201 
202  public Installer() {
203  logger.log(Level.INFO, "core installer created"); //NON-NLS
204  javaFxInit = false;
205 
206  // Prevent the Autopsy UI from shrinking on high DPI displays
207  System.setProperty("sun.java2d.dpiaware", "false");
208  System.setProperty("prism.allowhidpi", "false");
209 
210  // Update existing configuration in case of unsupported settings
211  updateConfig();
212 
213  packageInstallers = new ArrayList<>();
214  packageInstallers.add(org.sleuthkit.autopsy.coreutils.Installer.getDefault());
215  packageInstallers.add(org.sleuthkit.autopsy.corecomponents.Installer.getDefault());
216  packageInstallers.add(org.sleuthkit.autopsy.datamodel.Installer.getDefault());
217  packageInstallers.add(org.sleuthkit.autopsy.ingest.Installer.getDefault());
219  packageInstallers.add(org.sleuthkit.autopsy.healthmonitor.Installer.getDefault());
220  }
221 
226  private void updateConfig() {
227  String mode = ModuleSettings.getConfigSetting(SETTINGS_PROPERTIES, "AutopsyMode");
228  if (mode != null) {
229  int ordinal = Integer.parseInt(mode);
230  if (ordinal > 1) {
232  ModuleSettings.setConfigSetting(UserPreferences.SETTINGS_PROPERTIES, "JoinAutoModeCluster", Boolean.toString(false));
233  }
234  }
235  }
236 
243  public static boolean isJavaFxInited() {
244  return javaFxInit;
245  }
246 
247  private static void initJavaFx() {
248  //initialize java fx if exists
249  System.setProperty("javafx.macosx.embedded", "true");
250  try {
251  // Creating a JFXPanel initializes JavaFX
252  JFXPanel panel = new JFXPanel();
253  Platform.setImplicitExit(false);
254  javaFxInit = true;
255  } catch (UnsatisfiedLinkError | NoClassDefFoundError | Exception e) {
256  //in case javafx not present
257  final String msg = NbBundle.getMessage(Installer.class, "Installer.errorInitJavafx.msg");
258  final String details = NbBundle.getMessage(Installer.class, "Installer.errorInitJavafx.details");
259  logger.log(Level.SEVERE, msg
260  + details, e);
261 
262  WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
263  @Override
264  public void run() {
265  MessageNotifyUtil.Notify.error(msg, details);
266  }
267  });
268  }
269  }
270 
275  private static void ensureClassifierFolderExists() {
276  File objectDetectionClassifierDir = new File(PlatformUtil.getObjectDetectionClassifierPath());
277  objectDetectionClassifierDir.mkdir();
278  }
279 
284  private static void ensurePythonModulesFolderExists() {
285  File pythonModulesDir = new File(PlatformUtil.getUserPythonModulesPath());
286  pythonModulesDir.mkdir();
287  }
288 
289  @Override
290  public void restored() {
291  super.restored();
294  initJavaFx();
295  for (ModuleInstall mi : packageInstallers) {
296  try {
297  mi.restored();
298  logger.log(Level.INFO, "{0} restore succeeded", mi.getClass().getName()); //NON-NLS
299  } catch (Exception e) {
300  String msg = mi.getClass().getName() + " restore failed"; //NON-NLS
301  logger.log(Level.WARNING, msg, e);
302  }
303  }
304  logger.log(Level.INFO, "Autopsy Core restore completed"); //NON-NLS
305  }
306 
307  @Override
308  public void validate() throws IllegalStateException {
309  super.validate();
310 
311  logger.log(Level.INFO, "validate()"); //NON-NLS
312  for (ModuleInstall mi : packageInstallers) {
313  logger.log(Level.INFO, "{0} validate()", mi.getClass().getName()); //NON-NLS
314  try {
315  mi.validate();
316  } catch (IllegalStateException e) {
317  logger.log(Level.WARNING, "", e);
318  }
319  }
320  }
321 
322  @Override
323  public void uninstalled() {
324  super.uninstalled();
325 
326  logger.log(Level.INFO, "uninstalled()"); //NON-NLS
327 
328  for (ModuleInstall mi : packageInstallers) {
329  logger.log(Level.INFO, "{0} uninstalled()", mi.getClass().getName()); //NON-NLS
330  try {
331  mi.uninstalled();
332  } catch (Exception e) {
333  logger.log(Level.WARNING, "", e);
334  }
335  }
336  }
337 
338  @NbBundle.Messages({
339  "Installer.closing.confirmationDialog.title=Ingest is Running",
340  "Installer.closing.confirmationDialog.message=Ingest is running, are you sure you want to exit?",
341  "# {0} - exception message", "Installer.closing.messageBox.caseCloseExceptionMessage=Error closing case: {0}"
342  })
343  @Override
344  public boolean closing() {
345  if (IngestRunningCheck.checkAndConfirmProceed(Bundle.Installer_closing_confirmationDialog_title(), Bundle.Installer_closing_confirmationDialog_message())) {
346  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
347  FutureTask<Void> future = new FutureTask<>(new Callable<Void>() {
348  @Override
349  public Void call() throws Exception {
351  return null;
352  }
353  });
354  Thread thread = new Thread(future);
355  thread.start();
356  try {
357  future.get();
358  } catch (InterruptedException ex) {
359  logger.log(Level.SEVERE, "Unexpected interrupt closing the current case", ex);
360  } catch (ExecutionException ex) {
361  logger.log(Level.SEVERE, "Error closing the current case", ex);
362  MessageNotifyUtil.Message.error(Bundle.Installer_closing_messageBox_caseCloseExceptionMessage(ex.getMessage()));
363  } finally {
364  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
365  }
366  return true;
367  } else {
368  return false;
369  }
370  }
371 
372  @Override
373  public void close() {
374  super.close();
375 
376  logger.log(Level.INFO, "close()"); //NON-NLS
377 
378  //exit JavaFx plat
379  if (javaFxInit) {
380  Platform.exit();
381  }
382 
383  for (ModuleInstall mi : packageInstallers) {
384  logger.log(Level.INFO, "{0} close()", mi.getClass().getName()); //NON-NLS
385  try {
386  mi.close();
387  } catch (Exception e) {
388  logger.log(Level.WARNING, "", e);
389  }
390  }
391  for (Handler h : logger.getHandlers()) {
392  h.close(); //must call h.close or a .LCK file will remain.
393  }
394  }
395 }
static boolean checkAndConfirmProceed(String optionsDlgTitle, String optionsDlgMessage)
static void setMode(SelectedMode mode)
static synchronized Installer getDefault()
Definition: Installer.java:47
static synchronized void setConfigSetting(String moduleName, String settingName, String settingVal)
static volatile boolean javaFxInit
Definition: Installer.java:53
static synchronized Installer getDefault()
Definition: Installer.java:38
static synchronized Installer getDefault()
Definition: Installer.java:33
static String getConfigSetting(String moduleName, String settingName)
static synchronized Installer getDefault()
Definition: Installer.java:31
static void error(String title, String message)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
final List< ModuleInstall > packageInstallers
Definition: Installer.java:51
static synchronized Installer getDefault()
Definition: Installer.java:35

Copyright © 2012-2016 Basis Technology. Generated on: Mon Jun 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.