Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataContentViewerOtherCases.java
Go to the documentation of this file.
1/*
2 * Central Repository
3 *
4 * Copyright 2017-2021 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.centralrepository.contentviewer;
20
21import java.awt.Component;
22import java.awt.Cursor;
23import java.util.concurrent.ExecutionException;
24import java.util.logging.Level;
25import org.sleuthkit.autopsy.coreutils.Logger;
26import javax.swing.JPanel;
27import org.apache.commons.lang.StringUtils;
28import org.openide.nodes.Node;
29import org.openide.util.NbBundle.Messages;
30import org.openide.util.lookup.ServiceProvider;
31import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
32import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository;
33import org.sleuthkit.autopsy.contentviewers.utils.ViewerPriority;
34import org.sleuthkit.autopsy.datamodel.BlackboardArtifactItem;
35import org.sleuthkit.datamodel.AbstractFile;
36import org.sleuthkit.datamodel.BlackboardArtifactTag;
37import org.sleuthkit.datamodel.OsAccount;
38
42@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
43@ServiceProvider(service = DataContentViewer.class, position = 10)
44@Messages({"DataContentViewerOtherCases.title=Other Occurrences",
45 "DataContentViewerOtherCases.toolTip=Displays instances of the selected file/artifact from other occurrences."})
46public final class DataContentViewerOtherCases extends JPanel implements DataContentViewer {
47
48 private static final long serialVersionUID = -1L;
49 private static final Logger logger = Logger.getLogger(DataContentViewerOtherCases.class.getName());
51
52 private OtherOccurrencesNodeWorker worker = null;
53
61
62 @Override
63 public String getTitle() {
64 return Bundle.DataContentViewerOtherCases_title();
65 }
66
67 @Override
68 public String getToolTip() {
69 return Bundle.DataContentViewerOtherCases_toolTip();
70 }
71
72 @Override
76
77 @Override
78 public Component getComponent() {
79 return this;
80 }
81
82 @Override
83 public void resetComponent() {
85 }
86
87 @Override
88 public int isPreferred(Node node) {
89 return ViewerPriority.viewerPriority.LevelOne.getFlag();
90 }
91
92 @Override
93 public boolean isSupported(Node node) {
94 //Ideally we would want to attempt to create correlation attributes for the node contents
95 //and if none could be created determine that it was not supported.
96 //However that winds up being more work than we really want to be performing in this method so we perform a quicker check.
97 //The result of this is that the Other Occurrences viewer could be enabled but without any correlation attributes in some situations.
98 // Is supported if:
99 // The central repo is enabled and the node is not null
100 if (CentralRepository.isEnabled() && node != null) {
101 // And the node has information which could be correlated on.
102 if (node.getLookup().lookup(OsAccount.class) != null) {
103 //the node has an associated OsAccount to correlate on
104 return true;
105 }
106 if (node.getLookup().lookup(BlackboardArtifactItem.class) != null) {
107 //it has a blackboard artifact which might have a correlation attribute
108 return true;
109 }
110 if (node.getLookup().lookup(BlackboardArtifactTag.class) != null) {
111 //Blackboard artifact tags may have their underlying artifact correlated on
112 return true;
113 }
114 AbstractFile file = node.getLookup().lookup(AbstractFile.class);
115 //the AbstractFile lookup will handle the usecase for file tags as well
116 if (file != null && !StringUtils.isBlank(file.getMd5Hash())) {
117 //there is an abstractFile lookup and it has an MD5 so could be correlated on
118 return true;
119 }
120 }
121 return false;
122
123 }
124
125 @Override
126 public void setNode(Node node) {
127 otherOccurrencesPanel.reset(); // reset the table to empty.
128 otherOccurrencesPanel.showPanelLoadingMessage();
129
130 if (node == null) {
131 return;
132 }
133
134 if (worker != null) {
135 worker.cancel(true);
136 }
137 worker = new OtherOccurrencesNodeWorker(node) {
138 @Override
139 public void done() {
140 try {
141 if (!isCancelled()) {
142 OtherOccurrencesData data = get();
143 otherOccurrencesPanel.populateTable(data);
144 otherOccurrencesPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
145 }
146 } catch (InterruptedException | ExecutionException ex) {
147 DataContentViewerOtherCases.logger.log(Level.SEVERE, "Failed to update OtherOccurrencesPanel", ex);
148 }
149 }
150 };
151 otherOccurrencesPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
152 worker.execute();
153 }
154
160 @SuppressWarnings("unchecked")
161 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
162 private void initComponents() {
163 java.awt.GridBagConstraints gridBagConstraints;
164
165 setMinimumSize(new java.awt.Dimension(1000, 10));
166 setOpaque(false);
167 setPreferredSize(new java.awt.Dimension(1000, 63));
168 setLayout(new java.awt.BorderLayout());
169 }// </editor-fold>//GEN-END:initComponents
170
171 // Variables declaration - do not modify//GEN-BEGIN:variables
172 // End of variables declaration//GEN-END:variables
173}
synchronized static Logger getLogger(String name)
Definition Logger.java:124

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