Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
HashDbSearchAction.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 javax.swing.JOptionPane;
22 import org.openide.nodes.Node;
23 import org.openide.util.HelpCtx;
24 import org.openide.util.NbBundle;
25 import org.openide.util.actions.CallableSystemAction;
28 import org.sleuthkit.datamodel.AbstractFile;
29 import org.sleuthkit.datamodel.Content;
30 import org.sleuthkit.datamodel.ContentVisitor;
31 import org.sleuthkit.datamodel.Directory;
32 
39 public class HashDbSearchAction extends CallableSystemAction implements HashSearchProvider {
40 
42  private AbstractFile file;
43  private static HashDbSearchAction instance = null;
44 
46  super();
47  }
48 
49  public static HashDbSearchAction getDefault() {
50  if (instance == null) {
51  instance = new HashDbSearchAction();
52  }
53  return instance;
54  }
55 
56  @Override
57  public void search(Node contentNode) {
58  Content tempContent = contentNode.getLookup().lookup(Content.class);
59  this.file = tempContent.accept(initializeCV);
60  performAction();
61  }
62 
67  private static class InitializeContentVisitor extends ContentVisitor.Default<AbstractFile> {
68 
69  @Override
70  public AbstractFile visit(org.sleuthkit.datamodel.File f) {
71  return f;
72  }
73 
74  @Override
75  public AbstractFile visit(org.sleuthkit.datamodel.LocalFile lf) {
76  return lf;
77  }
78 
79  @Override
80  public AbstractFile visit(org.sleuthkit.datamodel.DerivedFile df) {
81  return df;
82  }
83 
84  @Override
85  public AbstractFile visit(Directory dir) {
86  return ContentUtils.isDotDirectory(dir) ? null : dir;
87  }
88 
89  @Override
90  protected AbstractFile defaultVisit(Content cntnt) {
91  return null;
92  }
93  }
94 
100  @Override
101  public void performAction() {
102  // Make sure at least 1 file has an md5 hash
103  if (HashDbSearcher.countFilesMd5Hashed() > 0) {
104  doSearch();
105  } else {
106  JOptionPane.showMessageDialog(null,
107  NbBundle.getMessage(this.getClass(),
108  "HashDbSearchAction.dlgMsg.noFilesHaveMD5Calculated"),
109  NbBundle.getMessage(this.getClass(), "HashDbSearchAction.dlgMsg.title"),
110  JOptionPane.ERROR_MESSAGE);
111  }
112  }
113 
114  private void doSearch() {
115  HashDbSearchThread hashThread = new HashDbSearchThread(file);
116  hashThread.execute();
117  }
118 
119  @Override
120  public String getName() {
121  return NbBundle.getMessage(this.getClass(), "HashDbSearchAction.getName.text");
122  }
123 
124  @Override
125  public HelpCtx getHelpCtx() {
126  return HelpCtx.DEFAULT_HELP;
127  }
128 }
static boolean isDotDirectory(AbstractFile dir)

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.