Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
HashDbSearcher.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011 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.hashdatabase;
20 
21 import java.util.Collections;
22 import java.util.LinkedHashMap;
23 import java.util.List;
24 import java.util.Map;
25 import javax.swing.SwingWorker;
26 import org.netbeans.api.progress.ProgressHandle;
31 
36  class HashDbSearcher {
37 
43  static List<AbstractFile> findFilesByMd5(String md5Hash) {
44  final Case currentCase = Case.getCurrentCase();
45  final SleuthkitCase skCase = currentCase.getSleuthkitCase();
46  return skCase.findFilesByMd5(md5Hash);
47  }
48 
55  static Map<String, List<AbstractFile>> findFilesBymd5(List<String> md5Hash) {
56  Map<String, List<AbstractFile>> map = new LinkedHashMap<String, List<AbstractFile>>();
57  for(String md5 : md5Hash) {
58  List<AbstractFile> files = findFilesByMd5(md5);
59  if(!files.isEmpty()) {
60  map.put(md5, files);
61  }
62  }
63  return map;
64  }
65  // Same as above, but with a given ProgressHandle to accumulate and StringWorker to check if cancelled
66  static Map<String, List<AbstractFile>> findFilesBymd5(List<String> md5Hash, ProgressHandle progress, SwingWorker<Object,Void> worker) {
67  Map<String, List<AbstractFile>> map = new LinkedHashMap<String, List<AbstractFile>>();
68  if(!worker.isCancelled()) {
69  progress.switchToDeterminate(md5Hash.size());
70  int size = 0;
71  for(String md5 : md5Hash) {
72  if(worker.isCancelled()) {
73  break;
74  }
75  List<AbstractFile> files = findFilesByMd5(md5);
76  if(!files.isEmpty()) {
77  map.put(md5, files);
78  }
79  size++;
80  if(!worker.isCancelled()) {
81  progress.progress(size);
82  }
83  }
84  }
85  return map;
86  }
87 
94  static List<AbstractFile> findFiles(FsContent file) {
95  String md5;
96  if((md5 = file.getMd5Hash()) != null) {
97  return findFilesByMd5(md5);
98  } else {
99  return Collections.<AbstractFile>emptyList();
100  }
101  }
102 
108  static boolean allFilesMd5Hashed() {
109  final Case currentCase = Case.getCurrentCase();
110  final SleuthkitCase skCase = currentCase.getSleuthkitCase();
111  return skCase.allFilesMd5Hashed();
112  }
113 
118  static int countFilesMd5Hashed() {
119  final Case currentCase = Case.getCurrentCase();
120  final SleuthkitCase skCase = currentCase.getSleuthkitCase();
121  return skCase.countFilesMd5Hashed();
122  }
123 }
List< AbstractFile > findFilesByMd5(String md5Hash)

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.