Autopsy  4.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-2014 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.io.File;
22 import java.util.ArrayList;
23 import java.util.List;
24 import java.util.logging.Handler;
25 import java.util.logging.Level;
26 import javafx.application.Platform;
27 import javafx.embed.swing.JFXPanel;
28 import org.openide.modules.ModuleInstall;
29 import org.openide.util.NbBundle;
30 import org.openide.windows.WindowManager;
34 
39 public class Installer extends ModuleInstall {
40 
41  private final List<ModuleInstall> packageInstallers;
42  private static final Logger logger = Logger.getLogger(Installer.class.getName());
43  private static volatile boolean javaFxInit = false;
44 
45  static {
47  }
48 
49  private static void loadDynLibraries() {
50  /*
51  * On Windows, we distribute dlls that libtsk_jni depend on. If
52  * libtsk_jni tries to load them, they will not be found by Windows
53  * because they are in special NetBeans folders. So, we manually load
54  * them from within Autopsy so that they are found via the NetBeans
55  * loading setup. These are copied by the build script when making the
56  * ZIP file. In a development environment they will need to be loaded
57  * from standard places in your system.
58  *
59  * On non-Windows platforms, we assume the dependncies are all installed
60  * and loadable (i.e. a 'make install' was done).
61  */
62  if (PlatformUtil.isWindowsOS()) {
63  try {
64  //Note: if shipping with a different CRT version, this will only print a warning
65  //and try to use linker mechanism to find the correct versions of libs.
66  //We should update this if we officially switch to a new version of CRT/compiler
67  System.loadLibrary("msvcr100"); //NON-NLS
68  System.loadLibrary("msvcp100"); //NON-NLS
69 
70  logger.log(Level.INFO, "MSVCR100 and MSVCP100 libraries loaded"); //NON-NLS
71  } catch (UnsatisfiedLinkError e) {
72  logger.log(Level.SEVERE, "Error loading MSVCR100 and MSVCP100 libraries, ", e); //NON-NLS
73  }
74 
75  try {
76  System.loadLibrary("zlib"); //NON-NLS
77  logger.log(Level.INFO, "ZLIB library loaded loaded"); //NON-NLS
78  } catch (UnsatisfiedLinkError e) {
79  logger.log(Level.SEVERE, "Error loading ZLIB library, ", e); //NON-NLS
80  }
81 
82  try {
83  System.loadLibrary("libewf"); //NON-NLS
84  logger.log(Level.INFO, "EWF library loaded"); //NON-NLS
85  } catch (UnsatisfiedLinkError e) {
86  logger.log(Level.SEVERE, "Error loading EWF library, ", e); //NON-NLS
87  }
88 
89  try {
90  System.loadLibrary("libvmdk"); //NON-NLS
91  logger.log(Level.INFO, "VMDK library loaded"); //NON-NLS
92  } catch (UnsatisfiedLinkError e) {
93  logger.log(Level.SEVERE, "Error loading VMDK library, ", e); //NON-NLS
94  }
95 
96  try {
97  System.loadLibrary("libvhdi"); //NON-NLS
98  logger.log(Level.INFO, "VHDI library loaded"); //NON-NLS
99  } catch (UnsatisfiedLinkError e) {
100  logger.log(Level.SEVERE, "Error loading VHDI library, ", e); //NON-NLS
101  }
102 
103  /* PostgreSQL */
104  try {
105  System.loadLibrary("msvcr120"); //NON-NLS
106  logger.log(Level.INFO, "MSVCR 120 library loaded"); //NON-NLS
107  } catch (UnsatisfiedLinkError e) {
108  logger.log(Level.SEVERE, "Error loading MSVCR120 library, ", e); //NON-NLS
109  }
110 
111  try {
112  System.loadLibrary("libeay32"); //NON-NLS
113  logger.log(Level.INFO, "LIBEAY32 library loaded"); //NON-NLS
114  } catch (UnsatisfiedLinkError e) {
115  logger.log(Level.SEVERE, "Error loading LIBEAY32 library, ", e); //NON-NLS
116  }
117 
118  try {
119  System.loadLibrary("ssleay32"); //NON-NLS
120  logger.log(Level.INFO, "SSLEAY32 library loaded"); //NON-NLS
121  } catch (UnsatisfiedLinkError e) {
122  logger.log(Level.SEVERE, "Error loading SSLEAY32 library, ", e); //NON-NLS
123  }
124 
125  // This library name is different in 32-bit versus 64-bit
126  String libintlName = "libintl-8"; //NON-NLS
127  if (PlatformUtil.is64BitJVM() == false) {
128  libintlName = "intl"; //NON-NLS
129  }
130  try {
131  System.loadLibrary(libintlName); //NON-NLS
132  logger.log(Level.INFO, libintlName + " library loaded"); //NON-NLS
133  } catch (UnsatisfiedLinkError e) {
134  logger.log(Level.SEVERE, "Error loading " + libintlName + " library, ", e); //NON-NLS
135  }
136 
137  try {
138  System.loadLibrary("libpq"); //NON-NLS
139  logger.log(Level.INFO, "LIBPQ library loaded"); //NON-NLS
140  } catch (UnsatisfiedLinkError e) {
141  logger.log(Level.SEVERE, "Error loading LIBPQ library, ", e); //NON-NLS
142  }
143  }
144  }
145 
146  public Installer() {
147  logger.log(Level.INFO, "core installer created"); //NON-NLS
148  javaFxInit = false;
149  packageInstallers = new ArrayList<>();
150  packageInstallers.add(org.sleuthkit.autopsy.coreutils.Installer.getDefault());
151  packageInstallers.add(org.sleuthkit.autopsy.corecomponents.Installer.getDefault());
152  packageInstallers.add(org.sleuthkit.autopsy.datamodel.Installer.getDefault());
153  packageInstallers.add(org.sleuthkit.autopsy.ingest.Installer.getDefault());
154  }
155 
162  public static boolean isJavaFxInited() {
163  return javaFxInit;
164  }
165 
166  private static void initJavaFx() {
167  //initialize java fx if exists
168  System.setProperty("javafx.macosx.embedded", "true");
169  try {
170  // Creating a JFXPanel initializes JavaFX
171  new JFXPanel();
172  Platform.setImplicitExit(false);
173  javaFxInit = true;
174  } catch (UnsatisfiedLinkError | NoClassDefFoundError | Exception e) {
175  //in case javafx not present
176  final String msg = NbBundle.getMessage(Installer.class, "Installer.errorInitJavafx.msg");
177  final String details = NbBundle.getMessage(Installer.class, "Installer.errorInitJavafx.details");
178  logger.log(Level.SEVERE, msg
179  + details, e);
180 
181  WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
182  @Override
183  public void run() {
184  MessageNotifyUtil.Notify.error(msg, details);
185  }
186  });
187  }
188  }
189 
190  private static void ensurePythonModulesFolderExists() {
191  File pythonModulesDir = new File(PlatformUtil.getUserPythonModulesPath());
192  pythonModulesDir.mkdir();
193  }
194 
195  @Override
196  public void restored() {
197  super.restored();
199  initJavaFx();
200  for (ModuleInstall mi : packageInstallers) {
201  try {
202  mi.restored();
203  logger.log(Level.INFO, "{0} restore succeeded", mi.getClass().getName()); //NON-NLS
204  } catch (Exception e) {
205  String msg = mi.getClass().getName() + " restore failed"; //NON-NLS
206  logger.log(Level.WARNING, msg, e);
207  }
208  }
209  logger.log(Level.INFO, "Autopsy Core restore completed"); //NON-NLS
210  }
211 
212  @Override
213  public void validate() throws IllegalStateException {
214  super.validate();
215 
216  logger.log(Level.INFO, "validate()"); //NON-NLS
217  for (ModuleInstall mi : packageInstallers) {
218  logger.log(Level.INFO, "{0} validate()", mi.getClass().getName()); //NON-NLS
219  try {
220  mi.validate();
221  } catch (Exception e) {
222  logger.log(Level.WARNING, "", e);
223  }
224  }
225  }
226 
227  @Override
228  public void uninstalled() {
229  super.uninstalled();
230 
231  logger.log(Level.INFO, "uninstalled()"); //NON-NLS
232 
233  for (ModuleInstall mi : packageInstallers) {
234  logger.log(Level.INFO, "{0} uninstalled()", mi.getClass().getName()); //NON-NLS
235  try {
236  mi.uninstalled();
237  } catch (Exception e) {
238  logger.log(Level.WARNING, "", e);
239  }
240  }
241  }
242 
243  @Override
244  public void close() {
245  super.close();
246 
247  logger.log(Level.INFO, "close()"); //NON-NLS
248 
249  //exit JavaFx plat
250  if (javaFxInit) {
251  Platform.exit();
252  }
253 
254  for (ModuleInstall mi : packageInstallers) {
255  logger.log(Level.INFO, "{0} close()", mi.getClass().getName()); //NON-NLS
256  try {
257  mi.close();
258  } catch (Exception e) {
259  logger.log(Level.WARNING, "", e);
260  }
261  }
262  for (Handler h : logger.getHandlers()) {
263  h.close(); //must call h.close or a .LCK file will remain.
264  }
265  }
266 }
static synchronized Installer getDefault()
Definition: Installer.java:50
static volatile boolean javaFxInit
Definition: Installer.java:43
static synchronized Installer getDefault()
Definition: Installer.java:38
static synchronized Installer getDefault()
Definition: Installer.java:31
static void error(String title, String message)
synchronized static Logger getLogger(String name)
Definition: Logger.java:166
final List< ModuleInstall > packageInstallers
Definition: Installer.java:41
static synchronized Installer getDefault()
Definition: Installer.java:35

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.