Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ImageDSProcessor.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 javax.swing.JPanel;
22 import java.util.ArrayList;
23 import java.util.Calendar;
24 import java.util.List;
25 import java.util.UUID;
26 import javax.swing.filechooser.FileFilter;
27 import org.openide.util.NbBundle;
28 import org.openide.util.lookup.ServiceProvider;
32 
39 @ServiceProvider(service = DataSourceProcessor.class)
40 public class ImageDSProcessor implements DataSourceProcessor {
41 
42  private final static String DATA_SOURCE_TYPE = NbBundle.getMessage(ImageDSProcessor.class, "ImageDSProcessor.dsType.text");
43  private static final List<String> allExt = new ArrayList<>();
47  private static final String allDesc = NbBundle.getMessage(ImageDSProcessor.class, "ImageDSProcessor.allDesc.text");
48  private static final GeneralFilter allFilter = new GeneralFilter(allExt, allDesc);
49  private static final List<FileFilter> filtersList = new ArrayList<>();
50  private final ImageFilePanel configPanel;
51  private AddImageTask addImageTask;
52  /*
53  * TODO: Remove the setDataSourceOptionsCalled flag and the settings fields
54  * when the deprecated method setDataSourceOptions is removed.
55  */
56  private String deviceId;
57  private String imagePath;
58  private String timeZone;
59  private boolean ignoreFatOrphanFiles;
60  private boolean setDataSourceOptionsCalled;
61 
62  static {
63  filtersList.add(allFilter);
64  filtersList.add(rawFilter);
65  filtersList.add(encaseFilter);
66  filtersList.add(virtualMachineFilter);
67  allExt.addAll(GeneralFilter.RAW_IMAGE_EXTS);
68  allExt.addAll(GeneralFilter.ENCASE_IMAGE_EXTS);
69  allExt.addAll(GeneralFilter.VIRTUAL_MACHINE_EXTS);
70  }
71 
78  public ImageDSProcessor() {
79  configPanel = ImageFilePanel.createInstance(ImageDSProcessor.class.getName(), filtersList);
80  }
81 
89  public static String getType() {
90  return DATA_SOURCE_TYPE;
91  }
92 
100  @Override
101  public String getDataSourceType() {
102  return getType();
103  }
104 
113  @Override
114  public JPanel getPanel() {
115  configPanel.readSettings();
116  configPanel.select();
117  return configPanel;
118  }
119 
127  @Override
128  public boolean isPanelValid() {
129  return configPanel.validatePanel();
130  }
131 
146  @Override
147  public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
148  if (!setDataSourceOptionsCalled) {
149  configPanel.storeSettings();
150  deviceId = UUID.randomUUID().toString();
151  imagePath = configPanel.getContentPaths();
152  timeZone = configPanel.getTimeZone();
153  ignoreFatOrphanFiles = configPanel.getNoFatOrphans();
154  }
155  run(deviceId, imagePath, timeZone, ignoreFatOrphanFiles, progressMonitor, callback);
156  }
157 
179  public void run(String deviceId, String imagePath, String timeZone, boolean ignoreFatOrphanFiles, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
180  addImageTask = new AddImageTask(deviceId, imagePath, timeZone, ignoreFatOrphanFiles, progressMonitor, callback);
181  new Thread(addImageTask).start();
182  }
183 
191  @Override
192  public void cancel() {
193  addImageTask.cancelTask();
194  }
195 
200  @Override
201  public void reset() {
202  deviceId = null;
203  imagePath = null;
204  timeZone = null;
205  ignoreFatOrphanFiles = false;
206  configPanel.reset();
207  setDataSourceOptionsCalled = false;
208  }
209 
223  @Deprecated
224  public void setDataSourceOptions(String imagePath, String timeZone, boolean ignoreFatOrphanFiles) {
225  this.deviceId = UUID.randomUUID().toString();
226  this.imagePath = imagePath;
227  this.timeZone = Calendar.getInstance().getTimeZone().getID();
228  this.ignoreFatOrphanFiles = ignoreFatOrphanFiles;
229  setDataSourceOptionsCalled = true;
230  }
231 
232 }
static synchronized ImageFilePanel createInstance(String context, List< FileFilter > fileChooserFilters)
void run(String deviceId, String imagePath, String timeZone, boolean ignoreFatOrphanFiles, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
static final List< String > VIRTUAL_MACHINE_EXTS
static final List< String > ENCASE_IMAGE_EXTS
void setDataSourceOptions(String imagePath, String timeZone, boolean ignoreFatOrphanFiles)
void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.