19 package org.sleuthkit.autopsy.casemodule;
 
   22 import java.nio.file.Path;
 
   23 import javax.swing.JPanel;
 
   24 import java.util.ArrayList;
 
   25 import java.util.Calendar;
 
   26 import java.util.List;
 
   27 import java.util.logging.Level;
 
   28 import java.util.UUID;
 
   29 import javax.swing.filechooser.FileFilter;
 
   30 import org.apache.commons.lang3.StringUtils;
 
   31 import org.openide.util.NbBundle;
 
   32 import org.openide.util.lookup.ServiceProvider;
 
   33 import org.openide.util.lookup.ServiceProviders;
 
   54 @ServiceProviders(value = {
 
   55     @ServiceProvider(service = DataSourceProcessor.class),
 
   56     @ServiceProvider(service = AutoIngestDataSourceProcessor.class)}
 
   60     private final static String DATA_SOURCE_TYPE = NbBundle.getMessage(
ImageDSProcessor.class, 
"ImageDSProcessor.dsType.text");
 
   62     private static final List<String> allExt = 
new ArrayList<>();
 
   66     private static final String ALL_DESC = NbBundle.getMessage(
ImageDSProcessor.class, 
"ImageDSProcessor.allDesc.text");
 
   68     private static final List<FileFilter> filtersList = 
new ArrayList<>();
 
   89         filtersList.add(allFilter);
 
   90         filtersList.add(rawFilter);
 
   91         filtersList.add(encaseFilter);
 
   94         if (!System.getProperty(
"os.name").toLowerCase().contains(
"mac")) {
 
   95             filtersList.add(virtualMachineFilter);
 
  115     static List<FileFilter> getFileFiltersList() {
 
  127         return DATA_SOURCE_TYPE;
 
  188         run(null, null, progressMonitor, callback);
 
  208         run(null, host, progressMonitor, callback);
 
  214         ingestStream = 
new DefaultIngestStream();
 
  215         readConfigSettings();
 
  217         this.password = StringUtils.defaultString(password, this.password);
 
  220                     new String[]{imagePath}, sectorSize, timeZone, md5, sha1, sha256, deviceId, this.password, this.host);
 
  222             logger.log(Level.SEVERE, 
"Error adding data source with path " + imagePath + 
" to database", ex);
 
  223             final List<String> errors = 
new ArrayList<>();
 
  224             errors.add(ex.getMessage());
 
  229         doAddImageProcess(deviceId, imagePath, sectorSize, timeZone, ignoreFatOrphanFiles, md5, sha1, sha256, this.password, progressMonitor, callback);
 
  255         ingestStream = 
new DefaultIngestStream();
 
  258                     new String[]{imagePath}, sectorSize, timeZone, 
"", 
"", 
"", deviceId, null, null);
 
  260             logger.log(Level.SEVERE, 
"Error adding data source with path " + imagePath + 
" to database", ex);
 
  261             final List<String> errors = 
new ArrayList<>();
 
  262             errors.add(ex.getMessage());
 
  267         doAddImageProcess(deviceId, imagePath, 0, timeZone, ignoreFatOrphanFiles, null, null, null, this.password, progressMonitor, callback);
 
  292         runWithIngestStream(null, null, settings, progress, callBack);
 
  316         runWithIngestStream(null, host, settings, progress, callBack);
 
  325         readConfigSettings();
 
  327         this.password = StringUtils.defaultString(password, this.password);
 
  332                     new String[]{imagePath}, sectorSize, timeZone, md5, sha1, sha256, deviceId, this.password, this.host);
 
  334             logger.log(Level.SEVERE, 
"Error adding data source with path " + imagePath + 
" to database", ex);
 
  335             final List<String> errors = 
new ArrayList<>();
 
  336             errors.add(ex.getMessage());
 
  345             logger.log(Level.SEVERE, 
"Error starting ingest modules", ex);
 
  349             ingestStream = 
