Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
LocalDiskDSProcessor.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2013-2021 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 */
19package org.sleuthkit.autopsy.casemodule;
20
21import java.util.ArrayList;
22import java.util.List;
23import java.util.UUID;
24import java.util.logging.Level;
25import javax.swing.JPanel;
26import org.openide.util.NbBundle;
27import org.openide.util.lookup.ServiceProvider;
28import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback;
29import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor;
30import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
31import org.sleuthkit.autopsy.coreutils.Logger;
32import org.sleuthkit.autopsy.imagewriter.ImageWriterSettings;
33import org.sleuthkit.datamodel.Host;
34import org.sleuthkit.datamodel.Image;
35import org.sleuthkit.datamodel.SleuthkitJNI;
36import org.sleuthkit.datamodel.TskCoreException;
37
44@ServiceProvider(service = DataSourceProcessor.class)
46
47 private final Logger logger = Logger.getLogger(LocalDiskDSProcessor.class.getName());
48 private static final String DATA_SOURCE_TYPE = NbBundle.getMessage(LocalDiskDSProcessor.class, "LocalDiskDSProcessor.dsType.text");
49 private final LocalDiskPanel configPanel;
50 private AddImageTask addDiskTask;
51 /*
52 * TODO: Remove the setDataSourceOptionsCalled flag and the settings fields
53 * when the deprecated method setDataSourceOptions is removed.
54 */
55 private String deviceId;
56 private String drivePath;
57 private int sectorSize;
58 private String timeZone;
59 private Host host;
61 private boolean ignoreFatOrphanFiles;
62 private String password;
63
71 configPanel = LocalDiskPanel.getDefault();
72 }
73
81 public static String getType() {
82 return DATA_SOURCE_TYPE;
83 }
84
92 @Override
93 public String getDataSourceType() {
94 return DATA_SOURCE_TYPE;
95 }
96
105 @Override
106 public JPanel getPanel() {
107 configPanel.resetLocalDiskSelection();
108 return configPanel;
109 }
110
118 @Override
119 public boolean isPanelValid() {
120 return configPanel.validatePanel();
121 }
122
137 @Override
139 run(null, null, progressMonitor, callback);
140 }
141
142 @Override
143 public void run(Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
144 run(null, host, progressMonitor, callback);
145 }
146
162 @Override
163 public void run(String password, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
164 deviceId = UUID.randomUUID().toString();
165 drivePath = configPanel.getContentPath();
166 sectorSize = configPanel.getSectorSize();
167 timeZone = configPanel.getTimeZone();
168 ignoreFatOrphanFiles = configPanel.getNoFatOrphans();
169 if (configPanel.getImageWriterEnabled()) {
170 imageWriterSettings = configPanel.getImageWriterSettings();
171 } else {
172 imageWriterSettings = null;
173 }
174
175 this.host = host;
176 this.password = password;
177
178 Image image;
179 try {
180 image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(),
181 new String[]{drivePath}, sectorSize,
182 timeZone, null, null, null, deviceId, this.password, this.host);
183 } catch (TskCoreException ex) {
184 logger.log(Level.SEVERE, "Error adding local disk with path " + drivePath + " to database", ex);
185 final List<String> errors = new ArrayList<>();
186 errors.add(ex.getMessage());
188 return;
189 }
190
191 addDiskTask = new AddImageTask(
192 new AddImageTask.ImageDetails(deviceId, image, sectorSize, timeZone, ignoreFatOrphanFiles, null, null, null, imageWriterSettings, this.password),
193 progressMonitor,
194 new StreamingAddDataSourceCallbacks(new DefaultIngestStream()),
195 new StreamingAddImageTaskCallback(new DefaultIngestStream(), callback));
196 new Thread(addDiskTask).start();
197 }
198
220 public void run(String deviceId, String drivePath, String timeZone, boolean ignoreFatOrphanFiles, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
221 run(deviceId, drivePath, 0, timeZone, ignoreFatOrphanFiles, progressMonitor, callback);
222 }
223
246 private void run(String deviceId, String drivePath, int sectorSize, String timeZone, boolean ignoreFatOrphanFiles, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
247 Image image;
248 try {
249 image = SleuthkitJNI.addImageToDatabase(Case.getCurrentCase().getSleuthkitCase(),
250 new String[]{drivePath}, sectorSize,
251 timeZone, null, null, null, deviceId, this.password, null);
252 } catch (TskCoreException ex) {
253 logger.log(Level.SEVERE, "Error adding local disk with path " + drivePath + " to database", ex);
254 final List<String> errors = new ArrayList<>();
255 errors.add(ex.getMessage());
257 return;
258 }
259
260 addDiskTask = new AddImageTask(new AddImageTask.ImageDetails(deviceId, image, sectorSize, timeZone, ignoreFatOrphanFiles, null, null, null, imageWriterSettings, this.password),
261 progressMonitor,
262 new StreamingAddDataSourceCallbacks(new DefaultIngestStream()),
263 new StreamingAddImageTaskCallback(new DefaultIngestStream(), callback));
264 new Thread(addDiskTask).start();
265 }
266
274 @Override
275 public void cancel() {
276 if (null != addDiskTask) {
277 addDiskTask.cancelTask();
278 }
279 }
280
285 @Override
286 public void reset() {
287 deviceId = null;
288 drivePath = null;
289 timeZone = null;
290 ignoreFatOrphanFiles = false;
291 }
292}
void run(String password, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
void run(String deviceId, String drivePath, int sectorSize, String timeZone, boolean ignoreFatOrphanFiles, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
void run(String deviceId, String drivePath, String timeZone, boolean ignoreFatOrphanFiles, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
void run(Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
void done(DataSourceProcessorResult result, List< String > errList, List< Content > newDataSources)
synchronized static Logger getLogger(String name)
Definition Logger.java:124

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