Autopsy  4.1
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  try {
126  System.loadLibrary("libiconv-2"); //NON-NLS
127  logger.log(Level.INFO, "libiconv-2 library loaded"); //NON-NLS
128  } catch (UnsatisfiedLinkError e) {
129  logger.log(Level.SEVERE, "Error loading libiconv-2 library, ", e); //NON-NLS
130  }
131 
132  try {
133  System.loadLibrary("libintl-8"); //NON-NLS
134  logger.log(Level.INFO, "libintl-8 library loaded"); //NON-NLS
135  } catch (UnsatisfiedLinkError e) {
136  logger.log(Level.SEVERE, "Error loading libintl-8 library, ", e); //NON-NLS
137  }
138 
139  try {
140  System.loadLibrary("libpq"); //NON-NLS
141  logger.log(Level.INFO, "LIBPQ library loaded"); //NON-NLS
142  } catch (UnsatisfiedLinkError e) {
143  logger.log(Level.SEVERE, "Error loading LIBPQ library, ", e); //NON-NLS
144  }
145  }
146  }
147 
148  public Installer() {
149  logger.log(Level.INFO, "core installer created"); //NON-NLS
150  javaFxInit = false;
151  packageInstallers = new ArrayList<>();
152  packageInstallers.add(org.sleuthkit.autopsy.coreutils.Installer.getDefault());
153  packageInstallers.add(org.sleuthkit.autopsy.corecomponents.Installer.getDefault());
154  packageInstallers.add(org.sleuthkit.autopsy.datamodel.Installer.getDefault());
155  packageInstallers.add(org.sleuthkit.autopsy.ingest.Installer.getDefault());
156  }
157 
164  public static boolean isJavaFxInited() {
165  return javaFxInit;
166  }
167 
168  private static void initJavaFx() {
169  //initialize java fx if exists
170  System.setProperty("javafx.macosx.embedded", "true");
171  try {
172  // Creating a JFXPanel initializes JavaFX
173  new JFXPanel();
174  Platform.setImplicitExit(false);
175  javaFxInit = true;
176  } catch (UnsatisfiedLinkError | NoClassDefFoundError | Exception e) {
177  //in case javafx not present
178  final String msg = NbBundle.getMessage(Installer.class, "Installer.errorInitJavafx.msg");
179  final String details = NbBundle.getMessage(Installer.class, "Installer.errorInitJavafx.details");
180  logger.log(Level.SEVERE, msg
181  + details, e);
182 
183  WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
184  @Override
185  public void run() {
186  MessageNotifyUtil.Notify.error(msg, details);
187  }
188  });
189  }
190  }
191 
192  private static void ensurePythonModulesFolderExists() {
193  File pythonModulesDir = new File(PlatformUtil.getUserPythonModulesPath());
194  pythonModulesDir.mkdir();
195  }
196 
197  @Override
198  public void restored() {
199  super.restored();
201  initJavaFx();
202  for (ModuleInstall mi : packageInstallers) {
203  try {
204  mi.restored();
205  logger.log(Level.INFO, "{0} restore succeeded", mi.getClass().getName()); //NON-NLS
206  } catch (Exception e) {
207  String msg = mi.getClass().getName() + " restore failed"; //NON-NLS
208  logger.log(Level.WARNING, msg, e);
209  }
210  }
211  logger.log(Level.INFO, "Autopsy Core restore completed"); //NON-NLS
212  }
213 
214  @Override
215  public void validate() throws IllegalStateException {
216  super.validate();
217 
218  logger.log(Level.INFO, "validate()"); //NON-NLS
219  for (ModuleInstall mi : packageInstallers) {
220  logger.log(Level.INFO, "{0} validate()", mi.getClass().getName()); //NON-NLS
221  try {
222  mi.validate();
223  } catch (Exception e) {
224  logger.log(Level.WARNING, "", e);
225  }
226  }
227  }
228 
229  @Override
230  public void uninstalled() {
231  super.uninstalled();
232 
233  logger.log(Level.INFO, "uninstalled()"); //NON-NLS
234 
235  for (ModuleInstall mi : packageInstallers) {
236  logger.log(Level.INFO, "{0} uninstalled()", mi.getClass().getName()); //NON-NLS
237  try {
238  mi.uninstalled();
239  } catch (Exception e) {
240  logger.log(Level.WARNING, "", e);
241  }
242  }
243  }
244 
245  @Override
246  public void close() {
247  super.close();
248 
249  logger.log(Level.INFO, "close()"); //NON-NLS
250 
251  //exit JavaFx plat
252  if (javaFxInit) {
253  Platform.exit();
254  }
255 
256  for (ModuleInstall mi : packageInstallers) {
257  logger.log(Level.INFO, "{0} close()", mi.getClass().getName()); //NON-NLS
258  try {
259  mi.close();
260  } catch (Exception e) {
261  logger.log(Level.WARNING, "", e);
262  }
263  }
264  for (Handler h : logger.getHandlers()) {
265  h.close(); //must call h.close or a .LCK file will remain.
266  }
267  }
268 }
static synchronized Installer getDefault()
Definition: Installer.java:52
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:161
final List< ModuleInstall > packageInstallers
Definition: Installer.java:41
static synchronized Installer getDefault()
Definition: Installer.java:35

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.