Autopsy  4.4
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-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.casemodule;
20 
21 import java.io.File;
22 import java.nio.file.Path;
23 import java.util.Calendar;
24 import java.util.UUID;
25 import javax.swing.JPanel;
26 import org.openide.util.NbBundle;
27 import org.openide.util.lookup.ServiceProvider;
28 import org.openide.util.lookup.ServiceProviders;
35 
42 @ServiceProviders(value = {
43  @ServiceProvider(service = DataSourceProcessor.class),
44  @ServiceProvider(service = AutoIngestDataSourceProcessor.class)}
45 )
47 
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 String timeZone;
59  private boolean ignoreFatOrphanFiles;
60  private boolean setDataSourceOptionsCalled;
61 
69  configPanel = LocalDiskPanel.getDefault();
70  }
71 
79  public static String getType() {
80  return DATA_SOURCE_TYPE;
81  }
82 
90  @Override
91  public String getDataSourceType() {
92  return DATA_SOURCE_TYPE;
93  }
94 
103  @Override
104  public JPanel getPanel() {
105  configPanel.refreshTable();
106  return configPanel;
107  }
108 
116  @Override
117  public boolean isPanelValid() {
118  return configPanel.validatePanel();
119  }
120 
135  @Override
136  public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
137  if (!setDataSourceOptionsCalled) {
138  deviceId = UUID.randomUUID().toString();
139  drivePath = configPanel.getContentPaths();
140  timeZone = configPanel.getTimeZone();
141  ignoreFatOrphanFiles = configPanel.getNoFatOrphans();
142  if (configPanel.getImageWriterEnabled()) {
143  imageWriterSettings = configPanel.getImageWriterSettings();
144  } else {
145  imageWriterSettings = null;
146  }
147  }
148  addDiskTask = new AddImageTask(deviceId, drivePath, timeZone, ignoreFatOrphanFiles, imageWriterSettings, progressMonitor, callback);
149  new Thread(addDiskTask).start();
150  }
151 
173  public void run(String deviceId, String drivePath, String timeZone, boolean ignoreFatOrphanFiles, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
174  addDiskTask = new AddImageTask(deviceId, drivePath, timeZone, ignoreFatOrphanFiles, imageWriterSettings, progressMonitor, callback);
175  new Thread(addDiskTask).start();
176  }
177 
185  @Override
186  public void cancel() {
187  if (null != addDiskTask) {
188  addDiskTask.cancelTask();
189  }
190  }
191 
196  @Override
197  public void reset() {
198  deviceId = null;
199  drivePath = null;
200  timeZone = null;
201  ignoreFatOrphanFiles = false;
202  setDataSourceOptionsCalled = false;
203  }
204 
205  @Override
206  public int canProcess(Path dataSourcePath) throws AutoIngestDataSourceProcessorException {
207 
208  // verify that the data source is not a file or a directory
209  File file = dataSourcePath.toFile();
210  // ELTODO this needs to be tested more. should I keep isDirectory or just test for isFile?
211  if (file.isFile() || file.isDirectory()) {
212  return 0;
213  }
214 
215  // check whether data source is an existing disk or partition
216  // ELTODO this needs to be tested more. do these methods actually work correctly?
217  // or should I use PlatformUtil.getPhysicalDrives() and PlatformUtil.getPartitions() instead?
218  String path = dataSourcePath.toString();
219  if ((DriveUtils.isPhysicalDrive(path) || DriveUtils.isPartition(path)) && DriveUtils.driveExists(path)) {
220  return 90;
221  }
222 
223  return 0;
224  }
225 
226  @Override
227  public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) throws AutoIngestDataSourceProcessorException {
228  this.deviceId = deviceId;
229  this.drivePath = dataSourcePath.toString();
230  this.timeZone = Calendar.getInstance().getTimeZone().getID();
231  this.ignoreFatOrphanFiles = false;
232  setDataSourceOptionsCalled = true;
233  run(deviceId, drivePath, timeZone, ignoreFatOrphanFiles, progressMonitor, callBack);
234  }
235 
249  @Deprecated
250  public void setDataSourceOptions(String drivePath, String timeZone, boolean ignoreFatOrphanFiles) {
251  this.deviceId = UUID.randomUUID().toString();
252  this.drivePath = drivePath;
253  this.timeZone = Calendar.getInstance().getTimeZone().getID();
254  this.ignoreFatOrphanFiles = ignoreFatOrphanFiles;
255  setDataSourceOptionsCalled = true;
256  }
257 
258 }
static boolean isPhysicalDrive(String path)
Definition: DriveUtils.java:43
static boolean driveExists(String path)
Definition: DriveUtils.java:66
void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
void run(String deviceId, String drivePath, String timeZone, boolean ignoreFatOrphanFiles, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
static boolean isPartition(String path)
Definition: DriveUtils.java:54
void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
void setDataSourceOptions(String drivePath, String timeZone, boolean ignoreFatOrphanFiles)

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