Autopsy  4.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-2016 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;
34 
41 @ServiceProviders(value={
42  @ServiceProvider(service=DataSourceProcessor.class),
43  @ServiceProvider(service=AutomatedIngestDataSourceProcessor.class)}
44 )
46 
47  private static final String DATA_SOURCE_TYPE = NbBundle.getMessage(LocalDiskDSProcessor.class, "LocalDiskDSProcessor.dsType.text");
48  private final LocalDiskPanel configPanel;
49  private AddImageTask addDiskTask;
50  /*
51  * TODO: Remove the setDataSourceOptionsCalled flag and the settings fields
52  * when the deprecated method setDataSourceOptions is removed.
53  */
54  private String deviceId;
55  private String drivePath;
56  private String timeZone;
57  private boolean ignoreFatOrphanFiles;
58  private boolean setDataSourceOptionsCalled;
59 
67  configPanel = LocalDiskPanel.getDefault();
68  }
69 
77  public static String getType() {
78  return DATA_SOURCE_TYPE;
79  }
80 
88  @Override
89  public String getDataSourceType() {
90  return DATA_SOURCE_TYPE;
91  }
92 
101  @Override
102  public JPanel getPanel() {
103  configPanel.select();
104  return configPanel;
105  }
106 
114  @Override
115  public boolean isPanelValid() {
116  return configPanel.validatePanel();
117  }
118 
133  @Override
134  public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
135  if (!setDataSourceOptionsCalled) {
136  deviceId = UUID.randomUUID().toString();
137  drivePath = configPanel.getContentPaths();
138  timeZone = configPanel.getTimeZone();
139  ignoreFatOrphanFiles = configPanel.getNoFatOrphans();
140  }
141  addDiskTask = new AddImageTask(deviceId, drivePath, timeZone, ignoreFatOrphanFiles, progressMonitor, callback);
142  new Thread(addDiskTask).start();
143  }
144 
166  public void run(String deviceId, String drivePath, String timeZone, boolean ignoreFatOrphanFiles, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
167  addDiskTask = new AddImageTask(deviceId, drivePath, timeZone, ignoreFatOrphanFiles, progressMonitor, callback);
168  new Thread(addDiskTask).start();
169  }
170 
178  @Override
179  public void cancel() {
180  if (null != addDiskTask) {
181  addDiskTask.cancelTask();
182  }
183  }
184 
189  @Override
190  public void reset() {
191  configPanel.reset();
192  deviceId = null;
193  drivePath = null;
194  timeZone = null;
195  ignoreFatOrphanFiles = false;
196  setDataSourceOptionsCalled = false;
197  }
198 
212  @Deprecated
213  public void setDataSourceOptions(String drivePath, String timeZone, boolean ignoreFatOrphanFiles) {
214  this.deviceId = UUID.randomUUID().toString();
215  this.drivePath = drivePath;
216  this.timeZone = Calendar.getInstance().getTimeZone().getID();
217  this.ignoreFatOrphanFiles = ignoreFatOrphanFiles;
218  setDataSourceOptionsCalled = true;
219  }
220 
221  @Override
222  public int canProcess(Path dataSourcePath) throws AutomatedIngestDataSourceProcessorException {
223 
224  // verify that the data source is not a file or a directory
225  File file = dataSourcePath.toFile();
226  // ELTODO this needs to be tested more. should I keep isDirectory or just test for isFile?
227  if (file.isFile() || file.isDirectory()) {
228  return 0;
229  }
230 
231  // check whether data source is an existing disk or partition
232  // ELTODO this needs to be tested more. do these methods actually work correctly?
233  // or should I use PlatformUtil.getPhysicalDrives() and PlatformUtil.getPartitions() instead?
234  String path = dataSourcePath.toString();
235  if ( (DriveUtils.isPhysicalDrive(path) || DriveUtils.isPartition(path)) && DriveUtils.driveExists(path) ) {
236  return 90;
237  }
238 
239  return 0;
240  }
241 
242  @Override
243  public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) throws AutomatedIngestDataSourceProcessorException {
244  this.deviceId = deviceId;
245  this.drivePath = dataSourcePath.toString();
246  this.timeZone = Calendar.getInstance().getTimeZone().getID();
247  this.ignoreFatOrphanFiles = false;
248  setDataSourceOptionsCalled = true;
249  run(deviceId, drivePath, timeZone, ignoreFatOrphanFiles, progressMonitor, callBack);
250  }
251 
252 }
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: Mon Jan 2 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.