Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
LocalFileNode.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2013-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 */
19package org.sleuthkit.autopsy.datamodel;
20
21import java.util.ArrayList;
22import java.util.Arrays;
23import java.util.Collection;
24import java.util.HashSet;
25import java.util.List;
26import java.util.logging.Level;
27import javax.swing.Action;
28import org.openide.util.NbBundle;
29import org.openide.util.Utilities;
30import org.sleuthkit.autopsy.actions.AddContentTagAction;
31import org.sleuthkit.autopsy.actions.DeleteFileContentTagAction;
32import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint;
33import org.sleuthkit.autopsy.coreutils.Logger;
34import org.sleuthkit.autopsy.directorytree.ExportCSVAction;
35import org.sleuthkit.autopsy.directorytree.ExternalViewerAction;
36import org.sleuthkit.autopsy.directorytree.ExternalViewerShortcutAction;
37import org.sleuthkit.autopsy.directorytree.ExtractAction;
38import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
39import org.sleuthkit.autopsy.directorytree.ViewContextAction;
40import org.sleuthkit.autopsy.modules.embeddedfileextractor.ExtractArchiveWithPasswordAction;
41import org.sleuthkit.datamodel.AbstractFile;
42import org.sleuthkit.datamodel.BlackboardArtifact;
43import org.sleuthkit.datamodel.TskCoreException;
44
48public class LocalFileNode extends AbstractAbstractFileNode<AbstractFile> {
49
50 private static final Logger logger = Logger.getLogger(LocalFileNode.class.getName());
51
52 public LocalFileNode(AbstractFile af) {
53 super(af);
54
55 this.setDisplayName(af.getName());
56
57 // set name, display name, and icon
58 if (af.isDir()) {
59 this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/Folder-icon.png"); //NON-NLS
60 } else {
61 this.setIconBaseWithExtension(FileNode.getIconForFileType(af));
62 }
63
64 }
65
66 @Override
67 public Action[] getActions(boolean context) {
68 List<Action> actionsList = new ArrayList<>();
69
70 actionsList.add(new ViewContextAction(NbBundle.getMessage(this.getClass(), "LocalFileNode.viewFileInDir.text"), this.content));
71 actionsList.add(null); // creates a menu separator
72 actionsList.add(new NewWindowViewAction(
73 NbBundle.getMessage(this.getClass(), "LocalFileNode.getActions.viewInNewWin.text"), this));
74 final Collection<AbstractFile> selectedFilesList
75 = new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
76 if (selectedFilesList.size() == 1) {
77 actionsList.add(new ExternalViewerAction(
78 NbBundle.getMessage(this.getClass(), "LocalFileNode.getActions.openInExtViewer.text"), this));
79 } else {
81 }
82 actionsList.add(null); // creates a menu separator
83
84 actionsList.add(ExtractAction.getInstance());
85 actionsList.add(ExportCSVAction.getInstance());
86 actionsList.add(null); // creates a menu separator
87 actionsList.add(AddContentTagAction.getInstance());
88
89 if (selectedFilesList.size() == 1) {
90 actionsList.add(DeleteFileContentTagAction.getInstance());
91 }
92
93 actionsList.addAll(ContextMenuExtensionPoint.getActions());
94 if (FileTypeExtensions.getArchiveExtensions().contains("." + this.content.getNameExtension().toLowerCase())) {
95 try {
96 if (this.content.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED).size() > 0) {
97 actionsList.add(new ExtractArchiveWithPasswordAction(this.getContent()));
98 }
99 } catch (TskCoreException ex) {
100 logger.log(Level.WARNING, "Unable to add unzip with password action to context menus", ex);
101 }
102 }
103
104 actionsList.add(null);
105 actionsList.addAll(Arrays.asList(super.getActions(true)));
106
107 return actionsList.toArray(new Action[actionsList.size()]);
108 }
109
110 @Override
111 public <T> T accept(ContentNodeVisitor<T> visitor) {
112 return visitor.visit(this);
113 }
114
115 @Override
116 public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
117 return visitor.visit(this);
118 }
119
120 @Override
121 public boolean isLeafTypeNode() {
122 // This seems wrong, but it also seems that it is never called
123 // because the visitor to figure out if there are children or
124 // not will check if it has children using the Content API
125 return true;
126 }
127
128 @Override
129 public String getItemType() {
130 return getClass().getName();
131 }
132}
static synchronized AddContentTagAction getInstance()
static synchronized DeleteFileContentTagAction getInstance()
synchronized static Logger getLogger(String name)
Definition Logger.java:124
static synchronized ExportCSVAction getInstance()
static synchronized ExtractAction getInstance()

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.