Autopsy  4.21.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-2018 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 import org.sleuthkit.datamodel.Host;
37 import org.sleuthkit.datamodel.TskCoreException;
38 
45 @ServiceProviders(value={
46  @ServiceProvider(service=DataSourceProcessor.class),
47  @ServiceProvider(service=AutoIngestDataSourceProcessor.class)}
48 )
50 
51  private final RawDSInputPanel configPanel;
54  private static final List<FileFilter> filtersList = new ArrayList<>();
55  static {
56  filtersList.add(rawFilter);
57  filtersList.add(encaseFilter);
58  }
59 
60  // By default, split image into 2GB unallocated space chunks
61  private static final long DEFAULT_CHUNK_SIZE = 2000000000L; // 2 GB
62 
63  /*
64  * Constructs a Raw data source processor that implements the
65  * DataSourceProcessor service provider interface to allow integration with
66  * the add data source wizard. It also provides a run method overload to
67  * allow it to be used independently of the wizard.
68  */
69  public RawDSProcessor() {
70  configPanel = RawDSInputPanel.createInstance(RawDSProcessor.class.getName());
71  }
72 
80  @Messages({"RawDSProcessor.dataSourceType=Unallocated Space Image File"})
81  public static String getType() {
82  return Bundle.RawDSProcessor_dataSourceType();
83  }
84 
92  @Override
93  public String getDataSourceType() {
94  return Bundle.RawDSProcessor_dataSourceType();
95  }
96 
105  @Override
106  public JPanel getPanel() {
107  configPanel.readSettings();
108  configPanel.select();
109  return configPanel;
110  }
111 
119  @Override
120  public boolean isPanelValid() {
121  return configPanel.validatePanel();
122  }
123 
138  @Override
139  public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
140  run(null, progressMonitor, callback);
141  }
142 
158  @Override
159  public void run(Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
160  configPanel.storeSettings();
161  run(UUID.randomUUID().toString(), configPanel.getImageFilePath(), configPanel.getTimeZone(), configPanel.getChunkSize(), host, progressMonitor, callback);
162  }
163 
187  private void run(String deviceId, String imageFilePath, String timeZone, long chunkSize, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
188  AddRawImageTask addImageTask = new AddRawImageTask(deviceId, imageFilePath, timeZone, chunkSize, host, progressMonitor, callback);
189  new Thread(addImageTask).start();
190  }
191 
192  @Override
193  public void cancel() {
194  }
195 
200  @Override
201  public void reset() {
202  configPanel.reset();
203  }
204 
205  private static boolean isAcceptedByFiler(File file, List<FileFilter> filters) {
206  for (FileFilter filter : filters) {
207  if (filter.accept(file)) {
208  return true;
209  }
210  }
211  return false;
212  }
213 
214  @Override
215  public int canProcess(Path dataSourcePath) throws AutoIngestDataSourceProcessorException {
216 
217  // only accept files
218  if (!new File(dataSourcePath.toString()).isFile()) {
219  return 0;
220  }
221 
222  // check file extension for supported types
223  if (!isAcceptedByFiler(dataSourcePath.toFile(), filtersList)) {
224  return 0;
225  }
226 
227  return 2;
228  }
229 
230  @Override
231  public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) {
232  process(deviceId, dataSourcePath, null, progressMonitor, callBack);
233  }
234 
235  @Override
236  public void process(String deviceId, Path dataSourcePath, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) {
237  run(deviceId, dataSourcePath.toString(), Calendar.getInstance().getTimeZone().getID(), DEFAULT_CHUNK_SIZE, host, progressMonitor, callBack);
238  }
239 
240 }
void run(String deviceId, String imageFilePath, String timeZone, long chunkSize, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
void process(String deviceId, Path dataSourcePath, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
static final List< String > ENCASE_IMAGE_EXTS
static boolean isAcceptedByFiler(File file, List< FileFilter > filters)
void run(Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)

Copyright © 2012-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.