new DefaultIngestStream();
 
  352         doAddImageProcess(deviceId, imagePath, sectorSize, timeZone, ignoreFatOrphanFiles, md5, sha1, sha256, this.password, progress, callBack);
 
  361         deviceId = UUID.randomUUID().toString();
 
  366         md5 = configPanel.getMd5();
 
  370         sha1 = configPanel.getSha1();
 
  371         if (sha1.isEmpty()) {
 
  374         sha256 = configPanel.getSha256();
 
  375         if (sha256.isEmpty()) {
 
  378         this.password = configPanel.getPassword();
 
  379         if (this.password.isEmpty()) {
 
  425     private void doAddImageProcess(String deviceId, String imagePath, 
int sectorSize, String timeZone, 
boolean ignoreFatOrphanFiles, String md5, String sha1, String sha256, String password, 
DataSourceProcessorProgressMonitor progressMonitor, 
DataSourceProcessorCallback callback) {
 
  428         if (ingestStream == null) {
 
  429             String message = 
"Ingest stream was not initialized before running the add image process on " + imagePath;
 
  430             logger.log(Level.SEVERE, message);
 
  431             final List<String> errors = 
new ArrayList<>();
 
  437             String message = 
"Image was not added to database before running the add image process on " + imagePath;
 
  438             logger.log(Level.SEVERE, message);
 
  439             final List<String> errors = 
new ArrayList<>();
 
  445         AddImageTask.ImageDetails imageDetails = 
new AddImageTask.ImageDetails(deviceId, image, sectorSize, timeZone, ignoreFatOrphanFiles, md5, sha1, sha256, null, password);
 
  446         addImageTask = 
new AddImageTask(imageDetails,
 
  448                 new StreamingAddDataSourceCallbacks(ingestStream),
 
  449                 new StreamingAddImageTaskCallback(ingestStream, callback));
 
  450         new Thread(addImageTask).start();
 
  462         if (null != addImageTask) {
 
  463             addImageTask.cancelTask();
 
  465         if (ingestStream != null) {
 
  479         ignoreFatOrphanFiles = 
false;
 
  486         for (FileFilter filter : filters) {
 
  487             if (filter.accept(file)) {
 
  496         return canProcess(dataSourcePath, null);
 
  505         if (!isAcceptedByFiler(dataSourcePath.toFile(), filtersList)) {
 
  510             if (password == null) {
 
  525         } 
catch (Exception ex) {
 
  535         process(deviceId, dataSourcePath, null, null, progressMonitor, callBack);
 
  540         process(deviceId, dataSourcePath, null, host, progressMonitor, callBack);
 
  546         this.deviceId = deviceId;
 
  547         this.imagePath = dataSourcePath.toString();
 
  549         this.timeZone = Calendar.getInstance().getTimeZone().getID();
 
  550         this.password = StringUtils.defaultString(password, this.password);
 
  552         this.ignoreFatOrphanFiles = 
false;
 
  554         ingestStream = 
new DefaultIngestStream();
 
  557                     new String[]{imagePath}, sectorSize, timeZone, 
"", 
"", 
"", deviceId, this.password, host);
 
  559             logger.log(Level.SEVERE, 
"Error adding data source with path " + imagePath + 
" to database", ex);
 
  560             final List<String> errors = 
new ArrayList<>();
 
  561             errors.add(ex.getMessage());
 
  566         doAddImageProcess(deviceId, dataSourcePath.toString(), sectorSize, timeZone, ignoreFatOrphanFiles, null, null, null, this.password, progressMonitor, callBack);
 
  573         return processWithIngestStream(deviceId, dataSourcePath, null, null, settings, progressMonitor, callBack);
 
  578         return processWithIngestStream(deviceId, dataSourcePath, null, host, settings, progressMonitor, callBack);
 
  584         this.deviceId = deviceId;
 
  585         this.imagePath = dataSourcePath.toString();
 
  587         this.timeZone = Calendar.getInstance().getTimeZone().getID();
 
  589         this.password = password;
 
  590         this.ignoreFatOrphanFiles = 
false;
 
  595                     new String[]{imagePath}, sectorSize, timeZone, md5, sha1, sha256, deviceId, password, host);
 
  597             logger.log(Level.SEVERE, 
"Error adding data source with path " + imagePath + 
" to database", ex);
 
  598             final List<String> errors = 
new ArrayList<>();
 
  599             errors.add(ex.getMessage());
 
  608             logger.log(Level.SEVERE, 
"Error starting ingest modules", ex);
 
  609             final List<String> errors = 
new ArrayList<>();
 
  610             errors.add(ex.getMessage());
 
  615         doAddImageProcess(deviceId, dataSourcePath.toString(), sectorSize, timeZone, ignoreFatOrphanFiles, null, null, null, password, progressMonitor, callBack);
 
IngestStream openIngestStream(DataSource dataSource, IngestJobSettings settings)
void doAddImageProcess(String deviceId, String imagePath, int sectorSize, String timeZone, boolean ignoreFatOrphanFiles, String md5, String sha1, String sha256, String password, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
static synchronized IngestManager getInstance()
boolean getNoFatOrphans()
void run(Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
void readConfigSettings()
void process(String deviceId, Path dataSourcePath, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
String getDataSourceType()
static boolean isAcceptedByFiler(File file, List< FileFilter > filters)
void run(String password, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
boolean supportsIngestStream()
static final String RAW_IMAGE_DESC
static final String VIRTUAL_MACHINE_DESC
static synchronized ImageFilePanel createInstance(String context, List< FileFilter > fileChooserFilters)
IngestStream processWithIngestStream(String deviceId, Path dataSourcePath, IngestJobSettings settings, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
AddImageTask addImageTask
void run(String deviceId, String imagePath, String timeZone, boolean ignoreFatOrphanFiles, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
IngestStream processWithIngestStream(String deviceId, Path dataSourcePath, String password, Host host, IngestJobSettings settings, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
static final String ENCASE_IMAGE_DESC
int canProcess(Path dataSourcePath, String password)
void done(DataSourceProcessorResult result, List< String > errList, List< Content > newDataSources)
IngestStream processWithIngestStream(String deviceId, Path dataSourcePath, Host host, IngestJobSettings settings, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
boolean ignoreFatOrphanFiles
static final List< String > VIRTUAL_MACHINE_EXTS
static final List< String > ENCASE_IMAGE_EXTS
SleuthkitCase getSleuthkitCase()
static Image addImageToDatabase(SleuthkitCase skCase, String[] imagePaths, int sectorSize, String timeZone, String md5fromSettings, String sha1fromSettings, String sha256fromSettings, String deviceId)
void runWithIngestStream(String password, Host host, IngestJobSettings settings, DataSourceProcessorProgressMonitor progress, DataSourceProcessorCallback callBack)
static boolean imageHasFileSystem(Path dataSourcePath)
boolean isValidationLoading()
void process(String deviceId, Path dataSourcePath, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
void runWithIngestStream(IngestJobSettings settings, DataSourceProcessorProgressMonitor progress, DataSourceProcessorCallback callBack)
void process(String deviceId, Path dataSourcePath, String password, Host host, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callBack)
final ImageFilePanel configPanel
void runWithIngestStream(Host host, IngestJobSettings settings, DataSourceProcessorProgressMonitor progress, DataSourceProcessorCallback callBack)
static final List< String > RAW_IMAGE_EXTS
int canProcess(Path dataSourcePath)