Autopsy  4.6.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-2017 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 
271  private static void ensurePythonModulesFolderExists() {
272  File pythonModulesDir = new File(PlatformUtil.getUserPythonModulesPath());
273  pythonModulesDir.mkdir();
274  }
275 
276  @Override
277  public void restored() {
278  super.restored();
280  initJavaFx();
281  for (ModuleInstall mi : packageInstallers) {
282  try {
283  mi.restored();
284  logger.log(Level.INFO, "{0} restore succeeded", mi.getClass().getName()); //NON-NLS
285  } catch (Exception e) {
286  String msg = mi.getClass().getName() + " restore failed"; //NON-NLS
287  logger.log(Level.WARNING, msg, e);
288  }
289  }
290  logger.log(Level.INFO, "Autopsy Core restore completed"); //NON-NLS
291  }
292 
293  @Override
294  public void validate() throws IllegalStateException {
295  super.validate();
296 
297  logger.log(Level.INFO, "validate()"); //NON-NLS
298  for (ModuleInstall mi : packageInstallers) {
299  logger.log(Level.INFO, "{0} validate()", mi.getClass().getName()); //NON-NLS
300  try {
301  mi.validate();
302  } catch (IllegalStateException e) {
303  logger.log(Level.WARNING, "", e);
304  }
305  }
306  }
307 
308  @Override
309  public void uninstalled() {
310  super.uninstalled();
311 
312  logger.log(Level.INFO, "uninstalled()"); //NON-NLS
313 
314  for (ModuleInstall mi : packageInstallers) {
315  logger.log(Level.INFO, "{0} uninstalled()", mi.getClass().getName()); //NON-NLS
316  try {
317  mi.uninstalled();
318  } catch (Exception e) {
319  logger.log(Level.WARNING, "", e);
320  }
321  }
322  }
323 
324  @NbBundle.Messages({
325  "Installer.closing.confirmationDialog.title=Ingest is Running",
326  "Installer.closing.confirmationDialog.message=Ingest is running, are you sure you want to exit?",
327  "# {0} - exception message", "Installer.closing.messageBox.caseCloseExceptionMessage=Error closing case: {0}"
328  })
329  @Override
330  public boolean closing() {
331  if (IngestRunningCheck.checkAndConfirmProceed(Bundle.Installer_closing_confirmationDialog_title(), Bundle.Installer_closing_confirmationDialog_message())) {
332  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
333  FutureTask<Void> future = new FutureTask<>(new Callable<Void>() {
334  @Override
335  public Void call() throws Exception {
337  return null;
338  }
339  });
340  Thread thread = new Thread(future);
341  thread.start();
342  try {
343  future.get();
344  } catch (InterruptedException ex) {
345  logger.log(Level.SEVERE, "Unexpected interrupt closing the current case", ex);
346  } catch (ExecutionException ex) {
347  logger.log(Level.SEVERE, "Error closing the current case", ex);
348  MessageNotifyUtil.Message.error(Bundle.Installer_closing_messageBox_caseCloseExceptionMessage(ex.getMessage()));
349  } finally {
350  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
351  }
352  return true;
353  } else {
354  return false;
355  }
356  }
357 
358  @Override
359  public void close() {
360  super.close();
361 
362  logger.log(Level.INFO, "close()"); //NON-NLS
363 
364  //exit JavaFx plat
365  if (javaFxInit) {
366  Platform.exit();
367  }
368 
369  for (ModuleInstall mi : packageInstallers) {
370  logger.log(Level.INFO, "{0} close()", mi.getClass().getName()); //NON-NLS
371  try {
372  mi.close();
373  } catch (Exception e) {
374  logger.log(Level.WARNING, "", e);
375  }
376  }
377  for (Handler h : logger.getHandlers()) {
378  h.close(); //must call h.close or a .LCK file will remain.
379  }
380  }
381 }
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 May 7 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.