Autopsy  4.5.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  }
220 
225  private void updateConfig() {
226  String mode = ModuleSettings.getConfigSetting(SETTINGS_PROPERTIES, "AutopsyMode");
227  if(mode != null) {
228  int ordinal = Integer.parseInt(mode);
229  if(ordinal > 1) {
231  ModuleSettings.setConfigSetting(UserPreferences.SETTINGS_PROPERTIES, "JoinAutoModeCluster", Boolean.toString(false));
232  }
233  }
234  }
235 
242  public static boolean isJavaFxInited() {
243  return javaFxInit;
244  }
245 
246  private static void initJavaFx() {
247  //initialize java fx if exists
248  System.setProperty("javafx.macosx.embedded", "true");
249  try {
250  // Creating a JFXPanel initializes JavaFX
251  JFXPanel panel = new JFXPanel();
252  Platform.setImplicitExit(false);
253  javaFxInit = true;
254  } catch (UnsatisfiedLinkError | NoClassDefFoundError | Exception e) {
255  //in case javafx not present
256  final String msg = NbBundle.getMessage(Installer.class, "Installer.errorInitJavafx.msg");
257  final String details = NbBundle.getMessage(Installer.class, "Installer.errorInitJavafx.details");
258  logger.log(Level.SEVERE, msg
259  + details, e);
260 
261  WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
262  @Override
263  public void run() {
264  MessageNotifyUtil.Notify.error(msg, details);
265  }
266  });
267  }
268  }
269 
270  private static void ensurePythonModulesFolderExists() {
271  File pythonModulesDir = new File(PlatformUtil.getUserPythonModulesPath());
272  pythonModulesDir.mkdir();
273  }
274 
275  @Override
276  public void restored() {
277  super.restored();
279  initJavaFx();
280  for (ModuleInstall mi : packageInstallers) {
281  try {
282  mi.restored();
283  logger.log(Level.INFO, "{0} restore succeeded", mi.getClass().getName()); //NON-NLS
284  } catch (Exception e) {
285  String msg = mi.getClass().getName() + " restore failed"; //NON-NLS
286  logger.log(Level.WARNING, msg, e);
287  }
288  }
289  logger.log(Level.INFO, "Autopsy Core restore completed"); //NON-NLS
290  }
291 
292  @Override
293  public void validate() throws IllegalStateException {
294  super.validate();
295 
296  logger.log(Level.INFO, "validate()"); //NON-NLS
297  for (ModuleInstall mi : packageInstallers) {
298  logger.log(Level.INFO, "{0} validate()", mi.getClass().getName()); //NON-NLS
299  try {
300  mi.validate();
301  } catch (IllegalStateException e) {
302  logger.log(Level.WARNING, "", e);
303  }
304  }
305  }
306 
307  @Override
308  public void uninstalled() {
309  super.uninstalled();
310 
311  logger.log(Level.INFO, "uninstalled()"); //NON-NLS
312 
313  for (ModuleInstall mi : packageInstallers) {
314  logger.log(Level.INFO, "{0} uninstalled()", mi.getClass().getName()); //NON-NLS
315  try {
316  mi.uninstalled();
317  } catch (Exception e) {
318  logger.log(Level.WARNING, "", e);
319  }
320  }
321  }
322 
323  @NbBundle.Messages({
324  "Installer.closing.confirmationDialog.title=Ingest is Running",
325  "Installer.closing.confirmationDialog.message=Ingest is running, are you sure you want to exit?",
326  "# {0} - exception message", "Installer.closing.messageBox.caseCloseExceptionMessage=Error closing case: {0}"
327  })
328  @Override
329  public boolean closing() {
330  if (IngestRunningCheck.checkAndConfirmProceed(Bundle.Installer_closing_confirmationDialog_title(), Bundle.Installer_closing_confirmationDialog_message())) {
331  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
332  FutureTask<Void> future = new FutureTask<>(new Callable<Void>() {
333  @Override
334  public Void call() throws Exception {
336  return null;
337  }
338  });
339  Thread thread = new Thread(future);
340  thread.start();
341  try {
342  future.get();
343  } catch (InterruptedException ex) {
344  logger.log(Level.SEVERE, "Unexpected interrupt closing the current case", ex);
345  } catch (ExecutionException ex) {
346  logger.log(Level.SEVERE, "Error closing the current case", ex);
347  MessageNotifyUtil.Message.error(Bundle.Installer_closing_messageBox_caseCloseExceptionMessage(ex.getMessage()));
348  } finally {
349  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
350  }
351  return true;
352  } else {
353  return false;
354  }
355  }
356 
357  @Override
358  public void close() {
359  super.close();
360 
361  logger.log(Level.INFO, "close()"); //NON-NLS
362 
363  //exit JavaFx plat
364  if (javaFxInit) {
365  Platform.exit();
366  }
367 
368  for (ModuleInstall mi : packageInstallers) {
369  logger.log(Level.INFO, "{0} close()", mi.getClass().getName()); //NON-NLS
370  try {
371  mi.close();
372  } catch (Exception e) {
373  logger.log(Level.WARNING, "", e);
374  }
375  }
376  for (Handler h : logger.getHandlers()) {
377  h.close(); //must call h.close or a .LCK file will remain.
378  }
379  }
380 }
static boolean checkAndConfirmProceed(String optionsDlgTitle, String optionsDlgMessage)
static void setMode(SelectedMode mode)
static synchronized Installer getDefault()
Definition: Installer.java:45
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 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: Tue Feb 20 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.