Autopsy  4.22.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 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.datamodel;
20 
21 import java.awt.Component;
22 import java.util.logging.Level;
23 
24 import org.openide.util.NbBundle;
26 import javax.swing.JOptionPane;
27 import org.openide.LifecycleManager;
28 import org.openide.modules.ModuleInstall;
29 import org.openide.util.NbBundle.Messages;
33 
37 public class Installer extends ModuleInstall {
38 
39  private static Installer instance;
40 
41  public synchronized static Installer getDefault() {
42  if (instance == null) {
43  instance = new Installer();
44  }
45  return instance;
46  }
47 
48  private Installer() {
49  super();
50  }
51 
52  @Messages({
53  "Installer_validate_tskLibLock_title=Error calling Sleuth Kit library",
54  "Installer_validate_tskLibLock_description=<html>Another forensics application is running that uses The Sleuth Kit.<br/>You must close that application before launching Autopsy.<br/>If that application is Cyber Triage, then you should upgrade it so that it can run at the same time as Autopsy.</html>"
55  })
56  @Override
57  public void validate() throws IllegalStateException {
58 
59 
60  /*
61  * The NetBeans API specifies that a module should throw an
62  * IllegalStateException if it can't be initalized, but NetBeans doesn't
63  * handle that behaviour well (it just disables the module, and all
64  * dependant modules, on the current and all subsequent application
65  * launches). Hence, we deal with it manually.
66  *
67  */
68 
69  // Check that the the Sleuth Kit JNI is working by getting the Sleuth Kit version number
70  Logger logger = Logger.getLogger(Installer.class.getName());
71 
72  try {
74  if (libLock != null && libLock.getLockState() == LockState.HELD_BY_OLD) {
75  throw new OldAppLockException("A lock on the libtsk_jni lib is already held by an old application. " + (libLock.getLibTskJniFile() != null ? libLock.getLibTskJniFile().getAbsolutePath() : ""));
76  }
77 
78  String skVersion = SleuthkitJNI.getVersion();
79 
80  if (skVersion == null) {
81  throw new Exception(NbBundle.getMessage(this.getClass(), "Installer.exception.tskVerStringNull.msg"));
82  } else if (skVersion.length() == 0) {
83  throw new Exception(NbBundle.getMessage(this.getClass(), "Installer.exception.taskVerStringBang.msg"));
84  } else {
85  logger.log(Level.CONFIG, "Sleuth Kit Version: {0}", skVersion); //NON-NLS
86  }
87 
88  } catch (Exception | UnsatisfiedLinkError e) {
89 
90  // Normal error box log handler won't be loaded yet, so show error here.
91  final Component parentComponent = null; // Use default window frame.
92  final int messageType = JOptionPane.ERROR_MESSAGE;
93 
94  final String message;
95  final String title;
96 
97  if (e instanceof OldAppLockException ex) {
98  logger.log(Level.SEVERE, "An older application already holds a lock on the libtsk_jni lib", ex);
99  message = Bundle.Installer_validate_tskLibLock_description();
100  title = Bundle.Installer_validate_tskLibLock_title();
101  } else {
102  logger.log(Level.SEVERE, "Error calling Sleuth Kit library (test call failed)", e); //NON-NLS
103  logger.log(Level.SEVERE, "Is Autopsy or Cyber Triage already running?)", e); //NON-NLS
104  message = NbBundle.getMessage(this.getClass(), "Installer.tskLibErr.msg", e.toString());
105  title = NbBundle.getMessage(this.getClass(), "Installer.tskLibErr.err");
106  }
107 
108  JOptionPane.showMessageDialog(
109  parentComponent,
110  message,
111  title,
112  messageType);
113 
114  // exit after user exits the error dialog box
115  LifecycleManager.getDefault().exit();
116  }
117 
118  }
119 
120  @Override
121  public void close() {
122  try {
124  } catch (Exception ex) {
125  Logger logger = Logger.getLogger(Installer.class.getName());
126  logger.log(Level.WARNING, "There was an error removing the TSK lib lock.", ex);
127  }
128  }
129 
130  @Override
131  public void uninstalled() {
132  try {
134  } catch (Exception ex) {
135  Logger logger = Logger.getLogger(Installer.class.getName());
136  logger.log(Level.WARNING, "There was an error removing the TSK lib lock.", ex);
137  }
138  }
139 
140 
141 
142 
146  static class OldAppLockException extends Exception {
147 
148  public OldAppLockException(String message) {
149  super(message);
150  }
151 
152  }
153 }
static synchronized Installer getDefault()
Definition: Installer.java:41
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2024 Sleuth Kit Labs. Generated on: Mon Mar 17 2025
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.