19 package org.sleuthkit.autopsy.contentviewers;
21 import java.awt.Component;
22 import java.util.Arrays;
23 import java.util.List;
24 import java.util.Optional;
26 import java.util.logging.Level;
27 import java.util.stream.Collectors;
28 import javax.swing.text.JTextComponent;
29 import org.apache.commons.lang3.StringUtils;
30 import org.jsoup.Jsoup;
31 import org.jsoup.nodes.Document;
32 import org.openide.explorer.ExplorerManager;
33 import org.openide.nodes.AbstractNode;
34 import org.openide.nodes.Children;
35 import org.openide.nodes.Node;
36 import org.openide.nodes.Sheet;
37 import org.openide.util.NbBundle;
38 import org.openide.util.lookup.ServiceProvider;
49 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG;
50 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT;
51 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE;
53 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT;
54 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME;
55 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_RCVD;
56 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DIRECTION;
57 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CC;
58 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_HTML;
59 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_PLAIN;
60 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_RTF;
61 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_FROM;
62 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_TO;
63 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_HEADERS;
64 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
65 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
66 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT;
67 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEXT;
73 @ServiceProvider(service = DataContentViewer.class, position = 5)
74 @SuppressWarnings(
"PMD.SingularField")
77 private static final long serialVersionUID = 1L;
79 private static final BlackboardAttribute.Type TSK_ASSOCIATED_TYPE =
new BlackboardAttribute.Type(TSK_ASSOCIATED_ARTIFACT);
81 private static final int HDR_TAB_INDEX = 0;
82 private static final int TEXT_TAB_INDEX = 1;
83 private static final int HTML_TAB_INDEX = 2;
84 private static final int RTF_TAB_INDEX = 3;
85 private static final int ATTM_TAB_INDEX = 4;
99 @NbBundle.Messages(
"MessageContentViewer.AtrachmentsPanel.title=Attachments")
103 attachmentsScrollPane.setViewportView(drp);
104 msgbodyTabbedPane.setEnabledAt(ATTM_TAB_INDEX,
true);
106 textAreas = Arrays.asList(headersTextArea, textbodyTextArea, htmlbodyTextPane, rtfbodyTextPane);
120 drpExplorerManager.addPropertyChangeListener(evt ->
121 viewInNewWindowButton.setEnabled(drpExplorerManager.getSelectedNodes().length == 1));
129 @SuppressWarnings(
"unchecked")
131 private
void initComponents() {
133 envelopePanel =
new javax.swing.JPanel();
134 fromLabel =
new javax.swing.JLabel();
135 datetimeText =
new javax.swing.JLabel();
136 fromText =
new javax.swing.JLabel();
137 toLabel =
new javax.swing.JLabel();
138 toText =
new javax.swing.JLabel();
139 ccLabel =
new javax.swing.JLabel();
140 ccText =
new javax.swing.JLabel();
141 subjectLabel =
new javax.swing.JLabel();
142 subjectText =
new javax.swing.JLabel();
143 directionText =
new javax.swing.JLabel();
144 msgbodyTabbedPane =
new javax.swing.JTabbedPane();
145 headersScrollPane =
new javax.swing.JScrollPane();
146 headersTextArea =
new javax.swing.JTextArea();
147 textbodyScrollPane =
new javax.swing.JScrollPane();
148 textbodyTextArea =
new javax.swing.JTextArea();
149 htmlPane =
new javax.swing.JPanel();
150 htmlScrollPane =
new javax.swing.JScrollPane();
151 htmlbodyTextPane =
new javax.swing.JTextPane();
152 showImagesToggleButton =
new javax.swing.JToggleButton();
153 rtfbodyScrollPane =
new javax.swing.JScrollPane();
154 rtfbodyTextPane =
new javax.swing.JTextPane();
155 attachmentsPanel =
new javax.swing.JPanel();
156 viewInNewWindowButton =
new javax.swing.JButton();
157 attachmentsScrollPane =
new javax.swing.JScrollPane();
159 envelopePanel.setBackground(
new java.awt.Color(204, 204, 204));
161 org.openide.awt.Mnemonics.setLocalizedText(fromLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.fromLabel.text"));
163 datetimeText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
164 org.openide.awt.Mnemonics.setLocalizedText(datetimeText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.datetimeText.text"));
166 org.openide.awt.Mnemonics.setLocalizedText(fromText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.fromText.text"));
168 org.openide.awt.Mnemonics.setLocalizedText(toLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.toLabel.text"));
170 org.openide.awt.Mnemonics.setLocalizedText(toText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.toText.text"));
171 toText.setAutoscrolls(
true);
172 toText.setMinimumSize(
new java.awt.Dimension(27, 14));
174 org.openide.awt.Mnemonics.setLocalizedText(ccLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.ccLabel.text"));
176 org.openide.awt.Mnemonics.setLocalizedText(ccText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.ccText.text"));
177 ccText.setMinimumSize(
new java.awt.Dimension(27, 14));
179 org.openide.awt.Mnemonics.setLocalizedText(subjectLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.subjectLabel.text"));
181 org.openide.awt.Mnemonics.setLocalizedText(subjectText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.subjectText.text"));
182 subjectText.setMinimumSize(
new java.awt.Dimension(26, 14));
184 directionText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
185 org.openide.awt.Mnemonics.setLocalizedText(directionText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.directionText.text"));
187 javax.swing.GroupLayout envelopePanelLayout =
new javax.swing.GroupLayout(envelopePanel);
188 envelopePanel.setLayout(envelopePanelLayout);
189 envelopePanelLayout.setHorizontalGroup(
190 envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
191 .addGroup(envelopePanelLayout.createSequentialGroup()
193 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
194 .addGroup(envelopePanelLayout.createSequentialGroup()
195 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
196 .addComponent(fromLabel)
197 .addComponent(toLabel))
198 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
199 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
200 .addGroup(envelopePanelLayout.createSequentialGroup()
201 .addComponent(toText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
202 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
203 .addComponent(directionText, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
204 .addGroup(envelopePanelLayout.createSequentialGroup()
205 .addComponent(fromText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
206 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
207 .addComponent(datetimeText, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))))
208 .addGroup(envelopePanelLayout.createSequentialGroup()
209 .addComponent(ccLabel)
211 .addComponent(ccText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
212 .addGroup(envelopePanelLayout.createSequentialGroup()
213 .addComponent(subjectLabel)
214 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
215 .addComponent(subjectText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
218 envelopePanelLayout.setVerticalGroup(
219 envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
220 .addGroup(envelopePanelLayout.createSequentialGroup()
222 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
223 .addComponent(fromLabel)
224 .addComponent(datetimeText)
225 .addComponent(fromText))
226 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
227 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
228 .addComponent(toLabel)
229 .addComponent(toText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
230 .addComponent(directionText))
231 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
232 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
233 .addComponent(ccLabel)
234 .addComponent(ccText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
235 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
236 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
237 .addComponent(subjectLabel)
238 .addComponent(subjectText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
242 headersScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
243 headersScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
245 headersTextArea.setEditable(
false);
246 headersTextArea.setColumns(20);
247 headersTextArea.setLineWrap(
true);
248 headersTextArea.setRows(5);
249 headersTextArea.setWrapStyleWord(
true);
250 headersScrollPane.setViewportView(headersTextArea);
252 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.headersScrollPane.TabConstraints.tabTitle"), headersScrollPane);
254 textbodyScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
255 textbodyScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
257 textbodyTextArea.setEditable(
false);
258 textbodyTextArea.setLineWrap(
true);
259 textbodyTextArea.setRows(5);
260 textbodyTextArea.setWrapStyleWord(
true);
261 textbodyScrollPane.setViewportView(textbodyTextArea);
263 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.textbodyScrollPane.TabConstraints.tabTitle"), textbodyScrollPane);
265 htmlScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
267 htmlbodyTextPane.setEditable(
false);
268 htmlScrollPane.setViewportView(htmlbodyTextPane);
270 org.openide.awt.Mnemonics.setLocalizedText(showImagesToggleButton,
"Show Images");
271 showImagesToggleButton.addActionListener(
new java.awt.event.ActionListener() {
272 public void actionPerformed(java.awt.event.ActionEvent evt) {
273 showImagesToggleButtonActionPerformed(evt);
277 javax.swing.GroupLayout htmlPaneLayout =
new javax.swing.GroupLayout(htmlPane);
278 htmlPane.setLayout(htmlPaneLayout);
279 htmlPaneLayout.setHorizontalGroup(
280 htmlPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
281 .addComponent(htmlScrollPane)
282 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, htmlPaneLayout.createSequentialGroup()
283 .addContainerGap(533, Short.MAX_VALUE)
284 .addComponent(showImagesToggleButton)
287 htmlPaneLayout.setVerticalGroup(
288 htmlPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
289 .addGroup(htmlPaneLayout.createSequentialGroup()
290 .addComponent(showImagesToggleButton)
291 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
292 .addComponent(htmlScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE)
296 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.htmlPane.TabConstraints.tabTitle"), htmlPane);
298 rtfbodyScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
300 rtfbodyTextPane.setEditable(
false);
301 rtfbodyScrollPane.setViewportView(rtfbodyTextPane);
303 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.rtfbodyScrollPane.TabConstraints.tabTitle"), rtfbodyScrollPane);
305 org.openide.awt.Mnemonics.setLocalizedText(viewInNewWindowButton,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.viewInNewWindowButton.text"));
306 viewInNewWindowButton.addActionListener(
new java.awt.event.ActionListener() {
307 public void actionPerformed(java.awt.event.ActionEvent evt) {
308 viewInNewWindowButtonActionPerformed(evt);
312 javax.swing.GroupLayout attachmentsPanelLayout =
new javax.swing.GroupLayout(attachmentsPanel);
313 attachmentsPanel.setLayout(attachmentsPanelLayout);
314 attachmentsPanelLayout.setHorizontalGroup(
315 attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
316 .addGroup(attachmentsPanelLayout.createSequentialGroup()
318 .addGroup(attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
319 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, attachmentsPanelLayout.createSequentialGroup()
320 .addComponent(viewInNewWindowButton)
322 .addComponent(attachmentsScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 647, Short.MAX_VALUE)))
324 attachmentsPanelLayout.setVerticalGroup(
325 attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
326 .addGroup(attachmentsPanelLayout.createSequentialGroup()
328 .addComponent(viewInNewWindowButton)
329 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
330 .addComponent(attachmentsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE)
334 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.attachmentsPanel.TabConstraints.tabTitle"), attachmentsPanel);
336 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
337 this.setLayout(layout);
338 layout.setHorizontalGroup(
339 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
340 .addGroup(layout.createSequentialGroup()
342 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
343 .addComponent(msgbodyTabbedPane)
344 .addComponent(envelopePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
347 layout.setVerticalGroup(
348 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
349 .addGroup(layout.createSequentialGroup()
351 .addComponent(envelopePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
352 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
353 .addComponent(msgbodyTabbedPane)
359 "MessageContentViewer.showImagesToggleButton.hide.text=Hide Images",
360 "MessageContentViewer.showImagesToggleButton.text=Show Images"})
363 String htmlText = getAttributeValueSafe(artifact, TSK_EMAIL_CONTENT_HTML);
364 if (
false == htmlText.isEmpty()) {
365 if (showImagesToggleButton.isSelected()) {
366 showImagesToggleButton.setText(Bundle.MessageContentViewer_showImagesToggleButton_hide_text());
367 this.htmlbodyTextPane.setText(wrapInHtmlBody(htmlText));
369 showImagesToggleButton.setText(Bundle.MessageContentViewer_showImagesToggleButton_text());
370 this.htmlbodyTextPane.setText(wrapInHtmlBody(cleanseHTML(htmlText)));
373 }
catch (TskCoreException ex) {
374 LOGGER.log(Level.WARNING,
"Failed to get attributes for email message.", ex);
379 new NewWindowViewAction(
"View in new window", drpExplorerManager.getSelectedNodes()[0]).actionPerformed(evt);
418 artifact = node.getLookup().lookup(BlackboardArtifact.class);
419 if (artifact == null) {
428 if (artifact.getArtifactTypeID() == TSK_KEYWORD_HIT.getTypeID()) {
430 getAssociatedArtifact(artifact).ifPresent(associatedArtifact -> {
431 artifact = associatedArtifact;
433 }
catch (TskCoreException ex) {
434 LOGGER.log(Level.SEVERE,
"error getting associated artifact", ex);
438 if (artifact.getArtifactTypeID() == TSK_MESSAGE.getTypeID()) {
440 }
else if (artifact.getArtifactTypeID() == TSK_EMAIL_MSG.getTypeID()) {
457 private static Optional<BlackboardArtifact>
getAssociatedArtifact(
final BlackboardArtifact artifact)
throws TskCoreException {
458 BlackboardAttribute attribute = artifact.getAttribute(TSK_ASSOCIATED_TYPE);
459 if (attribute != null) {
460 return Optional.of(artifact.getSleuthkitCase().getArtifactByArtifactId(attribute.getValueLong()));
462 return Optional.empty();
466 @NbBundle.Messages(
"MessageContentViewer.title=Message")
468 return Bundle.MessageContentViewer_title();
472 @NbBundle.Messages(
"MessageContentViewer.toolTip=Displays messages.")
474 return Bundle.MessageContentViewer_toolTip();
490 fromText.setText(
"");
491 fromLabel.setEnabled(
false);
493 toLabel.setEnabled(
false);
495 ccLabel.setEnabled(
false);
496 subjectText.setText(
"");
497 subjectLabel.setEnabled(
false);
498 datetimeText.setText(
"");
499 datetimeText.setEnabled(
false);
500 directionText.setText(
"");
501 directionText.setEnabled(
false);
503 headersTextArea.setText(
"");
504 rtfbodyTextPane.setText(
"");
505 htmlbodyTextPane.setText(
"");
506 textbodyTextArea.setText(
"");
507 showImagesToggleButton.setEnabled(
false);
508 msgbodyTabbedPane.setEnabled(
false);
513 BlackboardArtifact nodeArtifact = node.getLookup().lookup(BlackboardArtifact.class);
515 if (nodeArtifact == null) {
519 if (nodeArtifact.getArtifactTypeID() == TSK_KEYWORD_HIT.getTypeID()) {
524 }
catch (TskCoreException ex) {
525 LOGGER.log(Level.SEVERE,
"error getting associated artifact", ex);
528 return isMessageArtifact(nodeArtifact);
541 final int artifactTypeID = nodeArtifact.getArtifactTypeID();
542 return artifactTypeID == TSK_EMAIL_MSG.getTypeID()
543 || artifactTypeID == TSK_MESSAGE.getTypeID();
548 if (isSupported(node)) {
563 private void configureTextArea(BlackboardAttribute.ATTRIBUTE_TYPE type,
int index)
throws TskCoreException {
564 String attributeText = getAttributeValueSafe(artifact, type);
566 if (index == HTML_TAB_INDEX && StringUtils.isNotBlank(attributeText)) {
568 attributeText = wrapInHtmlBody(cleanseHTML(attributeText));
570 JTextComponent textComponent = textAreas.get(index);
571 textComponent.setText(attributeText);
572 textComponent.setCaretPosition(0);
573 final boolean hasText = attributeText.length() > 0;
575 msgbodyTabbedPane.setEnabledAt(index, hasText);
577 msgbodyTabbedPane.setSelectedIndex(index);
582 msgbodyTabbedPane.setEnabled(
true);
583 fromLabel.setEnabled(
true);
584 toLabel.setEnabled(
true);
585 subjectLabel.setEnabled(
true);
586 datetimeText.setEnabled(
true);
591 final Set<AbstractFile> attachments = artifact.getChildren().stream()
592 .filter(AbstractFile.class::isInstance)
593 .map(AbstractFile.class::cast)
594 .collect(Collectors.toSet());
595 final int numberOfAttachments = attachments.size();
597 msgbodyTabbedPane.setEnabledAt(ATTM_TAB_INDEX, numberOfAttachments > 0);
598 msgbodyTabbedPane.setTitleAt(ATTM_TAB_INDEX,
"Attachments (" + numberOfAttachments +
")");
604 return "<html><body>" + htmlText +
"</body></html>";
608 enableCommonFields();
610 directionText.setEnabled(
false);
611 ccLabel.setEnabled(
true);
613 showImagesToggleButton.setEnabled(
true);
614 showImagesToggleButton.setText(
"Show Images");
615 showImagesToggleButton.setSelected(
false);
618 this.fromText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_FROM));
619 this.fromText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_FROM));
620 this.toText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_TO));
621 this.toText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_TO));
622 this.directionText.setText(
"");
623 this.ccText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_CC));
624 this.ccText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_CC));
625 this.subjectText.setText(getAttributeValueSafe(artifact, TSK_SUBJECT));
626 this.datetimeText.setText(getAttributeValueSafe(artifact, TSK_DATETIME_RCVD));
628 configureTextArea(TSK_HEADERS, HDR_TAB_INDEX);
629 configureTextArea(TSK_EMAIL_CONTENT_PLAIN, TEXT_TAB_INDEX);
630 configureTextArea(TSK_EMAIL_CONTENT_HTML, HTML_TAB_INDEX);
631 configureTextArea(TSK_EMAIL_CONTENT_RTF, RTF_TAB_INDEX);
632 configureAttachments();
633 }
catch (TskCoreException ex) {
634 LOGGER.log(Level.WARNING,
"Failed to get attributes for email message.", ex);
639 enableCommonFields();
641 directionText.setEnabled(
true);
642 ccLabel.setEnabled(
false);
645 this.fromText.setText(getAttributeValueSafe(artifact, TSK_PHONE_NUMBER_FROM));
646 this.toText.setText(getAttributeValueSafe(artifact, TSK_PHONE_NUMBER_TO));
647 this.directionText.setText(getAttributeValueSafe(artifact, TSK_DIRECTION));
648 this.ccText.setText(
"");
649 this.subjectText.setText(getAttributeValueSafe(artifact, TSK_SUBJECT));
650 this.datetimeText.setText(getAttributeValueSafe(artifact, TSK_DATETIME));
652 msgbodyTabbedPane.setEnabledAt(HTML_TAB_INDEX,
false);
653 msgbodyTabbedPane.setEnabledAt(RTF_TAB_INDEX,
false);
654 msgbodyTabbedPane.setEnabledAt(HDR_TAB_INDEX,
false);
655 msgbodyTabbedPane.setEnabledAt(HDR_TAB_INDEX,
false);
656 configureTextArea(TSK_TEXT, TEXT_TAB_INDEX);
657 configureAttachments();
658 }
catch (TskCoreException ex) {
659 LOGGER.log(Level.WARNING,
"Failed to get attributes for message.", ex);
663 private static String
getAttributeValueSafe(BlackboardArtifact artifact, BlackboardAttribute.ATTRIBUTE_TYPE type) throws TskCoreException {
664 return Optional.ofNullable(artifact.getAttribute(
new BlackboardAttribute.Type(type)))
665 .map(BlackboardAttribute::getDisplayString)
678 Document doc = Jsoup.parse(htmlInString);
681 doc.select(
"img[src]").forEach(img -> img.attr(
"src",
""));
691 this.attachments = attachments;
702 setKeys(attachments);
720 Sheet sheet =
new Sheet();
721 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
722 if (sheetSet == null) {
723 sheetSet = Sheet.createPropertiesSet();
726 AbstractFile file = getContent();
727 sheetSet.put(
new NodeProperty<>(
"Name",
"Name",
"Name", file.getName()));
728 sheetSet.put(
new NodeProperty<>(
"Size",
"Size",
"Size", file.getSize()));
729 sheetSet.put(
new NodeProperty<>(
"Mime Type",
"Mime Type",
"Mime Type", StringUtils.defaultString(file.getMIMEType())));
730 sheetSet.put(
new NodeProperty<>(
"Known",
"Known",
"Known", file.getKnown().getName()));
732 addTagProperty(sheetSet);
javax.swing.JScrollPane textbodyScrollPane
final Set< AbstractFile > attachments
javax.swing.JPanel attachmentsPanel
static void configureTextPaneAsRtf(JTextPane pane)
final DataResultPanel drp
static String cleanseHTML(String htmlInString)
javax.swing.JScrollPane rtfbodyScrollPane
int isPreferred(Node node)
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.JScrollPane htmlScrollPane
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)
void showImagesToggleButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JTextPane rtfbodyTextPane
javax.swing.JTextPane htmlbodyTextPane
javax.swing.JScrollPane attachmentsScrollPane
static void configureTextPaneAsHtml(JTextPane pane)
javax.swing.JPanel htmlPane
final List< JTextComponent > textAreas
BlackboardArtifact artifact
javax.swing.JLabel subjectLabel
javax.swing.JButton viewInNewWindowButton
Node[] createNodes(AbstractFile t)
javax.swing.JLabel directionText
void enableCommonFields()
synchronized static Logger getLogger(String name)
void viewInNewWindowButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JTextArea textbodyTextArea
void configureAttachments()
javax.swing.JLabel subjectText
DataContentViewer createInstance()
javax.swing.JToggleButton showImagesToggleButton
final void resetComponent()
javax.swing.JTextArea headersTextArea