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.util.Arrays;
26 import java.util.Collection;
27 import java.util.HashSet;
28 import java.util.List;
29 import java.util.Optional;
31 import java.util.logging.Level;
32 import javax.swing.text.JTextComponent;
33 import org.apache.commons.lang3.StringUtils;
34 import org.jsoup.Jsoup;
35 import org.jsoup.nodes.Document;
36 import org.openide.explorer.ExplorerManager;
37 import org.openide.nodes.AbstractNode;
38 import org.openide.nodes.Children;
39 import org.openide.nodes.Node;
40 import org.openide.util.NbBundle;
41 import org.openide.util.lookup.ServiceProvider;
52 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_ASSOCIATED_OBJECT;
53 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG;
54 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT;
55 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE;
57 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT;
58 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME;
59 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_RCVD;
60 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DIRECTION;
61 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CC;
62 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_HTML;
63 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_PLAIN;
64 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_RTF;
65 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_FROM;
66 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_TO;
67 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_HEADERS;
68 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
69 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
70 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT;
71 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEXT;
75 import org.
sleuthkit.datamodel.blackboardutils.FileAttachment;
76 import org.
sleuthkit.datamodel.blackboardutils.MessageAttachments;
77 import org.
sleuthkit.datamodel.blackboardutils.Attachment;
78 import org.
sleuthkit.datamodel.blackboardutils.URLAttachment;
83 @ServiceProvider(service = DataContentViewer.class, position = 5)
84 @SuppressWarnings(
"PMD.SingularField")
87 private static final long serialVersionUID = 1L;
89 private static final BlackboardAttribute.Type TSK_ASSOCIATED_TYPE =
new BlackboardAttribute.Type(TSK_ASSOCIATED_ARTIFACT);
91 private static final int HDR_TAB_INDEX = 0;
92 private static final int TEXT_TAB_INDEX = 1;
93 private static final int HTML_TAB_INDEX = 2;
94 private static final int RTF_TAB_INDEX = 3;
95 private static final int ATTM_TAB_INDEX = 4;
109 @NbBundle.Messages(
"MessageContentViewer.AtrachmentsPanel.title=Attachments")
112 htmlPane.add(htmlPanel);
113 envelopePanel.setBackground(
new Color(0, 0, 0, 38));
115 attachmentsScrollPane.setViewportView(drp);
116 msgbodyTabbedPane.setEnabledAt(ATTM_TAB_INDEX,
true);
122 textAreas = Arrays.asList(headersTextArea, textbodyTextArea, null, rtfbodyTextPane);
135 drpExplorerManager.addPropertyChangeListener(evt
136 -> viewInNewWindowButton.setEnabled(drpExplorerManager.getSelectedNodes().length == 1));
144 @SuppressWarnings(
"unchecked")
146 private
void initComponents() {
148 envelopePanel =
new javax.swing.JPanel();
149 fromLabel =
new javax.swing.JLabel();
150 datetimeText =
new javax.swing.JLabel();
151 fromText =
new javax.swing.JLabel();
152 toLabel =
new javax.swing.JLabel();
153 toText =
new javax.swing.JLabel();
154 ccLabel =
new javax.swing.JLabel();
155 ccText =
new javax.swing.JLabel();
156 subjectLabel =
new javax.swing.JLabel();
157 subjectText =
new javax.swing.JLabel();
158 directionText =
new javax.swing.JLabel();
159 msgbodyTabbedPane =
new javax.swing.JTabbedPane();
160 headersScrollPane =
new javax.swing.JScrollPane();
161 headersTextArea =
new javax.swing.JTextArea();
162 textbodyScrollPane =
new javax.swing.JScrollPane();
163 textbodyTextArea =
new javax.swing.JTextArea();
164 htmlPane =
new javax.swing.JPanel();
165 rtfbodyScrollPane =
new javax.swing.JScrollPane();
166 rtfbodyTextPane =
new javax.swing.JTextPane();
167 attachmentsPanel =
new javax.swing.JPanel();
168 viewInNewWindowButton =
new javax.swing.JButton();
169 attachmentsScrollPane =
new javax.swing.JScrollPane();
171 envelopePanel.setBackground(
new java.awt.Color(204, 204, 204));
173 org.openide.awt.Mnemonics.setLocalizedText(fromLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.fromLabel.text"));
175 datetimeText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
176 org.openide.awt.Mnemonics.setLocalizedText(datetimeText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.datetimeText.text"));
178 org.openide.awt.Mnemonics.setLocalizedText(fromText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.fromText.text"));
180 org.openide.awt.Mnemonics.setLocalizedText(toLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.toLabel.text"));
182 org.openide.awt.Mnemonics.setLocalizedText(toText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.toText.text"));
183 toText.setAutoscrolls(
true);
184 toText.setMinimumSize(
new java.awt.Dimension(27, 14));
186 org.openide.awt.Mnemonics.setLocalizedText(ccLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.ccLabel.text"));
188 org.openide.awt.Mnemonics.setLocalizedText(ccText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.ccText.text"));
189 ccText.setMinimumSize(
new java.awt.Dimension(27, 14));
191 org.openide.awt.Mnemonics.setLocalizedText(subjectLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.subjectLabel.text"));
193 org.openide.awt.Mnemonics.setLocalizedText(subjectText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.subjectText.text"));
194 subjectText.setMinimumSize(
new java.awt.Dimension(26, 14));
196 directionText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
197 org.openide.awt.Mnemonics.setLocalizedText(directionText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.directionText.text"));
199 javax.swing.GroupLayout envelopePanelLayout =
new javax.swing.GroupLayout(envelopePanel);
200 envelopePanel.setLayout(envelopePanelLayout);
201 envelopePanelLayout.setHorizontalGroup(
202 envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
203 .addGroup(envelopePanelLayout.createSequentialGroup()
205 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
206 .addGroup(envelopePanelLayout.createSequentialGroup()
207 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
208 .addComponent(fromLabel)
209 .addComponent(toLabel))
210 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
211 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
212 .addGroup(envelopePanelLayout.createSequentialGroup()
213 .addComponent(toText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
214 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
215 .addComponent(directionText, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
216 .addGroup(envelopePanelLayout.createSequentialGroup()
217 .addComponent(fromText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
218 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
219 .addComponent(datetimeText, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))))
220 .addGroup(envelopePanelLayout.createSequentialGroup()
221 .addComponent(ccLabel)
223 .addComponent(ccText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
224 .addGroup(envelopePanelLayout.createSequentialGroup()
225 .addComponent(subjectLabel)
226 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
227 .addComponent(subjectText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
230 envelopePanelLayout.setVerticalGroup(
231 envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
232 .addGroup(envelopePanelLayout.createSequentialGroup()
234 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
235 .addComponent(fromLabel)
236 .addComponent(datetimeText)
237 .addComponent(fromText))
238 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
239 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
240 .addComponent(toLabel)
241 .addComponent(toText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
242 .addComponent(directionText))
243 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
244 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
245 .addComponent(ccLabel)
246 .addComponent(ccText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
247 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
248 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
249 .addComponent(subjectLabel)
250 .addComponent(subjectText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
254 headersScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
255 headersScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
257 headersTextArea.setEditable(
false);
258 headersTextArea.setColumns(20);
259 headersTextArea.setLineWrap(
true);
260 headersTextArea.setRows(5);
261 headersTextArea.setWrapStyleWord(
true);
262 headersScrollPane.setViewportView(headersTextArea);
264 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.headersScrollPane.TabConstraints.tabTitle"), headersScrollPane);
266 textbodyScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
267 textbodyScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
269 textbodyTextArea.setEditable(
false);
270 textbodyTextArea.setLineWrap(
true);
271 textbodyTextArea.setRows(5);
272 textbodyTextArea.setWrapStyleWord(
true);
273 textbodyScrollPane.setViewportView(textbodyTextArea);
275 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.textbodyScrollPane.TabConstraints.tabTitle"), textbodyScrollPane);
277 htmlPane.setLayout(
new java.awt.BorderLayout());
278 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.htmlPane.TabConstraints.tabTitle"), htmlPane);
280 rtfbodyScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
282 rtfbodyTextPane.setEditable(
false);
283 rtfbodyScrollPane.setViewportView(rtfbodyTextPane);
285 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.rtfbodyScrollPane.TabConstraints.tabTitle"), rtfbodyScrollPane);
287 org.openide.awt.Mnemonics.setLocalizedText(viewInNewWindowButton,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.viewInNewWindowButton.text"));
288 viewInNewWindowButton.addActionListener(
new java.awt.event.ActionListener() {
289 public void actionPerformed(java.awt.event.ActionEvent evt) {
290 viewInNewWindowButtonActionPerformed(evt);
294 javax.swing.GroupLayout attachmentsPanelLayout =
new javax.swing.GroupLayout(attachmentsPanel);
295 attachmentsPanel.setLayout(attachmentsPanelLayout);
296 attachmentsPanelLayout.setHorizontalGroup(
297 attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
298 .addGroup(attachmentsPanelLayout.createSequentialGroup()
300 .addGroup(attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
301 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, attachmentsPanelLayout.createSequentialGroup()
302 .addComponent(viewInNewWindowButton)
304 .addComponent(attachmentsScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 647, Short.MAX_VALUE)))
306 attachmentsPanelLayout.setVerticalGroup(
307 attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
308 .addGroup(attachmentsPanelLayout.createSequentialGroup()
310 .addComponent(viewInNewWindowButton)
311 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
312 .addComponent(attachmentsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE)
316 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.attachmentsPanel.TabConstraints.tabTitle"), attachmentsPanel);
318 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
319 this.setLayout(layout);
320 layout.setHorizontalGroup(
321 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
322 .addGroup(layout.createSequentialGroup()
324 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
325 .addComponent(msgbodyTabbedPane)
326 .addComponent(envelopePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
329 layout.setVerticalGroup(
330 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
331 .addGroup(layout.createSequentialGroup()
333 .addComponent(envelopePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
334 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
335 .addComponent(msgbodyTabbedPane)
341 new NewWindowViewAction(
"View in new window", drpExplorerManager.getSelectedNodes()[0]).actionPerformed(evt);
377 artifact = getNodeArtifact(node);
378 if (artifact == null) {
387 if (artifact.getArtifactTypeID() == TSK_KEYWORD_HIT.getTypeID()) {
389 getAssociatedArtifact(artifact).ifPresent(associatedArtifact -> {
390 artifact = associatedArtifact;
392 }
catch (TskCoreException ex) {
393 LOGGER.log(Level.SEVERE,
"error getting associated artifact", ex);
397 if (artifact.getArtifactTypeID() == TSK_MESSAGE.getTypeID()) {
399 }
else if (artifact.getArtifactTypeID() == TSK_EMAIL_MSG.getTypeID()) {
416 private static Optional<BlackboardArtifact>
getAssociatedArtifact(
final BlackboardArtifact artifact)
throws TskCoreException {
417 BlackboardAttribute attribute = artifact.getAttribute(TSK_ASSOCIATED_TYPE);
418 if (attribute != null) {
419 return Optional.of(artifact.getSleuthkitCase().getArtifactByArtifactId(attribute.getValueLong()));
421 return Optional.empty();
425 @NbBundle.Messages(
"MessageContentViewer.title=Message")
427 return Bundle.MessageContentViewer_title();
431 @NbBundle.Messages(
"MessageContentViewer.toolTip=Displays messages.")
433 return Bundle.MessageContentViewer_toolTip();
449 fromText.setText(
"");
450 fromLabel.setEnabled(
false);
452 toLabel.setEnabled(
false);
454 ccLabel.setEnabled(
false);
455 subjectText.setText(
"");
456 subjectLabel.setEnabled(
false);
457 datetimeText.setText(
"");
458 datetimeText.setEnabled(
false);
459 directionText.setText(
"");
460 directionText.setEnabled(
false);
462 headersTextArea.setText(
"");
463 rtfbodyTextPane.setText(
"");
465 textbodyTextArea.setText(
"");
466 msgbodyTabbedPane.setEnabled(
false);
472 BlackboardArtifact nodeArtifact = getNodeArtifact(node);
474 if (nodeArtifact == null) {
478 if (nodeArtifact.getArtifactTypeID() == TSK_KEYWORD_HIT.getTypeID()) {
483 }
catch (TskCoreException ex) {
484 LOGGER.log(Level.SEVERE,
"error getting associated artifact", ex);
487 return isMessageArtifact(nodeArtifact);
500 final int artifactTypeID = nodeArtifact.getArtifactTypeID();
501 return artifactTypeID == TSK_EMAIL_MSG.getTypeID()
502 || artifactTypeID == TSK_MESSAGE.getTypeID();
517 BlackboardArtifact nodeArtifact = node.getLookup().lookup(BlackboardArtifact.class);
519 if (nodeArtifact == null) {
522 AbstractFile file = node.getLookup().lookup(AbstractFile.class);
524 List<BlackboardArtifact> artifactsList = tskCase.getBlackboardArtifacts(TSK_ASSOCIATED_OBJECT, file.getId());
526 for (BlackboardArtifact fileArtifact : artifactsList) {
527 BlackboardAttribute associatedArtifactAttribute = fileArtifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT));
528 if (associatedArtifactAttribute != null) {
529 BlackboardArtifact associatedArtifact = fileArtifact.getSleuthkitCase().getBlackboardArtifact(associatedArtifactAttribute.getValueLong());
530 if (isMessageArtifact(associatedArtifact)) {
531 nodeArtifact = associatedArtifact;
537 LOGGER.log(Level.SEVERE,
"Failed to get file for selected node.", ex);
548 if (isSupported(node)) {
549 BlackboardArtifact nodeArtifact = node.getLookup().lookup(BlackboardArtifact.class);
550 if (nodeArtifact != null) {
568 private void configureTextArea(BlackboardAttribute.ATTRIBUTE_TYPE type,
int index)
throws TskCoreException {
569 String attributeText = getAttributeValueSafe(artifact, type);
571 if (index == HTML_TAB_INDEX && StringUtils.isNotBlank(attributeText)) {
572 htmlPanel.setHtmlText(attributeText);
574 JTextComponent textComponent = textAreas.get(index);
575 if (textComponent != null) {
576 textComponent.setText(attributeText);
577 textComponent.setCaretPosition(0);
581 final boolean hasText = attributeText.length() > 0;
583 msgbodyTabbedPane.setEnabledAt(index, hasText);
585 msgbodyTabbedPane.setSelectedIndex(index);
590 msgbodyTabbedPane.setEnabled(
true);
591 fromLabel.setEnabled(
true);
592 toLabel.setEnabled(
true);
593 subjectLabel.setEnabled(
true);
594 datetimeText.setEnabled(
true);
599 final Set<Attachment> attachments;
602 BlackboardAttribute attachmentsAttr = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ATTACHMENTS));
603 if(attachmentsAttr != null) {
605 attachments =
new HashSet<>();
606 String jsonVal = attachmentsAttr.getValueString();
607 MessageAttachments msgAttachments =
new Gson().fromJson(jsonVal, MessageAttachments.class);
609 Collection<FileAttachment> fileAttachments = msgAttachments.getFileAttachments();
610 for (FileAttachment fileAttachment: fileAttachments) {
611 attachments.add(fileAttachment);
613 Collection<URLAttachment> urlAttachments = msgAttachments.getUrlAttachments();
614 for (URLAttachment urlAttachment: urlAttachments) {
615 attachments.add(urlAttachment);
618 attachments =
new HashSet<>();
619 for (Content child: artifact.getChildren()) {
620 if (child instanceof AbstractFile) {
621 attachments.add(
new FileAttachment((AbstractFile)child));
626 final int numberOfAttachments = attachments.size();
628 msgbodyTabbedPane.setEnabledAt(ATTM_TAB_INDEX, numberOfAttachments > 0);
629 msgbodyTabbedPane.setTitleAt(ATTM_TAB_INDEX,
"Attachments (" + numberOfAttachments +
")");
635 return "<html><body>" + htmlText +
"</body></html>";
639 enableCommonFields();
641 directionText.setEnabled(
false);
642 ccLabel.setEnabled(
true);
645 this.fromText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_FROM));
646 this.fromText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_FROM));
647 this.toText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_TO));
648 this.toText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_TO));
649 this.directionText.setText(
"");
650 this.ccText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_CC));
651 this.ccText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_CC));
652 this.subjectText.setText(getAttributeValueSafe(artifact, TSK_SUBJECT));
653 this.datetimeText.setText(getAttributeValueSafe(artifact, TSK_DATETIME_RCVD));
655 configureTextArea(TSK_HEADERS, HDR_TAB_INDEX);
656 configureTextArea(TSK_EMAIL_CONTENT_PLAIN, TEXT_TAB_INDEX);
657 configureTextArea(TSK_EMAIL_CONTENT_HTML, HTML_TAB_INDEX);
658 configureTextArea(TSK_EMAIL_CONTENT_RTF, RTF_TAB_INDEX);
659 configureAttachments();
660 }
catch (TskCoreException ex) {
661 LOGGER.log(Level.WARNING,
"Failed to get attributes for email message.", ex);
666 enableCommonFields();
668 directionText.setEnabled(
true);
669 ccLabel.setEnabled(
false);
672 this.fromText.setText(getAttributeValueSafe(artifact, TSK_PHONE_NUMBER_FROM));
673 this.toText.setText(getAttributeValueSafe(artifact, TSK_PHONE_NUMBER_TO));
674 this.directionText.setText(getAttributeValueSafe(artifact, TSK_DIRECTION));
675 this.ccText.setText(
"");
676 this.subjectText.setText(getAttributeValueSafe(artifact, TSK_SUBJECT));
677 this.datetimeText.setText(getAttributeValueSafe(artifact, TSK_DATETIME));
679 msgbodyTabbedPane.setEnabledAt(HTML_TAB_INDEX,
false);
680 msgbodyTabbedPane.setEnabledAt(RTF_TAB_INDEX,
false);
681 msgbodyTabbedPane.setEnabledAt(HDR_TAB_INDEX,
false);
682 msgbodyTabbedPane.setEnabledAt(HDR_TAB_INDEX,
false);
683 configureTextArea(TSK_TEXT, TEXT_TAB_INDEX);
684 configureAttachments();
685 }
catch (TskCoreException ex) {
686 LOGGER.log(Level.WARNING,
"Failed to get attributes for message.", ex);
690 private static String
getAttributeValueSafe(BlackboardArtifact artifact, BlackboardAttribute.ATTRIBUTE_TYPE type) throws TskCoreException {
691 return Optional.ofNullable(artifact.getAttribute(
new BlackboardAttribute.Type(type)))
692 .map(BlackboardAttribute::getDisplayString)
705 Document doc = Jsoup.parse(htmlInString);
708 doc.select(
"img[src]").forEach(img -> img.attr(
"src",
""));
722 this.attachments = attachments;
733 setKeys(attachments);
javax.swing.JScrollPane textbodyScrollPane
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
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)
javax.swing.JTextArea textbodyTextArea
static Case getCurrentCaseThrows()
void configureAttachments()
Node[] createNodes(Attachment t)
javax.swing.JLabel subjectText
DataContentViewer createInstance()
final void resetComponent()
javax.swing.JTextArea headersTextArea