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>() {
54 private static final long serialVersionUID = 1L;
58 add(
"org.sleuthkit.autopsy.recentactivity.RecentActivityExtracterModuleFactory");
59 add(HashLookupModuleFactory.class.getCanonicalName());
60 add(FileTypeIdModuleFactory.class.getCanonicalName());
61 add(FileExtMismatchDetectorModuleFactory.class.getCanonicalName());
62 add(EmbeddedFileExtractorModuleFactory.class.getCanonicalName());
63 add(ExifParserModuleFactory.class.getCanonicalName());
64 add(
"org.sleuthkit.autopsy.keywordsearch.KeywordSearchModuleFactory");
65 add(
"org.sleuthkit.autopsy.thunderbirdparser.EmailParserModuleFactory");
66 add(EncryptionDetectionModuleFactory.class.getCanonicalName());
67 add(InterestingItemsIngestModuleFactory.class.getCanonicalName());
68 add(CentralRepoIngestModuleFactory.class.getCanonicalName());
69 add(PhotoRecCarverIngestModuleFactory.class.getCanonicalName());
70 add(VMExtractorIngestModuleFactory.class.getCanonicalName());
71 add(DataSourceIntegrityModuleFactory.class.getCanonicalName());
85 static List<IngestModuleFactory> getIngestModuleFactories() {
89 HashSet<String> moduleDisplayNames =
new HashSet<>();
90 HashMap<String, IngestModuleFactory> javaFactoriesByClass =
new HashMap<>();
94 for (IngestModuleFactory factory : Lookup.getDefault().lookupAll(IngestModuleFactory.class)) {
95 IngestModuleFactoryLoader.addFactory(factory, moduleDisplayNames, javaFactoriesByClass);
101 for (IngestModuleFactory factory : Lookup.getDefault().lookupAll(IngestModuleFactoryAdapter.class)) {
102 if (!javaFactoriesByClass.containsValue(factory)) {
103 IngestModuleFactoryLoader.addFactory(factory, moduleDisplayNames, javaFactoriesByClass);
110 List<IngestModuleFactory> factories =
new ArrayList<>();
111 for (String className : coreModuleOrdering) {
112 IngestModuleFactory coreFactory = javaFactoriesByClass.remove(className);
113 if (coreFactory != null) {
114 factories.add(coreFactory);
116 logger.log(Level.SEVERE,
"Core factory {0} not loaded", className);
122 TreeMap<String, IngestModuleFactory> javaFactoriesSortedByName =
new TreeMap<>();
123 for (IngestModuleFactory factory : javaFactoriesByClass.values()) {
124 javaFactoriesSortedByName.put(factory.getModuleDisplayName(), factory);
126 factories.addAll(javaFactoriesSortedByName.values());
130 for (IngestModuleFactory factory : JythonModuleLoader.getIngestModuleFactories()) {
131 if (!moduleDisplayNames.contains(factory.getModuleDisplayName())) {
132 moduleDisplayNames.add(factory.getModuleDisplayName());
133 factories.add(factory);
134 logger.log(Level.INFO,
"Found ingest module factory: name = {0}, version = {1}",
new Object[]{factory.getModuleDisplayName(), factory.getModuleVersionNumber()});
136 logger.log(Level.WARNING,
"Found duplicate ingest module display name (name = {0})", factory.getModuleDisplayName());
137 DialogDisplayer.getDefault().notify(
new NotifyDescriptor.Message(
138 NbBundle.getMessage(IngestModuleFactoryLoader.class,
"IngestModuleFactoryLoader.errorMessages.duplicateDisplayName", factory.getModuleDisplayName()),
139 NotifyDescriptor.ERROR_MESSAGE));
146 private static void addFactory(IngestModuleFactory factory, HashSet<String> moduleDisplayNames, HashMap<String, IngestModuleFactory> javaFactoriesByClass) {
148 String className = factory.getClass().getCanonicalName();
149 if (className.equals(IngestModuleFactoryLoader.SAMPLE_MODULE_FACTORY_CLASS_NAME)) {
153 if (!moduleDisplayNames.contains(factory.getModuleDisplayName())) {
154 moduleDisplayNames.add(factory.getModuleDisplayName());
155 javaFactoriesByClass.put(factory.getClass().getCanonicalName(), factory);
156 logger.log(Level.INFO,
"Found ingest module factory: name = {0}, version = {1}",
new Object[]{factory.getModuleDisplayName(), factory.getModuleVersionNumber()});
158 logger.log(Level.WARNING,
"Found duplicate ingest module display name (name = {0})", factory.getModuleDisplayName());
165 private IngestModuleFactoryLoader() {