Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
PictureAnalyzerIngestModule.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2020 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.modules.pictureanalyzer;
20 
21 import java.util.Collection;
22 
23 import org.openide.util.Lookup;
24 import org.openide.util.NbBundle;
25 
30 
31 import org.sleuthkit.datamodel.AbstractFile;
32 import org.sleuthkit.datamodel.TskData;
33 
41 
43  private Collection<? extends PictureProcessor> registry;
45 
46  @Override
47  public ProcessResult process(AbstractFile file) {
48  // Skip non files, known files, and unallocated/slack files.
49  if (!file.isFile() || file.getKnown().equals(TskData.FileKnown.KNOWN) ||
50  (file.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.UNALLOC_BLOCKS)
51  || (file.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.SLACK)))) {
52  return ProcessResult.OK;
53  }
54 
55  for (PictureProcessor processor : registry) {
56  final String fileMimeType = fileTypeDetector.getMIMEType(file);
57 
58  for (String supportedMimeType : processor.mimeTypes()) {
59 
60  if (context.fileIngestIsCancelled()) {
61  return ProcessResult.OK;
62  }
63 
64  if (supportedMimeType.equalsIgnoreCase(fileMimeType)) {
65  processor.process(context, file);
66  }
67  }
68  }
69  return ProcessResult.OK;
70  }
71 
72  @Override
73  @NbBundle.Messages({
74  "PictureAnalyzerIngestModule.cannot_run_file_type=Cannot run file type detection."
75  })
76  public void startUp(IngestJobContext context) throws IngestModuleException {
77  registry = Lookup.getDefault().lookupAll(PictureProcessor.class);
78  this.context = context;
79  try {
80  fileTypeDetector = new FileTypeDetector();
82  throw new IngestModuleException(Bundle.PictureAnalyzerIngestModule_cannot_run_file_type(), ex);
83  }
84  }
85 
86 }

Copyright © 2012-2022 Basis Technology. Generated on: Sun Sep 25 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.