Autopsy  4.9.1
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 
43 @ServiceProviders(value={
44  @ServiceProvider(service=DataSourceProcessor.class),
45  @ServiceProvider(service=AutoIngestDataSourceProcessor.class)}
46 )
48 
49  private final RawDSInputPanel configPanel;
52  private static final List<FileFilter> filtersList = new ArrayList<>();
53  static {
54  filtersList.add(rawFilter);
55  filtersList.add(encaseFilter);
56  }
57 
58  // By default, split image into 2GB unallocated space chunks
59  private static final long DEFAULT_CHUNK_SIZE = 2000000000L; // 2 GB
60 
61  /*
62  * Constructs a Raw data source processor that implements the
63  * DataSourceProcessor service provider interface to allow integration with
64  * the add data source wizard. It also provides a run method overload to
65  * allow it to be used independently of the wizard.
66  */
67  public RawDSProcessor() {
68  configPanel = RawDSInputPanel.createInstance(RawDSProcessor.class.getName());
69  }
70 
78  @Messages({"RawDSProcessor.dataSourceType=Unallocated Space Image File"})
79  public static String getType() {
80  return Bundle.RawDSProcessor_dataSourceType();
81  }
82 
90  @Override
91  public String getDataSourceType() {
92  return Bundle.RawDSProcessor_dataSourceType();
93  }
94 
103  @Override
104  public JPanel getPanel() {
105  configPanel.readSettings();
106  configPanel.select();
107  return configPanel;
108  }
109 
117  @Override
118  public boolean isPanelValid() {
119  return configPanel.validatePanel();
120  }
121 
136  @Override
137  public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
138  configPanel.storeSettings();
139  run(UUID.randomUUID().toString(), configPanel.getImageFilePath(), configPanel.getTimeZone(), configPanel.getChunkSize(), progressMonitor, callback);
140  }
141 
164  private void run(String deviceId, String imageFilePath, String timeZone, long chunkSize, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
165  AddRawImageTask addImageTask = new AddRawImageTask(deviceId, imageFilePath, timeZone, chunkSize, progressMonitor, callback);
166  new Thread(addImageTask).start();
167  }
168 
169  @Override
170  public void cancel() {
171  }
172 
177  @Override
178  public void reset() {
179  configPanel.reset();
180  }
181 
182  private static boolean isAcceptedByFiler(File file, List<FileFilter> filters) {
183  for (FileFilter filter : filters) {
184  if (filter.accept(file)) {
185  return true;
186  }
187  }
188  return false;
189  }
190 
191  @Override
192  public int canProcess(Path dataSourcePath) throws AutoIngestDataSourceProcessorException {
193 
194  // only accept files
195  if (!new File(dataSourcePath.toString()).isFile()) {
196  return 0;
197  }
198 
199  // check file extension for supported types
200  if (!isAcceptedByFiler(dataSourcePath.toFile(), filtersList)) {
201  return 0;
202  }
203 
204  return 2;
205  }
206 
207  @Override
208  public void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack) {
209  run(deviceId, dataSourcePath.toString(), Calendar.getInstance().getTimeZone().getID(), DEFAULT_CHUNK_SIZE, progressMonitor, callBack);
210  }
211 
212 }
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-2018 Basis Technology. Generated on: Tue Dec 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.