19 package org.sleuthkit.autopsy.contentviewers;
21 import java.awt.Color;
22 import java.awt.Component;
23 import java.util.Arrays;
24 import java.util.HashSet;
25 import java.util.List;
26 import java.util.Optional;
28 import java.util.logging.Level;
29 import java.util.stream.Collectors;
30 import javax.swing.text.JTextComponent;
31 import org.apache.commons.lang3.StringUtils;
32 import org.jsoup.Jsoup;
33 import org.jsoup.nodes.Document;
34 import org.openide.explorer.ExplorerManager;
35 import org.openide.nodes.AbstractNode;
36 import org.openide.nodes.Children;
37 import org.openide.nodes.Node;
38 import org.openide.nodes.Sheet;
39 import org.openide.util.NbBundle;
40 import org.openide.util.lookup.ServiceProvider;
55 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG;
56 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT;
57 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE;
59 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT;
60 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME;
61 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_RCVD;
62 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DIRECTION;
63 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CC;
64 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_HTML;
65 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_PLAIN;
66 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_RTF;
67 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_FROM;
68 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_TO;
69 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_HEADERS;
70 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
71 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
72 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT;
73 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEXT;
80 @ServiceProvider(service = DataContentViewer.class, position = 5)
81 @SuppressWarnings(
"PMD.SingularField")
84 private static final long serialVersionUID = 1L;
86 private static final BlackboardAttribute.Type TSK_ASSOCIATED_TYPE =
new BlackboardAttribute.Type(TSK_ASSOCIATED_ARTIFACT);
88 private static final int HDR_TAB_INDEX = 0;
89 private static final int TEXT_TAB_INDEX = 1;
90 private static final int HTML_TAB_INDEX = 2;
91 private static final int RTF_TAB_INDEX = 3;
92 private static final int ATTM_TAB_INDEX = 4;
106 @NbBundle.Messages(
"MessageContentViewer.AtrachmentsPanel.title=Attachments")
109 envelopePanel.setBackground(
new Color(0, 0, 0, 38));
111 attachmentsScrollPane.setViewportView(drp);
112 msgbodyTabbedPane.setEnabledAt(ATTM_TAB_INDEX,
true);
114 textAreas = Arrays.asList(headersTextArea, textbodyTextArea, htmlbodyTextPane, rtfbodyTextPane);
128 drpExplorerManager.addPropertyChangeListener(evt
129 -> viewInNewWindowButton.setEnabled(drpExplorerManager.getSelectedNodes().length == 1));
137 @SuppressWarnings(
"unchecked")
139 private
void initComponents() {
141 envelopePanel =
new javax.swing.JPanel();
142 fromLabel =
new javax.swing.JLabel();
143 datetimeText =
new javax.swing.JLabel();
144 fromText =
new javax.swing.JLabel();
145 toLabel =
new javax.swing.JLabel();
146 toText =
new javax.swing.JLabel();
147 ccLabel =
new javax.swing.JLabel();
148 ccText =
new javax.swing.JLabel();
149 subjectLabel =
new javax.swing.JLabel();
150 subjectText =
new javax.swing.JLabel();
151 directionText =
new javax.swing.JLabel();
152 msgbodyTabbedPane =
new javax.swing.JTabbedPane();
153 headersScrollPane =
new javax.swing.JScrollPane();
154 headersTextArea =
new javax.swing.JTextArea();
155 textbodyScrollPane =
new javax.swing.JScrollPane();
156 textbodyTextArea =
new javax.swing.JTextArea();
157 htmlPane =
new javax.swing.JPanel();
158 htmlScrollPane =
new javax.swing.JScrollPane();
159 htmlbodyTextPane =
new javax.swing.JTextPane();
160 showImagesToggleButton =
new javax.swing.JToggleButton();
161 rtfbodyScrollPane =
new javax.swing.JScrollPane();
162 rtfbodyTextPane =
new javax.swing.JTextPane();
163 attachmentsPanel =
new javax.swing.JPanel();
164 viewInNewWindowButton =
new javax.swing.JButton();
165 attachmentsScrollPane =
new javax.swing.JScrollPane();
167 envelopePanel.setBackground(
new java.awt.Color(204, 204, 204));
169 org.openide.awt.Mnemonics.setLocalizedText(fromLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.fromLabel.text"));
171 datetimeText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
172 org.openide.awt.Mnemonics.setLocalizedText(datetimeText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.datetimeText.text"));
174 org.openide.awt.Mnemonics.setLocalizedText(fromText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.fromText.text"));
176 org.openide.awt.Mnemonics.setLocalizedText(toLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.toLabel.text"));
178 org.openide.awt.Mnemonics.setLocalizedText(toText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.toText.text"));
179 toText.setAutoscrolls(
true);
180 toText.setMinimumSize(
new java.awt.Dimension(27, 14));
182 org.openide.awt.Mnemonics.setLocalizedText(ccLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.ccLabel.text"));
184 org.openide.awt.Mnemonics.setLocalizedText(ccText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.ccText.text"));
185 ccText.setMinimumSize(
new java.awt.Dimension(27, 14));
187 org.openide.awt.Mnemonics.setLocalizedText(subjectLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.subjectLabel.text"));
189 org.openide.awt.Mnemonics.setLocalizedText(subjectText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.subjectText.text"));
190 subjectText.setMinimumSize(
new java.awt.Dimension(26, 14));
192 directionText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
193 org.openide.awt.Mnemonics.setLocalizedText(directionText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.directionText.text"));
195 javax.swing.GroupLayout envelopePanelLayout =
new javax.swing.GroupLayout(envelopePanel);
196 envelopePanel.setLayout(envelopePanelLayout);
197 envelopePanelLayout.setHorizontalGroup(
198 envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
199 .addGroup(envelopePanelLayout.createSequentialGroup()
201 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
202 .addGroup(envelopePanelLayout.createSequentialGroup()
203 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
204 .addComponent(fromLabel)
205 .addComponent(toLabel))
206 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
207 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
208 .addGroup(envelopePanelLayout.createSequentialGroup()
209 .addComponent(toText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
210 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
211 .addComponent(directionText, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
212 .addGroup(envelopePanelLayout.createSequentialGroup()
213 .addComponent(fromText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
214 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
215 .addComponent(datetimeText, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))))
216 .addGroup(envelopePanelLayout.createSequentialGroup()
217 .addComponent(ccLabel)
219 .addComponent(ccText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
220 .addGroup(envelopePanelLayout.createSequentialGroup()
221 .addComponent(subjectLabel)
222 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
223 .addComponent(subjectText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
226 envelopePanelLayout.setVerticalGroup(
227 envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
228 .addGroup(envelopePanelLayout.createSequentialGroup()
230 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
231 .addComponent(fromLabel)
232 .addComponent(datetimeText)
233 .addComponent(fromText))
234 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
235 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
236 .addComponent(toLabel)
237 .addComponent(toText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
238 .addComponent(directionText))
239 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
240 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
241 .addComponent(ccLabel)
242 .addComponent(ccText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
243 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
244 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
245 .addComponent(subjectLabel)
246 .addComponent(subjectText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
250 headersScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
251 headersScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
253 headersTextArea.setEditable(
false);
254 headersTextArea.setColumns(20);
255 headersTextArea.setLineWrap(
true);
256 headersTextArea.setRows(5);
257 headersTextArea.setWrapStyleWord(
true);
258 headersScrollPane.setViewportView(headersTextArea);
260 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.headersScrollPane.TabConstraints.tabTitle"), headersScrollPane);
262 textbodyScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
263 textbodyScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
265 textbodyTextArea.setEditable(
false);
266 textbodyTextArea.setLineWrap(
true);
267 textbodyTextArea.setRows(5);
268 textbodyTextArea.setWrapStyleWord(
true);
269 textbodyScrollPane.setViewportView(textbodyTextArea);
271 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.textbodyScrollPane.TabConstraints.tabTitle"), textbodyScrollPane);
273 htmlScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
275 htmlbodyTextPane.setEditable(
false);
276 htmlScrollPane.setViewportView(htmlbodyTextPane);
278 org.openide.awt.Mnemonics.setLocalizedText(showImagesToggleButton,
"Show Images");
279 showImagesToggleButton.addActionListener(
new java.awt.event.ActionListener() {
280 public void actionPerformed(java.awt.event.ActionEvent evt) {
281 showImagesToggleButtonActionPerformed(evt);
285 javax.swing.GroupLayout htmlPaneLayout =
new javax.swing.GroupLayout(htmlPane);
286 htmlPane.setLayout(htmlPaneLayout);
287 htmlPaneLayout.setHorizontalGroup(
288 htmlPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
289 .addComponent(htmlScrollPane)
290 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, htmlPaneLayout.createSequentialGroup()
291 .addContainerGap(533, Short.MAX_VALUE)
292 .addComponent(showImagesToggleButton)
295 htmlPaneLayout.setVerticalGroup(
296 htmlPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
297 .addGroup(htmlPaneLayout.createSequentialGroup()
298 .addComponent(showImagesToggleButton)
299 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
300 .addComponent(htmlScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE)
304 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.htmlPane.TabConstraints.tabTitle"), htmlPane);
306 rtfbodyScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
308 rtfbodyTextPane.setEditable(
false);
309 rtfbodyScrollPane.setViewportView(rtfbodyTextPane);
311 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.rtfbodyScrollPane.TabConstraints.tabTitle"), rtfbodyScrollPane);
313 org.openide.awt.Mnemonics.setLocalizedText(viewInNewWindowButton,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.viewInNewWindowButton.text"));
314 viewInNewWindowButton.addActionListener(
new java.awt.event.ActionListener() {
315 public void actionPerformed(java.awt.event.ActionEvent evt) {
316 viewInNewWindowButtonActionPerformed(evt);
320 javax.swing.GroupLayout attachmentsPanelLayout =
new javax.swing.GroupLayout(attachmentsPanel);
321 attachmentsPanel.setLayout(attachmentsPanelLayout);
322 attachmentsPanelLayout.setHorizontalGroup(
323 attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
324 .addGroup(attachmentsPanelLayout.createSequentialGroup()
326 .addGroup(attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
327 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, attachmentsPanelLayout.createSequentialGroup()
328 .addComponent(viewInNewWindowButton)
330 .addComponent(attachmentsScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 647, Short.MAX_VALUE)))
332 attachmentsPanelLayout.setVerticalGroup(
333 attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
334 .addGroup(attachmentsPanelLayout.createSequentialGroup()
336 .addComponent(viewInNewWindowButton)
337 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
338 .addComponent(attachmentsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE)
342 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.attachmentsPanel.TabConstraints.tabTitle"), attachmentsPanel);
344 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
345 this.setLayout(layout);
346 layout.setHorizontalGroup(
347 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
348 .addGroup(layout.createSequentialGroup()
350 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
351 .addComponent(msgbodyTabbedPane)
352 .addComponent(envelopePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
355 layout.setVerticalGroup(
356 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
357 .addGroup(layout.createSequentialGroup()
359 .addComponent(envelopePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
360 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
361 .addComponent(msgbodyTabbedPane)
367 "MessageContentViewer.showImagesToggleButton.hide.text=Hide Images",
368 "MessageContentViewer.showImagesToggleButton.text=Show Images"})
371 String htmlText = getAttributeValueSafe(artifact, TSK_EMAIL_CONTENT_HTML);
372 if (
false == htmlText.isEmpty()) {
373 if (showImagesToggleButton.isSelected()) {
374 showImagesToggleButton.setText(Bundle.MessageContentViewer_showImagesToggleButton_hide_text());
375 this.htmlbodyTextPane.setText(wrapInHtmlBody(htmlText));
377 showImagesToggleButton.setText(Bundle.MessageContentViewer_showImagesToggleButton_text());
378 this.htmlbodyTextPane.setText(wrapInHtmlBody(cleanseHTML(htmlText)));
381 }
catch (TskCoreException ex) {
382 LOGGER.log(Level.WARNING,
"Failed to get attributes for email message.", ex);
387 new NewWindowViewAction(
"View in new window", drpExplorerManager.getSelectedNodes()[0]).actionPerformed(evt);
426 artifact = node.getLookup().lookup(BlackboardArtifact.class);
427 if (artifact == null) {
436 if (artifact.getArtifactTypeID() == TSK_KEYWORD_HIT.getTypeID()) {
438 getAssociatedArtifact(artifact).ifPresent(associatedArtifact -> {
439 artifact = associatedArtifact;
441 }
catch (TskCoreException ex) {
442 LOGGER.log(Level.SEVERE,
"error getting associated artifact", ex);
446 if (artifact.getArtifactTypeID() == TSK_MESSAGE.getTypeID()) {
448 }
else if (artifact.getArtifactTypeID() == TSK_EMAIL_MSG.getTypeID()) {
465 private static Optional<BlackboardArtifact>
getAssociatedArtifact(
final BlackboardArtifact artifact)
throws TskCoreException {
466 BlackboardAttribute attribute = artifact.getAttribute(TSK_ASSOCIATED_TYPE);
467 if (attribute != null) {
468 return Optional.of(artifact.getSleuthkitCase().getArtifactByArtifactId(attribute.getValueLong()));
470 return Optional.empty();
474 @NbBundle.Messages(
"MessageContentViewer.title=Message")
476 return Bundle.MessageContentViewer_title();
480 @NbBundle.Messages(
"MessageContentViewer.toolTip=Displays messages.")
482 return Bundle.MessageContentViewer_toolTip();
498 fromText.setText(
"");
499 fromLabel.setEnabled(
false);
501 toLabel.setEnabled(
false);
503 ccLabel.setEnabled(
false);
504 subjectText.setText(
"");
505 subjectLabel.setEnabled(
false);
506 datetimeText.setText(
"");
507 datetimeText.setEnabled(
false);
508 directionText.setText(
"");
509 directionText.setEnabled(
false);
511 headersTextArea.setText(
"");
512 rtfbodyTextPane.setText(
"");
513 htmlbodyTextPane.setText(
"");
514 textbodyTextArea.setText(
"");
515 showImagesToggleButton.setEnabled(
false);
516 msgbodyTabbedPane.setEnabled(
false);
521 BlackboardArtifact nodeArtifact = node.getLookup().lookup(BlackboardArtifact.class);
523 if (nodeArtifact == null) {
527 if (nodeArtifact.getArtifactTypeID() == TSK_KEYWORD_HIT.getTypeID()) {
532 }
catch (TskCoreException ex) {
533 LOGGER.log(Level.SEVERE,
"error getting associated artifact", ex);
536 return isMessageArtifact(nodeArtifact);
549 final int artifactTypeID = nodeArtifact.getArtifactTypeID();
550 return artifactTypeID == TSK_EMAIL_MSG.getTypeID()
551 || artifactTypeID == TSK_MESSAGE.getTypeID();
556 if (isSupported(node)) {
571 private void configureTextArea(BlackboardAttribute.ATTRIBUTE_TYPE type,
int index)
throws TskCoreException {
572 String attributeText = getAttributeValueSafe(artifact, type);
574 if (index == HTML_TAB_INDEX && StringUtils.isNotBlank(attributeText)) {
576 attributeText = wrapInHtmlBody(cleanseHTML(attributeText));
578 JTextComponent textComponent = textAreas.get(index);
579 textComponent.setText(attributeText);
580 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<AbstractFile> attachments = artifact.getChildren().stream()
600 .filter(AbstractFile.class::isInstance)
601 .map(AbstractFile.class::cast)
602 .collect(Collectors.toSet());
603 final int numberOfAttachments = attachments.size();
605 msgbodyTabbedPane.setEnabledAt(ATTM_TAB_INDEX, numberOfAttachments > 0);
606 msgbodyTabbedPane.setTitleAt(ATTM_TAB_INDEX,
"Attachments (" + numberOfAttachments +
")");
612 return "<html><body>" + htmlText +
"</body></html>";
616 enableCommonFields();
618 directionText.setEnabled(
false);
619 ccLabel.setEnabled(
true);
621 showImagesToggleButton.setEnabled(
true);
622 showImagesToggleButton.setText(
"Show Images");
623 showImagesToggleButton.setSelected(
false);
626 this.fromText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_FROM));
627 this.fromText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_FROM));
628 this.toText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_TO));
629 this.toText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_TO));
630 this.directionText.setText(
"");
631 this.ccText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_CC));
632 this.ccText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_CC));
633 this.subjectText.setText(getAttributeValueSafe(artifact, TSK_SUBJECT));
634 this.datetimeText.setText(getAttributeValueSafe(artifact, TSK_DATETIME_RCVD));
636 configureTextArea(TSK_HEADERS, HDR_TAB_INDEX);
637 configureTextArea(TSK_EMAIL_CONTENT_PLAIN, TEXT_TAB_INDEX);
638 configureTextArea(TSK_EMAIL_CONTENT_HTML, HTML_TAB_INDEX);
639 configureTextArea(TSK_EMAIL_CONTENT_RTF, RTF_TAB_INDEX);
640 configureAttachments();
641 }
catch (TskCoreException ex) {
642 LOGGER.log(Level.WARNING,
"Failed to get attributes for email message.", ex);
647 enableCommonFields();
649 directionText.setEnabled(
true);
650 ccLabel.setEnabled(
false);
653 this.fromText.setText(getAttributeValueSafe(artifact, TSK_PHONE_NUMBER_FROM));
654 this.toText.setText(getAttributeValueSafe(artifact, TSK_PHONE_NUMBER_TO));
655 this.directionText.setText(getAttributeValueSafe(artifact, TSK_DIRECTION));
656 this.ccText.setText(
"");
657 this.subjectText.setText(getAttributeValueSafe(artifact, TSK_SUBJECT));
658 this.datetimeText.setText(getAttributeValueSafe(artifact, TSK_DATETIME));
660 msgbodyTabbedPane.setEnabledAt(HTML_TAB_INDEX,
false);
661 msgbodyTabbedPane.setEnabledAt(RTF_TAB_INDEX,
false);
662 msgbodyTabbedPane.setEnabledAt(HDR_TAB_INDEX,
false);
663 msgbodyTabbedPane.setEnabledAt(HDR_TAB_INDEX,
false);
664 configureTextArea(TSK_TEXT, TEXT_TAB_INDEX);
665 configureAttachments();
666 }
catch (TskCoreException ex) {
667 LOGGER.log(Level.WARNING,
"Failed to get attributes for message.", ex);
671 private static String
getAttributeValueSafe(BlackboardArtifact artifact, BlackboardAttribute.ATTRIBUTE_TYPE type) throws TskCoreException {
672 return Optional.ofNullable(artifact.getAttribute(
new BlackboardAttribute.Type(type)))
673 .map(BlackboardAttribute::getDisplayString)
686 Document doc = Jsoup.parse(htmlInString);
689 doc.select(
"img[src]").forEach(img -> img.attr(
"src",
""));
699 this.attachments = attachments;
710 setKeys(attachments);
728 Sheet sheet = super.createSheet();
729 Set<String> keepProps =
new HashSet<>(Arrays.asList(
739 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
740 for(Property<?> p : sheetSet.getProperties()) {
741 if(!keepProps.contains(p.getName())){
742 sheetSet.remove(p.getName());
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