Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
ImageNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2014 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.datamodel;
20 
21 import java.awt.event.ActionEvent;
22 import java.sql.ResultSet;
23 import java.sql.SQLException;
24 import java.util.ArrayList;
25 import java.util.Collections;
26 import java.util.List;
27 import java.util.logging.Level;
28 import javax.swing.AbstractAction;
29 import javax.swing.Action;
30 import org.openide.nodes.Sheet;
31 import org.openide.util.NbBundle;
32 import org.openide.util.NbBundle.Messages;
39 import org.sleuthkit.datamodel.Content;
40 import org.sleuthkit.datamodel.Image;
41 import org.sleuthkit.datamodel.SleuthkitCase.CaseDbQuery;
42 import org.sleuthkit.datamodel.TskCoreException;
43 
48 public class ImageNode extends AbstractContentNode<Image> {
49 
50  private static final Logger logger = Logger.getLogger(ImageNode.class.getName());
51 
60  static String nameForImage(Image i) {
61  return i.getName();
62  }
63 
67  public ImageNode(Image img) {
68  super(img);
69 
70  // set name, display name, and icon
71  String imgName = nameForImage(img);
72  this.setDisplayName(imgName);
73  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/hard-drive-icon.jpg"); //NON-NLS
74  }
75 
83  @Override
84  @Messages({"ImageNode.action.runIngestMods.text=Run Ingest Modules",
85  "ImageNode.getActions.openFileSearchByAttr.text=Open File Search by Attributes",})
86  public Action[] getActions(boolean context) {
87 
88 
89 
90  List<Action> actionsList = new ArrayList<Action>();
91  for (Action a : super.getActions(true)) {
92  actionsList.add(a);
93  }
94  actionsList.addAll(ExplorerNodeActionVisitor.getActions(content));
95  actionsList.add(new FileSearchAction(
96  Bundle.ImageNode_getActions_openFileSearchByAttr_text()));
97  actionsList.add(new AbstractAction(
98  Bundle.ImageNode_action_runIngestMods_text()) {
99  @Override
100  public void actionPerformed(ActionEvent e) {
101  final RunIngestModulesDialog ingestDialog = new RunIngestModulesDialog(Collections.<Content>singletonList(content));
102  ingestDialog.display();
103  }
104  });
105 
106  actionsList.add(new NewWindowViewAction(
107  NbBundle.getMessage(this.getClass(), "ImageNode.getActions.viewInNewWin.text"), this));
108  return actionsList.toArray(new Action[0]);
109  }
110 
111  @Override
112  @Messages({"ImageNode.createSheet.size.name=Size (Bytes)",
113  "ImageNode.createSheet.size.displayName=Size (Bytes)",
114  "ImageNode.createSheet.size.desc=Size of the data source in bytes.",
115  "ImageNode.createSheet.type.name=Type",
116  "ImageNode.createSheet.type.displayName=Type",
117  "ImageNode.createSheet.type.desc=Type of the image.",
118  "ImageNode.createSheet.type.text=Image",
119  "ImageNode.createSheet.sectorSize.name=Sector Size (Bytes)",
120  "ImageNode.createSheet.sectorSize.displayName=Sector Size (Bytes)",
121  "ImageNode.createSheet.sectorSize.desc=Sector size of the image in bytes.",
122  "ImageNode.createSheet.md5.name=MD5 Hash",
123  "ImageNode.createSheet.md5.displayName=MD5 Hash",
124  "ImageNode.createSheet.md5.desc=MD5 Hash of the image",
125  "ImageNode.createSheet.timezone.name=Timezone",
126  "ImageNode.createSheet.timezone.displayName=Timezone",
127  "ImageNode.createSheet.timezone.desc=Timezone of the image",
128  "ImageNode.createSheet.deviceId.name=Device ID",
129  "ImageNode.createSheet.deviceId.displayName=Device ID",
130  "ImageNode.createSheet.deviceId.desc=Device ID of the image"})
131  protected Sheet createSheet() {
132  Sheet s = super.createSheet();
133  Sheet.Set ss = s.get(Sheet.PROPERTIES);
134  if (ss == null) {
135  ss = Sheet.createPropertiesSet();
136  s.put(ss);
137  }
138 
139  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "ImageNode.createSheet.name.name"),
140  NbBundle.getMessage(this.getClass(), "ImageNode.createSheet.name.displayName"),
141  NbBundle.getMessage(this.getClass(), "ImageNode.createSheet.name.desc"),
142  getDisplayName()));
143 
144  ss.put(new NodeProperty<>(Bundle.ImageNode_createSheet_type_name(),
145  Bundle.ImageNode_createSheet_type_displayName(),
146  Bundle.ImageNode_createSheet_type_desc(),
147  Bundle.ImageNode_createSheet_type_text()));
148 
149  ss.put(new NodeProperty<>(Bundle.ImageNode_createSheet_size_name(),
150  Bundle.ImageNode_createSheet_size_displayName(),
151  Bundle.ImageNode_createSheet_size_desc(),
152  this.content.getSize()));
153  ss.put(new NodeProperty<>(Bundle.ImageNode_createSheet_sectorSize_name(),
154  Bundle.ImageNode_createSheet_sectorSize_displayName(),
155  Bundle.ImageNode_createSheet_sectorSize_desc(),
156  this.content.getSsize()));
157 
158  ss.put(new NodeProperty<>(Bundle.ImageNode_createSheet_md5_name(),
159  Bundle.ImageNode_createSheet_md5_displayName(),
160  Bundle.ImageNode_createSheet_md5_desc(),
161  this.content.getMd5()));
162 
163  ss.put(new NodeProperty<>(Bundle.ImageNode_createSheet_timezone_name(),
164  Bundle.ImageNode_createSheet_timezone_displayName(),
165  Bundle.ImageNode_createSheet_timezone_desc(),
166  this.content.getTimeZone()));
167 
168  try (CaseDbQuery query = Case.getCurrentCase().getSleuthkitCase().executeQuery("SELECT device_id FROM data_source_info WHERE obj_id = " + this.content.getId());) {
169  ResultSet deviceIdSet = query.getResultSet();
170  if (deviceIdSet.next()) {
171  ss.put(new NodeProperty<>(Bundle.ImageNode_createSheet_deviceId_name(),
172  Bundle.ImageNode_createSheet_deviceId_displayName(),
173  Bundle.ImageNode_createSheet_deviceId_desc(),
174  deviceIdSet.getString("device_id")));
175  }
176  } catch (SQLException | TskCoreException ex) {
177  logger.log(Level.SEVERE, "Failed to get device id for the following image: " + this.content.getId(), ex);
178  }
179 
180  return s;
181  }
182 
183  @Override
184  public <T> T accept(ContentNodeVisitor<T> v) {
185  return v.visit(this);
186  }
187 
188  @Override
189  public boolean isLeafTypeNode() {
190  return false;
191  }
192 
193  @Override
194  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
195  return v.visit(this);
196  }
197 
198  /*
199  * TODO (AUT-1849): Correct or remove peristent column reordering code
200  *
201  * Added to support this feature.
202  */
203 // @Override
204 // public String getItemType() {
205 // return "Image"; //NON-NLS
206 // }
207 }
Action[] getActions(boolean context)
Definition: ImageNode.java:86
synchronized static Logger getLogger(String name)
Definition: Logger.java:161

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