Autopsy  4.6.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
IngestMessageDetailsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2018 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.ingest;
20 
21 import java.awt.*;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import javax.swing.JMenuItem;
25 import javax.swing.text.html.HTMLEditorKit;
26 import javax.swing.text.html.StyleSheet;
31 import org.sleuthkit.datamodel.AbstractFile;
32 import org.sleuthkit.datamodel.BlackboardArtifact;
33 import org.sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM;
34 import org.sleuthkit.datamodel.TskException;
35 
39 class IngestMessageDetailsPanel extends javax.swing.JPanel {
40 
41  private final IngestMessageMainPanel mainPanel;
42  private final DirectoryTreeTopComponent dtc = DirectoryTreeTopComponent.findInstance();
43 
47  IngestMessageDetailsPanel(IngestMessageMainPanel mainPanel) {
48  this.mainPanel = mainPanel;
49  initComponents();
50  customizeComponents();
51  }
52 
53  private void customizeComponents() {
54  messageDetailsPane.setContentType("text/html"); //NON-NLS
55  viewArtifactButton.setEnabled(false);
56  viewContentButton.setEnabled(false);
57  HTMLEditorKit kit = new HTMLEditorKit();
58  messageDetailsPane.setEditorKit(kit);
59  StyleSheet styleSheet = kit.getStyleSheet();
60  /*
61  * I tried to define the font-size only on body to have it inherit, it
62  * didn't work in all cases.
63  */
64  styleSheet.addRule("body {font-family:Arial;font-size:10pt;}"); //NON-NLS
65  styleSheet.addRule("p {font-family:Arial;font-size:10pt;}"); //NON-NLS
66  styleSheet.addRule("li {font-family:Arial;font-size:10pt;}"); //NON-NLS
67  styleSheet.addRule("table {table-layout:fixed;}"); //NON-NLS
68  styleSheet.addRule("td {white-space:pre-wrap;overflow:hidden;}"); //NON-NLS
69  styleSheet.addRule("th {font-weight:bold;}"); //NON-NLS
70 
71  //right click
72  messageDetailsPane.setComponentPopupMenu(rightClickMenu);
73  ActionListener actList = new ActionListener() {
74  @Override
75  public void actionPerformed(ActionEvent e) {
76  JMenuItem jmi = (JMenuItem) e.getSource();
77  if (jmi.equals(copyMenuItem)) {
78  messageDetailsPane.copy();
79  } else if (jmi.equals(selectAllMenuItem)) {
80  messageDetailsPane.selectAll();
81  }
82  }
83  };
84  copyMenuItem.addActionListener(actList);
85  selectAllMenuItem.addActionListener(actList);
86  }
87 
93  @SuppressWarnings("unchecked")
94  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
95  private void initComponents() {
96 
97  rightClickMenu = new javax.swing.JPopupMenu();
98  copyMenuItem = new javax.swing.JMenuItem();
99  selectAllMenuItem = new javax.swing.JMenuItem();
100  jScrollPane1 = new javax.swing.JScrollPane();
101  messageDetailsPane = new javax.swing.JTextPane();
102  jToolBar1 = new javax.swing.JToolBar();
103  backButton = new javax.swing.JButton();
104  filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0));
105  viewArtifactButton = new javax.swing.JButton();
106  viewContentButton = new javax.swing.JButton();
107 
108  copyMenuItem.setText(org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class, "IngestMessageDetailsPanel.copyMenuItem.text")); // NOI18N
109  rightClickMenu.add(copyMenuItem);
110 
111  selectAllMenuItem.setText(org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class, "IngestMessageDetailsPanel.selectAllMenuItem.text")); // NOI18N
112  rightClickMenu.add(selectAllMenuItem);
113 
114  messageDetailsPane.setEditable(false);
115  messageDetailsPane.setBackground(new java.awt.Color(221, 221, 235));
116  messageDetailsPane.setBorder(null);
117  messageDetailsPane.setContentType(org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class, "IngestMessageDetailsPanel.messageDetailsPane.contentType")); // NOI18N
118  messageDetailsPane.setFont(messageDetailsPane.getFont().deriveFont(messageDetailsPane.getFont().getStyle() & ~java.awt.Font.BOLD, 10));
119  messageDetailsPane.setToolTipText(org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class, "IngestMessageDetailsPanel.messageDetailsPane.toolTipText")); // NOI18N
120  jScrollPane1.setViewportView(messageDetailsPane);
121 
122  jToolBar1.setFloatable(false);
123  jToolBar1.setRollover(true);
124 
125  backButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/ingest/btn_step_back.png"))); // NOI18N
126  backButton.setText(org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class, "IngestMessageDetailsPanel.backButton.text")); // NOI18N
127  backButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
128  backButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
129  backButton.setMaximumSize(new java.awt.Dimension(23, 23));
130  backButton.setMinimumSize(new java.awt.Dimension(23, 23));
131  backButton.setPreferredSize(new java.awt.Dimension(23, 23));
132  backButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/ingest/btn_step_back_hover.png"))); // NOI18N
133  backButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/ingest/btn_step_back_hover.png"))); // NOI18N
134  backButton.addActionListener(new java.awt.event.ActionListener() {
135  public void actionPerformed(java.awt.event.ActionEvent evt) {
136  backButtonActionPerformed(evt);
137  }
138  });
139  jToolBar1.add(backButton);
140  jToolBar1.add(filler1);
141 
142  viewArtifactButton.setFont(viewArtifactButton.getFont().deriveFont(viewArtifactButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
143  viewArtifactButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/ingest/goto_res.png"))); // NOI18N
144  viewArtifactButton.setText(org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class, "IngestMessageDetailsPanel.viewArtifactButton.text")); // NOI18N
145  viewArtifactButton.setIconTextGap(2);
146  viewArtifactButton.addActionListener(new java.awt.event.ActionListener() {
147  public void actionPerformed(java.awt.event.ActionEvent evt) {
148  viewArtifactButtonActionPerformed(evt);
149  }
150  });
151  jToolBar1.add(viewArtifactButton);
152 
153  viewContentButton.setFont(viewContentButton.getFont().deriveFont(viewContentButton.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
154  viewContentButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/ingest/goto_dir.png"))); // NOI18N
155  viewContentButton.setText(org.openide.util.NbBundle.getMessage(IngestMessageDetailsPanel.class, "IngestMessageDetailsPanel.viewContentButton.text")); // NOI18N
156  viewContentButton.setIconTextGap(2);
157  viewContentButton.addActionListener(new java.awt.event.ActionListener() {
158  public void actionPerformed(java.awt.event.ActionEvent evt) {
159  viewContentButtonActionPerformed(evt);
160  }
161  });
162  jToolBar1.add(viewContentButton);
163 
164  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
165  this.setLayout(layout);
166  layout.setHorizontalGroup(
167  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
168  .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
169  .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
170  );
171  layout.setVerticalGroup(
172  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
173  .addGroup(layout.createSequentialGroup()
174  .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
175  .addGap(0, 0, 0)
176  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE))
177  );
178  }// </editor-fold>//GEN-END:initComponents
179 
180  private void viewContentButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewContentButtonActionPerformed
181  messageDetailsPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
182  final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getSelectedMessage();
183  if (messageGroup != null) {
184  BlackboardArtifact art = messageGroup.getData();
185  if (art != null) {
186  dtc.viewArtifactContent(art);
187  }
188  }
189  messageDetailsPane.setCursor(null);
190  }//GEN-LAST:event_viewContentButtonActionPerformed
191 
192  private void viewArtifactButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewArtifactButtonActionPerformed
193  messageDetailsPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
194  final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getSelectedMessage();
195  if (messageGroup != null) {
196  BlackboardArtifact art = messageGroup.getData();
197  if (art != null) {
198  dtc.viewArtifact(art);
199  }
200  }
201  messageDetailsPane.setCursor(null);
202  }//GEN-LAST:event_viewArtifactButtonActionPerformed
203 
204  private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed
205  mainPanel.showMessages();
206  }//GEN-LAST:event_backButtonActionPerformed
207  // Variables declaration - do not modify//GEN-BEGIN:variables
208  private javax.swing.JButton backButton;
209  private javax.swing.JMenuItem copyMenuItem;
210  private javax.swing.Box.Filler filler1;
211  private javax.swing.JScrollPane jScrollPane1;
212  private javax.swing.JToolBar jToolBar1;
213  private javax.swing.JTextPane messageDetailsPane;
214  private javax.swing.JPopupMenu rightClickMenu;
215  private javax.swing.JMenuItem selectAllMenuItem;
216  private javax.swing.JButton viewArtifactButton;
217  private javax.swing.JButton viewContentButton;
218  // End of variables declaration//GEN-END:variables
219 
225  void showDetails(int rowNumber) {
226  final IngestMessageGroup messageGroup = mainPanel.getMessagePanel().getMessageGroup(rowNumber);
227  if (messageGroup != null) {
228  String details = messageGroup.getDetails();
229  if (details != null) {
230  StringBuilder b = new StringBuilder();
231  if (details.startsWith("<html><body>") == false) { //NON-NLS
232  b.append("<html><body>"); //NON-NLS
233  b.append(details);
234  b.append("</body></html>"); //NON-NLS
235  } else {
236  b.append(details);
237  }
238  this.messageDetailsPane.setText(b.toString());
239  } else {
240  this.messageDetailsPane.setText("");
241  }
242  //show artifact/content only for a message group with a single message
243  BlackboardArtifact artifact = messageGroup.getData();;
244  if (artifact != null && messageGroup.getCount() == 1) {
245  viewArtifactButton.setEnabled(true);
246 
247  //check file type
248  long objId = artifact.getObjectID();
249  AbstractFile file = null;
250  try {
251  file = Case.getOpenCase().getSleuthkitCase().getAbstractFileById(objId);
252  } catch (TskException | NoCurrentCaseException ex) {
253 
254  }
255  if (file == null) {
256  viewContentButton.setEnabled(false);
257  } else if (!file.getType().equals(TSK_DB_FILES_TYPE_ENUM.FS)) {
258  viewContentButton.setEnabled(false);
259  } else {
260  viewContentButton.setEnabled(true);
261  }
262  } else {
263  viewArtifactButton.setEnabled(false);
264  viewContentButton.setEnabled(false);
265  }
266  } else {
267  viewArtifactButton.setEnabled(false);
268  viewContentButton.setEnabled(false);
269  messageDetailsPane.setText("");
270  }
271 
272  }
273 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon May 7 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.