19 package org.sleuthkit.autopsy.ingest;
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.HashSet;
24 import java.util.List;
25 import java.util.TreeMap;
26 import java.util.logging.Level;
27 import org.openide.DialogDisplayer;
28 import org.openide.NotifyDescriptor;
29 import org.openide.util.Lookup;
30 import org.openide.util.NbBundle;
46 final class IngestModuleFactoryLoader {
48 private static final Logger logger = Logger.getLogger(IngestModuleFactoryLoader.class.getName());
49 private static final String SAMPLE_MODULE_FACTORY_CLASS_NAME = SampleIngestModuleFactory.class.getCanonicalName();
50 private static final ArrayList<String> coreModuleOrdering =
new ArrayList<String>() {
54 add(
"org.sleuthkit.autopsy.recentactivity.RecentActivityExtracterModuleFactory");
55 add(HashLookupModuleFactory.class.getCanonicalName());
56 add(FileTypeIdModuleFactory.class.getCanonicalName());
57 add(EmbeddedFileExtractorModuleFactory.class.getCanonicalName());
58 add(ExifParserModuleFactory.class.getCanonicalName());
59 add(
"org.sleuthkit.autopsy.keywordsearch.KeywordSearchModuleFactory");
60 add(
"org.sleuthkit.autopsy.thunderbirdparser.EmailParserModuleFactory");
61 add(FileExtMismatchDetectorModuleFactory.class.getCanonicalName());
62 add(E01VerifierModuleFactory.class.getCanonicalName());
63 add(InterestingItemsIngestModuleFactory.class.getCanonicalName());
64 add(PhotoRecCarverIngestModuleFactory.class.getCanonicalName());
78 static List<IngestModuleFactory> getIngestModuleFactories() {
82 HashSet<String> moduleDisplayNames =
new HashSet<>();
83 HashMap<String, IngestModuleFactory> javaFactoriesByClass =
new HashMap<>();
87 for (IngestModuleFactory factory : Lookup.getDefault().lookupAll(IngestModuleFactory.class)) {
88 IngestModuleFactoryLoader.addFactory(factory, moduleDisplayNames, javaFactoriesByClass);
94 for (IngestModuleFactory factory : Lookup.getDefault().lookupAll(IngestModuleFactoryAdapter.class)) {
95 if (!javaFactoriesByClass.containsValue(factory)) {
96 IngestModuleFactoryLoader.addFactory(factory, moduleDisplayNames, javaFactoriesByClass);
103 List<IngestModuleFactory> factories =
new ArrayList<>();
104 for (String className : coreModuleOrdering) {
105 IngestModuleFactory coreFactory = javaFactoriesByClass.remove(className);
106 if (coreFactory != null) {
107 factories.add(coreFactory);
109 logger.log(Level.SEVERE,
"Core factory {0} not loaded", className);
115 TreeMap<String, IngestModuleFactory> javaFactoriesSortedByName =
new TreeMap<>();
116 for (IngestModuleFactory factory : javaFactoriesByClass.values()) {
117 javaFactoriesSortedByName.put(factory.getModuleDisplayName(), factory);
119 factories.addAll(javaFactoriesSortedByName.values());
123 for (IngestModuleFactory factory : JythonModuleLoader.getIngestModuleFactories()) {
124 if (!moduleDisplayNames.contains(factory.getModuleDisplayName())) {
125 moduleDisplayNames.add(factory.getModuleDisplayName());
126 factories.add(factory);
127 logger.log(Level.INFO,
"Found ingest module factory: name = {0}, version = {1}",
new Object[]{factory.getModuleDisplayName(), factory.getModuleVersionNumber()});
129 logger.log(Level.SEVERE,
"Found duplicate ingest module display name (name = {0})", factory.getModuleDisplayName());
130 DialogDisplayer.getDefault().notify(
new NotifyDescriptor.Message(
131 NbBundle.getMessage(IngestModuleFactoryLoader.class,
"IngestModuleFactoryLoader.errorMessages.duplicateDisplayName", factory.getModuleDisplayName()),
132 NotifyDescriptor.ERROR_MESSAGE));
139 private static void addFactory(IngestModuleFactory factory, HashSet<String> moduleDisplayNames, HashMap<String, IngestModuleFactory> javaFactoriesByClass) {
141 String className = factory.getClass().getCanonicalName();
142 if (className.equals(IngestModuleFactoryLoader.SAMPLE_MODULE_FACTORY_CLASS_NAME)) {
146 if (!moduleDisplayNames.contains(factory.getModuleDisplayName())) {
147 moduleDisplayNames.add(factory.getModuleDisplayName());
148 javaFactoriesByClass.put(factory.getClass().getCanonicalName(), factory);
149 logger.log(Level.INFO,
"Found ingest module factory: name = {0}, version = {1}",
new Object[]{factory.getModuleDisplayName(), factory.getModuleVersionNumber()});
151 logger.log(Level.SEVERE,
"Found duplicate ingest module display name (name = {0})", factory.getModuleDisplayName());
152 DialogDisplayer.getDefault().notify(
new NotifyDescriptor.Message(
153 NbBundle.getMessage(IngestModuleFactoryLoader.class,
"IngestModuleFactoryLoader.errorMessages.duplicateDisplayName", factory.getModuleDisplayName()),
154 NotifyDescriptor.ERROR_MESSAGE));