Autopsy  4.19.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
HashDbSearchManager.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2018 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.ArrayList;
22 import java.util.Collection;
23 import java.util.List;
24 import java.util.Map;
25 import javax.swing.JOptionPane;
26 import org.openide.nodes.AbstractNode;
27 import org.openide.nodes.Children;
28 import org.openide.nodes.Node;
29 import org.openide.util.NbBundle;
30 import org.openide.windows.TopComponent;
31 import org.openide.windows.WindowManager;
33 import org.sleuthkit.datamodel.AbstractFile;
34 
40 class HashDbSearchManager {
41 
42  private Map<String, List<AbstractFile>> map;
43  private List<AbstractFile> kvContents;
44 
45  public HashDbSearchManager(Map<String, List<AbstractFile>> map) {
46  this.map = map;
47  init();
48  }
49 
55  private void init() {
56  if (!map.isEmpty()) {
57  kvContents = new ArrayList<AbstractFile>();
58  int id = 0;
59  for (String s : map.keySet()) {
60  for (AbstractFile file : map.get(s)) {
61  kvContents.add(file);
62  }
63  }
64  }
65  }
66 
71  public void execute() {
72  if (!map.isEmpty()) {
73  Collection<AbstractFile> kvCollection = kvContents;
74  Node rootNode = null;
75 
76  if (kvCollection.size() > 0) {
77  Children childKeyValueContentNodes
78  = Children.create(new HashDbSearchResultFactory(kvCollection), true);
79 
80  rootNode = new AbstractNode(childKeyValueContentNodes);
81  } else {
82  rootNode = Node.EMPTY;
83  }
84 
85  final String pathText = NbBundle.getMessage(this.getClass(), "HashDbSearchManager.MD5HashSearch");
86  TopComponent searchResultWin = DataResultTopComponent.createInstance(
87  NbBundle.getMessage(this.getClass(), "HashDbSearchManager.MD5HashSearch"),
88  pathText,
89  rootNode,
90  kvCollection.size());
91 
92  searchResultWin.requestActive();
93  } else {
94  JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
95  NbBundle.getMessage(this.getClass(), "HashDbSearchManager.noResultsFoundMsg"));
96  }
97  }
98 }

Copyright © 2012-2021 Basis Technology. Generated on: Thu Sep 30 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.