Autopsy  4.12.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
VolumeNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2019 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.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.ArrayList;
24 import java.util.EnumSet;
25 import java.util.List;
26 import java.util.Set;
27 import java.util.logging.Level;
28 import javax.swing.Action;
29 import org.apache.commons.lang3.tuple.Pair;
30 import org.openide.nodes.Sheet;
31 import org.openide.util.NbBundle;
42 import org.sleuthkit.datamodel.Content;
43 import org.sleuthkit.datamodel.TskCoreException;
44 import org.sleuthkit.datamodel.VirtualDirectory;
45 import org.sleuthkit.datamodel.Volume;
47 import org.sleuthkit.datamodel.Tag;
48 
53 public class VolumeNode extends AbstractContentNode<Volume> {
54 
55  private static final Logger logger = Logger.getLogger(VolumeNode.class.getName());
57 
66  static String nameForVolume(Volume vol) {
67  return "vol" + Long.toString(vol.getAddr()); //NON-NLS
68  }
69 
74  public VolumeNode(Volume vol) {
75  super(vol);
76 
77  // set name, display name, and icon
78  String volName = nameForVolume(vol);
79 
80  long end = vol.getStart() + (vol.getLength() - 1);
81  String tempVolName = volName + " (" + vol.getDescription() + ": " + vol.getStart() + "-" + end + ")";
82  this.setDisplayName(tempVolName);
83 
84  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/vol-icon.png"); //NON-NLS
85  // Listen for ingest events so that we can detect new added files (e.g. carved)
87  // Listen for case events so that we can detect when case is closed
89  }
90 
91  private void removeListeners() {
94  }
95 
96  /*
97  * This property change listener refreshes the tree when a new file is
98  * carved out of the unallocated space of this volume.
99  */
100  private final PropertyChangeListener pcl = (PropertyChangeEvent evt) -> {
101  String eventType = evt.getPropertyName();
102 
103  // See if the new file is a child of ours
104  if (eventType.equals(IngestManager.IngestModuleEvent.CONTENT_CHANGED.toString())) {
105  if ((evt.getOldValue() instanceof ModuleContentEvent) == false) {
106  return;
107  }
108  ModuleContentEvent moduleContentEvent = (ModuleContentEvent) evt.getOldValue();
109  if ((moduleContentEvent.getSource() instanceof Content) == false) {
110  return;
111  }
112  Content newContent = (Content) moduleContentEvent.getSource();
113 
114  try {
115  Content parent = newContent.getParent();
116  if (parent != null) {
117  // Is this a new carved file?
118  if (parent.getName().equals(VirtualDirectory.NAME_CARVED)) {
119  // Is this new carved file for this data source?
120  if (newContent.getDataSource().getId() == getContent().getDataSource().getId()) {
121  // Find the volume (if any) associated with the new content and
122  // trigger a refresh if it matches the volume wrapped by this node.
123  while ((parent = parent.getParent()) != null) {
124  if (parent.getId() == getContent().getId()) {
126  break;
127  }
128  }
129  }
130  }
131  }
132  } catch (TskCoreException ex) {
133  // Do nothing.
134  } catch (NoSuchEventBusException ex) {
135  logger.log(Level.WARNING, eventType, ex);
136  }
137  } else if (eventType.equals(Case.Events.CURRENT_CASE.toString())) {
138  if (evt.getNewValue() == null) {
139  // case was closed. Remove listeners so that we don't get called with a stale case handle
140  removeListeners();
141  }
142  }
143  };
144 
152  @Override
153  public Action[] getActions(boolean popup) {
154  List<Action> actionsList = new ArrayList<>();
155 
156  for (Action a : super.getActions(true)) {
157  actionsList.add(a);
158  }
159  actionsList.add(new FileSystemDetailsAction(content));
160  actionsList.add(new NewWindowViewAction(
161  NbBundle.getMessage(this.getClass(), "VolumeNode.getActions.viewInNewWin.text"), this));
162  actionsList.addAll(ExplorerNodeActionVisitor.getActions(content));
163 
164  return actionsList.toArray(new Action[actionsList.size()]);
165  }
166 
167  @Override
168  protected Sheet createSheet() {
169  Sheet sheet = super.createSheet();
170  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
171  if (sheetSet == null) {
172  sheetSet = Sheet.createPropertiesSet();
173  sheet.put(sheetSet);
174  }
175 
176  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.name.name"),
177  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.name.displayName"),
178  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.name.desc"),
179  this.getDisplayName()));
180  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.id.name"),
181  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.id.displayName"),
182  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.id.desc"),
183  content.getAddr()));
184  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.startSector.name"),
185  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.startSector.displayName"),
186  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.startSector.desc"),
187  content.getStart()));
188  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.lenSectors.name"),
189  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.lenSectors.displayName"),
190  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.lenSectors.desc"),
191  content.getLength()));
192  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.description.name"),
193  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.description.displayName"),
194  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.description.desc"),
195  content.getDescription()));
196  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.flags.name"),
197  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.flags.displayName"),
198  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.flags.desc"),
199  content.getFlagsAsString()));
200 
201  return sheet;
202  }
203 
204  @Override
205  public <T> T accept(ContentNodeVisitor<T> visitor) {
206  return visitor.visit(this);
207  }
208 
209  @Override
210  public boolean isLeafTypeNode() {
211  return false;
212  }
213 
214  @Override
215  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
216  return visitor.visit(this);
217  }
218 
219  @Override
220  public String getItemType() {
221  return DisplayableItemNode.FILE_PARENT_NODE_KEY;
222  }
223 
231  @Override
232  protected List<Tag> getAllTagsFromDatabase() {
233  return new ArrayList<>();
234  }
235 
245  @Override
247  return null;
248  }
249 
259  @Override
260  protected Pair<DataResultViewerTable.Score, String> getScorePropertyAndDescription(List<Tag> tags) {
261  return Pair.of(DataResultViewerTable.Score.NO_SCORE, NO_DESCR);
262  }
263 
274  @Override
277  }
278 
291  @Override
292  protected Pair<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) {
293  return Pair.of(-1L, NO_DESCR);
294  }
295 }
void removeIngestModuleEventListener(final PropertyChangeListener listener)
Pair< Long, String > getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription)
static synchronized IngestManager getInstance()
static final Set< IngestManager.IngestModuleEvent > INGEST_MODULE_EVENTS_OF_INTEREST
Definition: VolumeNode.java:56
Pair< DataResultViewerTable.Score, String > getScorePropertyAndDescription(List< Tag > tags)
DataResultViewerTable.HasCommentStatus getCommentProperty(List< Tag > tags, CorrelationAttributeInstance attribute)
CorrelationAttributeInstance getCorrelationAttributeInstance()
final PropertyChangeListener pcl
static void post(String nodeName, Object event)
void addIngestModuleEventListener(final PropertyChangeListener listener)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
Definition: Case.java:477
static void removeEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
Definition: Case.java:522

Copyright © 2012-2018 Basis Technology. Generated on: Wed Sep 18 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.