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;
49 final class IngestModuleFactoryLoader {
51 private static final Logger logger = Logger.getLogger(IngestModuleFactoryLoader.class.getName());
52 private static final String SAMPLE_MODULE_FACTORY_CLASS_NAME = SampleIngestModuleFactory.class.getCanonicalName();
53 private static final ArrayList<String> coreModuleOrdering =
new ArrayList<String>() {
57 add(
"org.sleuthkit.autopsy.recentactivity.RecentActivityExtracterModuleFactory");
58 add(HashLookupModuleFactory.class.getCanonicalName());
59 add(FileTypeIdModuleFactory.class.getCanonicalName());
60 add(FileExtMismatchDetectorModuleFactory.class.getCanonicalName());
61 add(EmbeddedFileExtractorModuleFactory.class.getCanonicalName());
62 add(ExifParserModuleFactory.class.getCanonicalName());
63 add(
"org.sleuthkit.autopsy.keywordsearch.KeywordSearchModuleFactory");
64 add(
"org.sleuthkit.autopsy.thunderbirdparser.EmailParserModuleFactory");
65 add(EncryptionDetectionModuleFactory.class.getCanonicalName());
66 add(InterestingItemsIngestModuleFactory.class.getCanonicalName());
67 add(CentralRepoIngestModuleFactory.class.getCanonicalName());
68 add(PhotoRecCarverIngestModuleFactory.class.getCanonicalName());
69 add(VMExtractorIngestModuleFactory.class.getCanonicalName());
70 add(DataSourceIntegrityModuleFactory.class.getCanonicalName());
84 static List<IngestModuleFactory> getIngestModuleFactories() {
88 HashSet<String> moduleDisplayNames =
new HashSet<>();
89 HashMap<String, IngestModuleFactory> javaFactoriesByClass =
new HashMap<>();
93 for (IngestModuleFactory factory : Lookup.getDefault().lookupAll(IngestModuleFactory.class)) {
94 IngestModuleFactoryLoader.addFactory(factory, moduleDisplayNames, javaFactoriesByClass);
100 for (IngestModuleFactory factory : Lookup.getDefault().lookupAll(IngestModuleFactoryAdapter.class)) {
101 if (!javaFactoriesByClass.containsValue(factory)) {
102 IngestModuleFactoryLoader.addFactory(factory, moduleDisplayNames, javaFactoriesByClass);
109 List<IngestModuleFactory> factories =
new ArrayList<>();
110 for (String className : coreModuleOrdering) {
111 IngestModuleFactory coreFactory = javaFactoriesByClass.remove(className);
112 if (coreFactory != null) {
113 factories.add(coreFactory);
115 logger.log(Level.SEVERE,
"Core factory {0} not loaded", className);
121 TreeMap<String, IngestModuleFactory> javaFactoriesSortedByName =
new TreeMap<>();
122 for (IngestModuleFactory factory : javaFactoriesByClass.values()) {
123 javaFactoriesSortedByName.put(factory.getModuleDisplayName(), factory);
125 factories.addAll(javaFactoriesSortedByName.values());
129 for (IngestModuleFactory factory : JythonModuleLoader.getIngestModuleFactories()) {
130 if (!moduleDisplayNames.contains(factory.getModuleDisplayName())) {
131 moduleDisplayNames.add(factory.getModuleDisplayName());
132 factories.add(factory);
133 logger.log(Level.INFO,
"Found ingest module factory: name = {0}, version = {1}",
new Object[]{factory.getModuleDisplayName(), factory.getModuleVersionNumber()});
135 logger.log(Level.SEVERE,
"Found duplicate ingest module display name (name = {0})", factory.getModuleDisplayName());
136 DialogDisplayer.getDefault().notify(
new NotifyDescriptor.Message(
137 NbBundle.getMessage(IngestModuleFactoryLoader.class,
"IngestModuleFactoryLoader.errorMessages.duplicateDisplayName", factory.getModuleDisplayName()),
138 NotifyDescriptor.ERROR_MESSAGE));
145 private static void addFactory(IngestModuleFactory factory, HashSet<String> moduleDisplayNames, HashMap<String, IngestModuleFactory> javaFactoriesByClass) {
147 String className = factory.getClass().getCanonicalName();
148 if (className.equals(IngestModuleFactoryLoader.SAMPLE_MODULE_FACTORY_CLASS_NAME)) {
152 if (!moduleDisplayNames.contains(factory.getModuleDisplayName())) {
153 moduleDisplayNames.add(factory.getModuleDisplayName());
154 javaFactoriesByClass.put(factory.getClass().getCanonicalName(), factory);
155 logger.log(Level.INFO,
"Found ingest module factory: name = {0}, version = {1}",
new Object[]{factory.getModuleDisplayName(), factory.getModuleVersionNumber()});
157 logger.log(Level.SEVERE,
"Found duplicate ingest module display name (name = {0})", factory.getModuleDisplayName());
158 DialogDisplayer.getDefault().notify(
new NotifyDescriptor.Message(
159 NbBundle.getMessage(IngestModuleFactoryLoader.class,
"IngestModuleFactoryLoader.errorMessages.duplicateDisplayName", factory.getModuleDisplayName()),
160 NotifyDescriptor.ERROR_MESSAGE));