19 package org.sleuthkit.autopsy.modules.hashdatabase;
21 import java.util.Collections;
22 import java.util.LinkedHashMap;
23 import java.util.List;
25 import java.util.logging.Level;
26 import javax.swing.SwingWorker;
27 import org.netbeans.api.progress.ProgressHandle;
39 class HashDbSearcher {
40 private static final Logger logger = Logger.getLogger(HashDbSearcher.class.getName());
48 static List<AbstractFile> findFilesByMd5(String md5Hash)
throws NoCurrentCaseException {
49 final Case currentCase = Case.getCurrentCaseThrows();
50 final SleuthkitCase skCase = currentCase.getSleuthkitCase();
51 return skCase.findFilesByMd5(md5Hash);
62 static Map<String, List<AbstractFile>> findFilesBymd5(List<String> md5Hash)
throws NoCurrentCaseException {
63 Map<String, List<AbstractFile>> map =
new LinkedHashMap<String, List<AbstractFile>>();
64 for (String md5 : md5Hash) {
65 List<AbstractFile> files = findFilesByMd5(md5);
66 if (!files.isEmpty()) {
75 static Map<String, List<AbstractFile>> findFilesBymd5(List<String> md5Hash, ProgressHandle progress, SwingWorker<Object, Void> worker)
throws NoCurrentCaseException {
76 Map<String, List<AbstractFile>> map =
new LinkedHashMap<String, List<AbstractFile>>();
77 if (!worker.isCancelled()) {
78 progress.switchToDeterminate(md5Hash.size());
80 for (String md5 : md5Hash) {
81 if (worker.isCancelled()) {
84 List<AbstractFile> files = findFilesByMd5(md5);
85 if (!files.isEmpty()) {
89 if (!worker.isCancelled()) {
90 progress.progress(size);
105 static List<AbstractFile> findFiles(FsContent file) {
108 if ((md5 = file.getMd5Hash()) != null) {
109 return findFilesByMd5(md5);
111 return Collections.<AbstractFile>emptyList();
113 }
catch (NoCurrentCaseException ex) {
114 logger.log(Level.SEVERE,
"Exception while getting open case.", ex);
115 return Collections.<AbstractFile>emptyList();
125 static boolean allFilesMd5Hashed() throws NoCurrentCaseException {
126 final Case currentCase = Case.getCurrentCaseThrows();
127 final SleuthkitCase skCase = currentCase.getSleuthkitCase();
128 return skCase.allFilesMd5Hashed();
136 static int countFilesMd5Hashed() throws NoCurrentCaseException {
137 final Case currentCase = Case.getCurrentCaseThrows();
138 final SleuthkitCase skCase = currentCase.getSleuthkitCase();
139 return skCase.countFilesMd5Hashed();