19 package org.sleuthkit.autopsy.contentviewers;
22 import com.google.gson.Gson;
23 import java.awt.Color;
24 import java.awt.Component;
25 import java.awt.ComponentOrientation;
26 import java.util.Arrays;
27 import java.util.Collection;
28 import java.util.HashSet;
29 import java.util.List;
30 import java.util.Optional;
32 import java.util.logging.Level;
33 import javax.swing.JScrollPane;
34 import javax.swing.text.JTextComponent;
35 import org.apache.commons.lang3.StringUtils;
36 import org.jsoup.Jsoup;
37 import org.jsoup.nodes.Document;
38 import org.openide.explorer.ExplorerManager;
39 import org.openide.nodes.AbstractNode;
40 import org.openide.nodes.Children;
41 import org.openide.nodes.Node;
42 import org.openide.util.NbBundle;
43 import org.openide.util.lookup.ServiceProvider;
56 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_ASSOCIATED_OBJECT;
57 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG;
58 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT;
59 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE;
61 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT;
62 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME;
63 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_RCVD;
64 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DIRECTION;
65 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CC;
66 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_HTML;
67 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_PLAIN;
68 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_RTF;
69 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_FROM;
70 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_TO;
71 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_HEADERS;
72 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
73 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
74 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT;
75 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEXT;
79 import org.
sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments;
80 import org.
sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments.FileAttachment;
81 import org.
sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments.Attachment;
82 import org.
sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments.URLAttachment;
87 @ServiceProvider(service = DataContentViewer.class, position = 5)
88 @SuppressWarnings(
"PMD.SingularField")
94 class TextComponent
implements TranslatablePanel.ContentComponent {
96 private final Component rootComponent;
101 childTextComponent.setEditable(
false);
103 JScrollPane parentComponent =
new JScrollPane();
104 parentComponent.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
105 parentComponent.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
106 parentComponent.setViewportView(childTextComponent);
107 rootComponent = parentComponent;
111 public Component getRootComponent() {
112 return rootComponent;
116 public void setContent(String content, ComponentOrientation orientation)
throws TranslatablePanelException {
117 childTextComponent.
setText(content == null ?
"" : content);
118 childTextComponent.setComponentOrientation(orientation);
119 childTextComponent.setCaretPosition(0);
123 private static final long serialVersionUID = 1L;
125 private static final BlackboardAttribute.Type TSK_ASSOCIATED_TYPE =
new BlackboardAttribute.Type(TSK_ASSOCIATED_ARTIFACT);
127 private static final int HDR_TAB_INDEX = 0;
128 private static final int TEXT_TAB_INDEX = 1;
129 private static final int HTML_TAB_INDEX = 2;
130 private static final int RTF_TAB_INDEX = 3;
131 private static final int ATTM_TAB_INDEX = 4;
135 private final TranslatablePanel textPanel =
new TranslatablePanel(
new TextComponent());
146 @NbBundle.Messages(
"MessageContentViewer.AtrachmentsPanel.title=Attachments")
149 htmlPane.add(htmlPanel);
150 envelopePanel.setBackground(
new Color(0, 0, 0, 38));
152 attachmentsScrollPane.setViewportView(drp);
154 msgbodyTabbedPane.insertTab(
155 NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.textbodyScrollPane.TabConstraints.tabTitle"),
161 msgbodyTabbedPane.setEnabledAt(ATTM_TAB_INDEX,
true);
167 textAreas = Arrays.asList(headersTextArea, null, null, rtfbodyTextPane);
180 drpExplorerManager.addPropertyChangeListener(evt
181 -> viewInNewWindowButton.setEnabled(drpExplorerManager.getSelectedNodes().length == 1));
189 @SuppressWarnings(
"unchecked")
191 private
void initComponents() {
193 envelopePanel =
new javax.swing.JPanel();
194 fromLabel =
new javax.swing.JLabel();
195 datetimeText =
new javax.swing.JLabel();
196 fromText =
new javax.swing.JLabel();
197 toLabel =
new javax.swing.JLabel();
198 toText =
new javax.swing.JLabel();
199 ccLabel =
new javax.swing.JLabel();
200 ccText =
new javax.swing.JLabel();
201 subjectLabel =
new javax.swing.JLabel();
202 subjectText =
new javax.swing.JLabel();
203 directionText =
new javax.swing.JLabel();
204 msgbodyTabbedPane =
new javax.swing.JTabbedPane();
205 headersScrollPane =
new javax.swing.JScrollPane();
206 headersTextArea =
new javax.swing.JTextArea();
207 htmlPane =
new javax.swing.JPanel();
208 rtfbodyScrollPane =
new javax.swing.JScrollPane();
209 rtfbodyTextPane =
new javax.swing.JTextPane();
210 attachmentsPanel =
new javax.swing.JPanel();
211 viewInNewWindowButton =
new javax.swing.JButton();
212 attachmentsScrollPane =
new javax.swing.JScrollPane();
214 envelopePanel.setBackground(
new java.awt.Color(204, 204, 204));
216 org.openide.awt.Mnemonics.setLocalizedText(fromLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.fromLabel.text"));
218 datetimeText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
219 org.openide.awt.Mnemonics.setLocalizedText(datetimeText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.datetimeText.text"));
221 org.openide.awt.Mnemonics.setLocalizedText(fromText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.fromText.text"));
223 org.openide.awt.Mnemonics.setLocalizedText(toLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.toLabel.text"));
225 org.openide.awt.Mnemonics.setLocalizedText(toText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.toText.text"));
226 toText.setAutoscrolls(
true);
227 toText.setMinimumSize(
new java.awt.Dimension(27, 14));
229 org.openide.awt.Mnemonics.setLocalizedText(ccLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.ccLabel.text"));
231 org.openide.awt.Mnemonics.setLocalizedText(ccText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.ccText.text"));
232 ccText.setMinimumSize(
new java.awt.Dimension(27, 14));
234 org.openide.awt.Mnemonics.setLocalizedText(subjectLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.subjectLabel.text"));
236 org.openide.awt.Mnemonics.setLocalizedText(subjectText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.subjectText.text"));
237 subjectText.setMinimumSize(
new java.awt.Dimension(26, 14));
239 directionText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
240 org.openide.awt.Mnemonics.setLocalizedText(directionText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.directionText.text"));
242 javax.swing.GroupLayout envelopePanelLayout =
new javax.swing.GroupLayout(envelopePanel);
243 envelopePanel.setLayout(envelopePanelLayout);
244 envelopePanelLayout.setHorizontalGroup(
245 envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
246 .addGroup(envelopePanelLayout.createSequentialGroup()
248 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
249 .addGroup(envelopePanelLayout.createSequentialGroup()
250 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
251 .addComponent(fromLabel)
252 .addComponent(toLabel))
253 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
254 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
255 .addGroup(envelopePanelLayout.createSequentialGroup()
256 .addComponent(toText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
257 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
258 .addComponent(directionText, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
259 .addGroup(envelopePanelLayout.createSequentialGroup()
260 .addComponent(fromText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
261 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
262 .addComponent(datetimeText, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))))
263 .addGroup(envelopePanelLayout.createSequentialGroup()
264 .addComponent(ccLabel)
266 .addComponent(ccText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
267 .addGroup(envelopePanelLayout.createSequentialGroup()
268 .addComponent(subjectLabel)
269 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
270 .addComponent(subjectText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
273 envelopePanelLayout.setVerticalGroup(
274 envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
275 .addGroup(envelopePanelLayout.createSequentialGroup()
277 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
278 .addComponent(fromLabel)
279 .addComponent(datetimeText)
280 .addComponent(fromText))
281 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
282 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
283 .addComponent(toLabel)
284 .addComponent(toText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
285 .addComponent(directionText))
286 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
287 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
288 .addComponent(ccLabel)
289 .addComponent(ccText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
290 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
291 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
292 .addComponent(subjectLabel)
293 .addComponent(subjectText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
297 headersScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
298 headersScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
300 headersTextArea.setEditable(
false);
301 headersTextArea.setColumns(20);
302 headersTextArea.setLineWrap(
true);
303 headersTextArea.setRows(5);
304 headersTextArea.setWrapStyleWord(
true);
305 headersScrollPane.setViewportView(headersTextArea);
307 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.headersScrollPane.TabConstraints.tabTitle"), headersScrollPane);
309 htmlPane.setLayout(
new java.awt.BorderLayout());
310 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.htmlPane.TabConstraints.tabTitle"), htmlPane);
312 rtfbodyScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
314 rtfbodyTextPane.setEditable(
false);
315 rtfbodyScrollPane.setViewportView(rtfbodyTextPane);
317 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.rtfbodyScrollPane.TabConstraints.tabTitle"), rtfbodyScrollPane);
319 org.openide.awt.Mnemonics.setLocalizedText(viewInNewWindowButton,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.viewInNewWindowButton.text"));
320 viewInNewWindowButton.addActionListener(
new java.awt.event.ActionListener() {
321 public void actionPerformed(java.awt.event.ActionEvent evt) {
322 viewInNewWindowButtonActionPerformed(evt);
326 javax.swing.GroupLayout attachmentsPanelLayout =
new javax.swing.GroupLayout(attachmentsPanel);
327 attachmentsPanel.setLayout(attachmentsPanelLayout);
328 attachmentsPanelLayout.setHorizontalGroup(
329 attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
330 .addGroup(attachmentsPanelLayout.createSequentialGroup()
332 .addGroup(attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
333 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, attachmentsPanelLayout.createSequentialGroup()
334 .addComponent(viewInNewWindowButton)
336 .addComponent(attachmentsScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 647, Short.MAX_VALUE)))
338 attachmentsPanelLayout.setVerticalGroup(
339 attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
340 .addGroup(attachmentsPanelLayout.createSequentialGroup()
342 .addComponent(viewInNewWindowButton)
343 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
344 .addComponent(attachmentsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE)
348 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.attachmentsPanel.TabConstraints.tabTitle"), attachmentsPanel);
350 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
351 this.setLayout(layout);
352 layout.setHorizontalGroup(
353 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
354 .addGroup(layout.createSequentialGroup()
356 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
357 .addComponent(msgbodyTabbedPane)
358 .addComponent(envelopePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
361 layout.setVerticalGroup(
362 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
363 .addGroup(layout.createSequentialGroup()
365 .addComponent(envelopePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
366 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
367 .addComponent(msgbodyTabbedPane)
371 msgbodyTabbedPane.getAccessibleContext().setAccessibleParent(null);
375 new NewWindowViewAction(
"View in new window", drpExplorerManager.getSelectedNodes()[0]).actionPerformed(evt);
409 artifact = getNodeArtifact(node);
410 if (artifact == null) {
419 if (artifact.getArtifactTypeID() == TSK_KEYWORD_HIT.getTypeID()) {
421 getAssociatedArtifact(artifact).ifPresent(associatedArtifact -> {
422 artifact = associatedArtifact;
424 }
catch (TskCoreException ex) {
425 LOGGER.log(Level.SEVERE,
"error getting associated artifact", ex);
429 if (artifact.getArtifactTypeID() == TSK_MESSAGE.getTypeID()) {
431 }
else if (artifact.getArtifactTypeID() == TSK_EMAIL_MSG.getTypeID()) {
448 private static Optional<BlackboardArtifact>
getAssociatedArtifact(
final BlackboardArtifact artifact)
throws TskCoreException {
449 BlackboardAttribute attribute = artifact.getAttribute(TSK_ASSOCIATED_TYPE);
450 if (attribute != null) {
451 return Optional.of(artifact.getSleuthkitCase().getArtifactByArtifactId(attribute.getValueLong()));
453 return Optional.empty();
457 @NbBundle.Messages(
"MessageContentViewer.title=Message")
459 return Bundle.MessageContentViewer_title();
463 @NbBundle.Messages(
"MessageContentViewer.toolTip=Displays messages.")
465 return Bundle.MessageContentViewer_toolTip();
481 fromText.setText(
"");
482 fromLabel.setEnabled(
false);
484 toLabel.setEnabled(
false);
486 ccLabel.setEnabled(
false);
487 subjectText.setText(
"");
488 subjectLabel.setEnabled(
false);
489 datetimeText.setText(
"");
490 datetimeText.setEnabled(
false);
491 directionText.setText(
"");
492 directionText.setEnabled(
false);
494 headersTextArea.setText(
"");
495 rtfbodyTextPane.setText(
"");
498 msgbodyTabbedPane.setEnabled(
false);
504 BlackboardArtifact nodeArtifact = getNodeArtifact(node);
506 if (nodeArtifact == null) {
510 if (nodeArtifact.getArtifactTypeID() == TSK_KEYWORD_HIT.getTypeID()) {
515 }
catch (TskCoreException ex) {
516 LOGGER.log(Level.SEVERE,
"error getting associated artifact", ex);
519 return isMessageArtifact(nodeArtifact);
532 final int artifactTypeID = nodeArtifact.getArtifactTypeID();
533 return artifactTypeID == TSK_EMAIL_MSG.getTypeID()
534 || artifactTypeID == TSK_MESSAGE.getTypeID();
549 BlackboardArtifact nodeArtifact = node.getLookup().lookup(BlackboardArtifact.class);
551 if (nodeArtifact == null) {
554 AbstractFile file = node.getLookup().lookup(AbstractFile.class);
556 List<BlackboardArtifact> artifactsList = tskCase.getBlackboardArtifacts(TSK_ASSOCIATED_OBJECT, file.getId());
558 for (BlackboardArtifact fileArtifact : artifactsList) {
559 BlackboardAttribute associatedArtifactAttribute = fileArtifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT));
560 if (associatedArtifactAttribute != null) {
561 BlackboardArtifact associatedArtifact = fileArtifact.getSleuthkitCase().getBlackboardArtifact(associatedArtifactAttribute.getValueLong());
562 if (isMessageArtifact(associatedArtifact)) {
563 nodeArtifact = associatedArtifact;
569 LOGGER.log(Level.SEVERE,
"Failed to get file for selected node.", ex);
580 if (isSupported(node)) {
581 BlackboardArtifact nodeArtifact = node.getLookup().lookup(BlackboardArtifact.class);
582 if (nodeArtifact != null) {
600 private void configureTextArea(BlackboardAttribute.ATTRIBUTE_TYPE type,
int index)
throws TskCoreException {
601 String attributeText = getAttributeValueSafe(artifact, type);
603 if (index == HTML_TAB_INDEX && StringUtils.isNotBlank(attributeText)) {
604 htmlPanel.setHtmlText(attributeText);
605 }
else if (index == TEXT_TAB_INDEX && StringUtils.isNotBlank(attributeText)) {
606 textPanel.setContent(attributeText, artifact.toString());
608 JTextComponent textComponent = textAreas.get(index);
609 if (textComponent != null) {
610 textComponent.setText(attributeText);
611 textComponent.setCaretPosition(0);
615 final boolean hasText = attributeText.length() > 0;
617 msgbodyTabbedPane.setEnabledAt(index, hasText);
619 msgbodyTabbedPane.setSelectedIndex(index);
624 msgbodyTabbedPane.setEnabled(
true);
625 fromLabel.setEnabled(
true);
626 toLabel.setEnabled(
true);
627 subjectLabel.setEnabled(
true);
628 datetimeText.setEnabled(
true);
633 final Set<Attachment> attachments;
636 BlackboardAttribute attachmentsAttr = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ATTACHMENTS));
637 if (attachmentsAttr != null) {
639 attachments =
new HashSet<>();
640 String jsonVal = attachmentsAttr.getValueString();
641 MessageAttachments msgAttachments =
new Gson().fromJson(jsonVal, MessageAttachments.class);
643 Collection<FileAttachment> fileAttachments = msgAttachments.getFileAttachments();
644 for (FileAttachment fileAttachment : fileAttachments) {
645 attachments.add(fileAttachment);
647 Collection<URLAttachment> urlAttachments = msgAttachments.getUrlAttachments();
648 for (URLAttachment urlAttachment : urlAttachments) {
649 attachments.add(urlAttachment);
652 attachments =
new HashSet<>();
653 for (Content child : artifact.getChildren()) {
654 if (child instanceof AbstractFile) {
655 attachments.add(
new FileAttachment((AbstractFile) child));
660 final int numberOfAttachments = attachments.size();
662 msgbodyTabbedPane.setEnabledAt(ATTM_TAB_INDEX, numberOfAttachments > 0);
663 msgbodyTabbedPane.setTitleAt(ATTM_TAB_INDEX,
"Attachments (" + numberOfAttachments +
")");
669 return "<html><body>" + htmlText +
"</body></html>";
673 enableCommonFields();
675 directionText.setEnabled(
false);
676 ccLabel.setEnabled(
true);
679 this.fromText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_FROM));
680 this.fromText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_FROM));
681 this.toText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_TO));
682 this.toText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_TO));
683 this.directionText.setText(
"");
684 this.ccText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_CC));
685 this.ccText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_CC));
686 this.subjectText.setText(getAttributeValueSafe(artifact, TSK_SUBJECT));
687 this.datetimeText.setText(getAttributeValueSafe(artifact, TSK_DATETIME_RCVD));
689 configureTextArea(TSK_HEADERS, HDR_TAB_INDEX);
690 configureTextArea(TSK_EMAIL_CONTENT_PLAIN, TEXT_TAB_INDEX);
691 configureTextArea(TSK_EMAIL_CONTENT_HTML, HTML_TAB_INDEX);
692 configureTextArea(TSK_EMAIL_CONTENT_RTF, RTF_TAB_INDEX);
693 configureAttachments();
694 }
catch (TskCoreException ex) {
695 LOGGER.log(Level.WARNING,
"Failed to get attributes for email message.", ex);
700 enableCommonFields();
702 directionText.setEnabled(
true);
703 ccLabel.setEnabled(
false);
706 this.fromText.setText(getAttributeValueSafe(artifact, TSK_PHONE_NUMBER_FROM));
707 this.toText.setText(getAttributeValueSafe(artifact, TSK_PHONE_NUMBER_TO));
708 this.directionText.setText(getAttributeValueSafe(artifact, TSK_DIRECTION));
709 this.ccText.setText(
"");
710 this.subjectText.setText(getAttributeValueSafe(artifact, TSK_SUBJECT));
711 this.datetimeText.setText(getAttributeValueSafe(artifact, TSK_DATETIME));
713 msgbodyTabbedPane.setEnabledAt(HTML_TAB_INDEX,
false);
714 msgbodyTabbedPane.setEnabledAt(RTF_TAB_INDEX,
false);
715 msgbodyTabbedPane.setEnabledAt(HDR_TAB_INDEX,
false);
716 msgbodyTabbedPane.setEnabledAt(HDR_TAB_INDEX,
false);
717 configureTextArea(TSK_TEXT, TEXT_TAB_INDEX);
718 configureAttachments();
719 }
catch (TskCoreException ex) {
720 LOGGER.log(Level.WARNING,
"Failed to get attributes for message.", ex);
724 private static String
getAttributeValueSafe(BlackboardArtifact artifact, BlackboardAttribute.ATTRIBUTE_TYPE type) throws TskCoreException {
725 return Optional.ofNullable(artifact.getAttribute(
new BlackboardAttribute.Type(type)))
726 .map(BlackboardAttribute::getDisplayString)
739 Document doc = Jsoup.parse(htmlInString);
742 doc.select(
"img[src]").forEach(img -> img.attr(
"src",
""));
755 this.attachments = attachments;
766 setKeys(attachments);
javax.swing.JPanel attachmentsPanel
static void configureTextPaneAsRtf(JTextPane pane)
final DataResultPanel drp
BlackboardArtifact getNodeArtifact(Node node)
static String cleanseHTML(String htmlInString)
javax.swing.JScrollPane rtfbodyScrollPane
int isPreferred(Node node)
final Set< Attachment > attachments
javax.swing.JLabel toLabel
void setText(String text)
javax.swing.JLabel ccText
static String getAttributeValueSafe(BlackboardArtifact artifact, BlackboardAttribute.ATTRIBUTE_TYPE type)
boolean isSupported(Node node)
static String wrapInHtmlBody(String htmlText)
javax.swing.JPanel envelopePanel
javax.swing.JLabel fromLabel
void configureTextArea(BlackboardAttribute.ATTRIBUTE_TYPE type, int index)
static boolean isMessageArtifact(BlackboardArtifact nodeArtifact)
ExplorerManager getExplorerManager()
javax.swing.JTabbedPane msgbodyTabbedPane
javax.swing.JScrollPane headersScrollPane
javax.swing.JLabel fromText
void setNode(Node rootNode)
javax.swing.JLabel datetimeText
javax.swing.JLabel ccLabel
javax.swing.JLabel toText
static DataResultPanel createInstanceUninitialized(String title, String description, Node currentRootNode, int childNodeCount, DataContent customContentView)
ExplorerManager drpExplorerManager
static Optional< BlackboardArtifact > getAssociatedArtifact(final BlackboardArtifact artifact)
javax.swing.JTextPane rtfbodyTextPane
javax.swing.JScrollPane attachmentsScrollPane
javax.swing.JPanel htmlPane
final List< JTextComponent > textAreas
BlackboardArtifact artifact
javax.swing.JLabel subjectLabel
SleuthkitCase getSleuthkitCase()
javax.swing.JButton viewInNewWindowButton
javax.swing.JLabel directionText
void enableCommonFields()
synchronized static Logger getLogger(String name)
void viewInNewWindowButtonActionPerformed(java.awt.event.ActionEvent evt)
static Case getCurrentCaseThrows()
void configureAttachments()
Node[] createNodes(Attachment t)
javax.swing.JLabel subjectText
DataContentViewer createInstance()
final void resetComponent()
javax.swing.JTextArea headersTextArea