Autopsy  4.6.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
RawDSProcessor.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-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.datasourceprocessors;
20 
21 import java.io.File;
22 import java.nio.file.Path;
23 import java.util.ArrayList;
24 import java.util.Calendar;
25 import java.util.List;
26 import java.util.UUID;
27 import javax.swing.JPanel;
28 import javax.swing.filechooser.FileFilter;
29 import org.openide.util.NbBundle.Messages;
30 import org.openide.util.lookup.ServiceProvider;
31 import org.openide.util.lookup.ServiceProviders;
36 
43 @ServiceProviders(value={
44  @ServiceProvider(service=DataSourceProcessor.class),
45  @ServiceProvider(service=AutoIngestDataSourceProcessor.class)}
46 )
48 
49  private final RawDSInputPanel configPanel;
50  private AddRawImageTask addImageTask;
53  private static final List<FileFilter> filtersList = new ArrayList<>();
54  static {
55  filtersList.add(rawFilter);
56  filtersList.add(encaseFilter);
57  }
58 
59  // By default, split image into 2GB unallocated space chunks
60  private static final long DEFAULT_CHUNK_SIZE = 2000000000L; // 2 GB
61 
62  /*
63  * Constructs a Raw data source processor that implements the
64  * DataSourceProcessor service provider interface to allow integration with
65  * the add data source wizard. It also provides a run method overload to
66  * allow it to be used independently of the wizard.
67  */
68  public RawDSProcessor() {
69  configPanel = RawDSInputPanel.createInstance(RawDSProcessor.class.getName());
70  }
71 
79  @Messages({"RawDSProcessor.dataSourceType=Unallocated Space Image File"})
80  public static String getType() {
81  return Bundle.RawDSProcessor_dataSourceType();
82  }
83 
91  @Override
92  public String getDataSourceType() {
93  return Bundle.RawDSProcessor_dataSourceType();
94  }
95 
104  @Override
105  public JPanel getPanel() {
106  configPanel.readSettings();
107  configPanel.select();
108  return configPanel;
109  }
110 
118  @Override
119  public boolean isPanelValid() {
120  return configPanel.validatePanel();
121  }
122 
137  @Override
138  public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
139  configPanel.storeSettings();
140  run(UUID.randomUUID().toString(), configPanel.getImageFilePath(), configPanel.getTimeZone(), configPanel.getChunkSize(), progressMonitor, callback);
141  }
142 
165  private void run(String deviceId, String imageFilePath, String timeZone, long chunkSize, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
166  addImageTask = new AddRawImageTask(deviceId, imageFilePath, timeZone, chunkSize, progressMonitor, callback);
167  new Thread(addImageTask).start();
168  }
169 
170  @Override
171  public void cancel() {
172  }
173 
178  @Override
179  public void reset() {
180  configPanel.reset();
181  }
182 
183  private static boolean isAcceptedByFiler(File file, List<FileFilter> filters) {
184  for (FileFilter filter : filters) {
185  if (filter.accept(file)) {
186  return true;
187  }
188  }
189  return false;
190  }
191 
192  @Override
193  public int canProcess(Path dataSourcePath) throws AutoIngestDataSourceProcessorException {
194 
195  // only accept files
196  if (!new File(dataSourcePath.toString()).isFile()) {
197  return 0;
198  }
199 
200  // check file extension for supported types
201  if (!isAcceptedByFiler(dataSourcePath.toFile(), filtersList)) {
202  return 0;
203  }
204 
205  return 2;
206  }
207 
208  @Override
209  public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) {
210  run(deviceId, dataSourcePath.toString(), Calendar.getInstance().getTimeZone().getID(), DEFAULT_CHUNK_SIZE, progressMonitor, callBack);
211  }
212 
213 }
void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
void run(String deviceId, String imageFilePath, String timeZone, long chunkSize, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
static final List< String > ENCASE_IMAGE_EXTS
static boolean isAcceptedByFiler(File file, List< FileFilter > filters)
void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)

Copyright © 2012-2016 Basis Technology. Generated on: Mon May 7 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.