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 = 4)
76 private static final long serialVersionUID = 1L;
78 private static final BlackboardAttribute.Type TSK_ASSOCIATED_TYPE =
new BlackboardAttribute.Type(TSK_ASSOCIATED_ARTIFACT);
80 private static final int HDR_TAB_INDEX = 0;
81 private static final int TEXT_TAB_INDEX = 1;
82 private static final int HTML_TAB_INDEX = 2;
83 private static final int RTF_TAB_INDEX = 3;
84 private static final int ATTM_TAB_INDEX = 4;
98 @NbBundle.Messages(
"MessageContentViewer.AtrachmentsPanel.title=Attachments")
102 attachmentsScrollPane.setViewportView(drp);
103 msgbodyTabbedPane.setEnabledAt(ATTM_TAB_INDEX,
true);
105 textAreas = Arrays.asList(headersTextArea, textbodyTextArea, htmlbodyTextPane, rtfbodyTextPane);
113 drpExplorerManager.addPropertyChangeListener(evt ->
114 viewInNewWindowButton.setEnabled(drpExplorerManager.getSelectedNodes().length == 1));
122 @SuppressWarnings(
"unchecked")
124 private
void initComponents() {
126 envelopePanel =
new javax.swing.JPanel();
127 fromLabel =
new javax.swing.JLabel();
128 datetimeText =
new javax.swing.JLabel();
129 fromText =
new javax.swing.JLabel();
130 toLabel =
new javax.swing.JLabel();
131 toText =
new javax.swing.JLabel();
132 ccLabel =
new javax.swing.JLabel();
133 ccText =
new javax.swing.JLabel();
134 subjectLabel =
new javax.swing.JLabel();
135 subjectText =
new javax.swing.JLabel();
136 directionText =
new javax.swing.JLabel();
137 msgbodyTabbedPane =
new javax.swing.JTabbedPane();
138 headersScrollPane =
new javax.swing.JScrollPane();
139 headersTextArea =
new javax.swing.JTextArea();
140 textbodyScrollPane =
new javax.swing.JScrollPane();
141 textbodyTextArea =
new javax.swing.JTextArea();
142 htmlPane =
new javax.swing.JPanel();
143 htmlScrollPane =
new javax.swing.JScrollPane();
144 htmlbodyTextPane =
new javax.swing.JTextPane();
145 showImagesToggleButton =
new javax.swing.JToggleButton();
146 rtfbodyScrollPane =
new javax.swing.JScrollPane();
147 rtfbodyTextPane =
new javax.swing.JTextPane();
148 attachmentsPanel =
new javax.swing.JPanel();
149 viewInNewWindowButton =
new javax.swing.JButton();
150 attachmentsScrollPane =
new javax.swing.JScrollPane();
152 envelopePanel.setBackground(
new java.awt.Color(204, 204, 204));
154 org.openide.awt.Mnemonics.setLocalizedText(fromLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.fromLabel.text"));
156 datetimeText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
157 org.openide.awt.Mnemonics.setLocalizedText(datetimeText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.datetimeText.text"));
159 org.openide.awt.Mnemonics.setLocalizedText(fromText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.fromText.text"));
161 org.openide.awt.Mnemonics.setLocalizedText(toLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.toLabel.text"));
163 org.openide.awt.Mnemonics.setLocalizedText(toText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.toText.text"));
164 toText.setAutoscrolls(
true);
165 toText.setMinimumSize(
new java.awt.Dimension(27, 14));
167 org.openide.awt.Mnemonics.setLocalizedText(ccLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.ccLabel.text"));
169 org.openide.awt.Mnemonics.setLocalizedText(ccText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.ccText.text"));
170 ccText.setMinimumSize(
new java.awt.Dimension(27, 14));
172 org.openide.awt.Mnemonics.setLocalizedText(subjectLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.subjectLabel.text"));
174 org.openide.awt.Mnemonics.setLocalizedText(subjectText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.subjectText.text"));
175 subjectText.setMinimumSize(
new java.awt.Dimension(26, 14));
177 directionText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
178 org.openide.awt.Mnemonics.setLocalizedText(directionText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.directionText.text"));
180 javax.swing.GroupLayout envelopePanelLayout =
new javax.swing.GroupLayout(envelopePanel);
181 envelopePanel.setLayout(envelopePanelLayout);
182 envelopePanelLayout.setHorizontalGroup(
183 envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
184 .addGroup(envelopePanelLayout.createSequentialGroup()
186 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
187 .addGroup(envelopePanelLayout.createSequentialGroup()
188 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
189 .addComponent(fromLabel)
190 .addComponent(toLabel))
191 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
192 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
193 .addGroup(envelopePanelLayout.createSequentialGroup()
194 .addComponent(toText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
195 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
196 .addComponent(directionText, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
197 .addGroup(envelopePanelLayout.createSequentialGroup()
198 .addComponent(fromText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
199 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
200 .addComponent(datetimeText, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))))
201 .addGroup(envelopePanelLayout.createSequentialGroup()
202 .addComponent(ccLabel)
204 .addComponent(ccText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
205 .addGroup(envelopePanelLayout.createSequentialGroup()
206 .addComponent(subjectLabel)
207 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
208 .addComponent(subjectText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
211 envelopePanelLayout.setVerticalGroup(
212 envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
213 .addGroup(envelopePanelLayout.createSequentialGroup()
215 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
216 .addComponent(fromLabel)
217 .addComponent(datetimeText)
218 .addComponent(fromText))
219 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
220 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
221 .addComponent(toLabel)
222 .addComponent(toText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
223 .addComponent(directionText))
224 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
225 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
226 .addComponent(ccLabel)
227 .addComponent(ccText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
228 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
229 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
230 .addComponent(subjectLabel)
231 .addComponent(subjectText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
235 headersScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
236 headersScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
238 headersTextArea.setEditable(
false);
239 headersTextArea.setColumns(20);
240 headersTextArea.setLineWrap(
true);
241 headersTextArea.setRows(5);
242 headersTextArea.setWrapStyleWord(
true);
243 headersScrollPane.setViewportView(headersTextArea);
245 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.headersScrollPane.TabConstraints.tabTitle"), headersScrollPane);
247 textbodyScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
248 textbodyScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
250 textbodyTextArea.setEditable(
false);
251 textbodyTextArea.setLineWrap(
true);
252 textbodyTextArea.setRows(5);
253 textbodyTextArea.setWrapStyleWord(
true);
254 textbodyScrollPane.setViewportView(textbodyTextArea);
256 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.textbodyScrollPane.TabConstraints.tabTitle"), textbodyScrollPane);
258 htmlScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
260 htmlbodyTextPane.setEditable(
false);
261 htmlScrollPane.setViewportView(htmlbodyTextPane);
263 org.openide.awt.Mnemonics.setLocalizedText(showImagesToggleButton,
"Show Images");
264 showImagesToggleButton.addActionListener(
new java.awt.event.ActionListener() {
265 public void actionPerformed(java.awt.event.ActionEvent evt) {
266 showImagesToggleButtonActionPerformed(evt);
270 javax.swing.GroupLayout htmlPaneLayout =
new javax.swing.GroupLayout(htmlPane);
271 htmlPane.setLayout(htmlPaneLayout);
272 htmlPaneLayout.setHorizontalGroup(
273 htmlPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
274 .addComponent(htmlScrollPane)
275 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, htmlPaneLayout.createSequentialGroup()
276 .addContainerGap(533, Short.MAX_VALUE)
277 .addComponent(showImagesToggleButton)
280 htmlPaneLayout.setVerticalGroup(
281 htmlPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
282 .addGroup(htmlPaneLayout.createSequentialGroup()
283 .addComponent(showImagesToggleButton)
284 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
285 .addComponent(htmlScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE)
289 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.htmlPane.TabConstraints.tabTitle"), htmlPane);
291 rtfbodyScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
293 rtfbodyTextPane.setEditable(
false);
294 rtfbodyScrollPane.setViewportView(rtfbodyTextPane);
296 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.rtfbodyScrollPane.TabConstraints.tabTitle"), rtfbodyScrollPane);
298 org.openide.awt.Mnemonics.setLocalizedText(viewInNewWindowButton,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.viewInNewWindowButton.text"));
299 viewInNewWindowButton.addActionListener(
new java.awt.event.ActionListener() {
300 public void actionPerformed(java.awt.event.ActionEvent evt) {
301 viewInNewWindowButtonActionPerformed(evt);
305 javax.swing.GroupLayout attachmentsPanelLayout =
new javax.swing.GroupLayout(attachmentsPanel);
306 attachmentsPanel.setLayout(attachmentsPanelLayout);
307 attachmentsPanelLayout.setHorizontalGroup(
308 attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
309 .addGroup(attachmentsPanelLayout.createSequentialGroup()
311 .addGroup(attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
312 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, attachmentsPanelLayout.createSequentialGroup()
313 .addComponent(viewInNewWindowButton)
315 .addComponent(attachmentsScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 647, Short.MAX_VALUE)))
317 attachmentsPanelLayout.setVerticalGroup(
318 attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
319 .addGroup(attachmentsPanelLayout.createSequentialGroup()
321 .addComponent(viewInNewWindowButton)
322 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
323 .addComponent(attachmentsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE)
327 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.attachmentsPanel.TabConstraints.tabTitle"), attachmentsPanel);
329 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
330 this.setLayout(layout);
331 layout.setHorizontalGroup(
332 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
333 .addGroup(layout.createSequentialGroup()
335 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
336 .addComponent(msgbodyTabbedPane)
337 .addComponent(envelopePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
340 layout.setVerticalGroup(
341 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
342 .addGroup(layout.createSequentialGroup()
344 .addComponent(envelopePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
345 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
346 .addComponent(msgbodyTabbedPane)
352 "MessageContentViewer.showImagesToggleButton.hide.text=Hide Images",
353 "MessageContentViewer.showImagesToggleButton.text=Show Images"})
356 String htmlText = getAttributeValueSafe(artifact, TSK_EMAIL_CONTENT_HTML);
357 if (
false == htmlText.isEmpty()) {
358 if (showImagesToggleButton.isSelected()) {
359 showImagesToggleButton.setText(Bundle.MessageContentViewer_showImagesToggleButton_hide_text());
360 this.htmlbodyTextPane.setText(wrapInHtmlBody(htmlText));
362 showImagesToggleButton.setText(Bundle.MessageContentViewer_showImagesToggleButton_text());
363 this.htmlbodyTextPane.setText(wrapInHtmlBody(cleanseHTML(htmlText)));
366 }
catch (TskCoreException ex) {
367 LOGGER.log(Level.WARNING,
"Failed to get attributes for email message.", ex);
372 new NewWindowViewAction(
"View in new window", drpExplorerManager.getSelectedNodes()[0]).actionPerformed(evt);
411 artifact = node.getLookup().lookup(BlackboardArtifact.class);
412 if (artifact == null) {
421 if (artifact.getArtifactTypeID() == TSK_KEYWORD_HIT.getTypeID()) {
423 getAssociatedArtifact(artifact).ifPresent(associatedArtifact -> {
424 artifact = associatedArtifact;
426 }
catch (TskCoreException ex) {
427 LOGGER.log(Level.SEVERE,
"error getting associated artifact", ex);
431 if (artifact.getArtifactTypeID() == TSK_MESSAGE.getTypeID()) {
433 }
else if (artifact.getArtifactTypeID() == TSK_EMAIL_MSG.getTypeID()) {
450 private static Optional<BlackboardArtifact>
getAssociatedArtifact(
final BlackboardArtifact artifact)
throws TskCoreException {
451 BlackboardAttribute attribute = artifact.getAttribute(TSK_ASSOCIATED_TYPE);
452 if (attribute != null) {
453 return Optional.of(artifact.getSleuthkitCase().getArtifactByArtifactId(attribute.getValueLong()));
455 return Optional.empty();
459 @NbBundle.Messages(
"MessageContentViewer.title=Message")
461 return Bundle.MessageContentViewer_title();
465 @NbBundle.Messages(
"MessageContentViewer.toolTip=Displays messages.")
467 return Bundle.MessageContentViewer_toolTip();
483 fromText.setText(
"");
484 fromLabel.setEnabled(
false);
486 toLabel.setEnabled(
false);
488 ccLabel.setEnabled(
false);
489 subjectText.setText(
"");
490 subjectLabel.setEnabled(
false);
491 datetimeText.setText(
"");
492 datetimeText.setEnabled(
false);
493 directionText.setText(
"");
494 directionText.setEnabled(
false);
496 headersTextArea.setText(
"");
497 rtfbodyTextPane.setText(
"");
498 htmlbodyTextPane.setText(
"");
499 textbodyTextArea.setText(
"");
501 showImagesToggleButton.setEnabled(
false);
502 msgbodyTabbedPane.setEnabled(
false);
507 BlackboardArtifact nodeArtifact = node.getLookup().lookup(BlackboardArtifact.class);
509 if (nodeArtifact == null) {
513 if (nodeArtifact.getArtifactTypeID() == TSK_KEYWORD_HIT.getTypeID()) {
518 }
catch (TskCoreException ex) {
519 LOGGER.log(Level.SEVERE,
"error getting associated artifact", ex);
522 return isMessageArtifact(nodeArtifact);
535 final int artifactTypeID = nodeArtifact.getArtifactTypeID();
536 return artifactTypeID == TSK_EMAIL_MSG.getTypeID()
537 || artifactTypeID == TSK_MESSAGE.getTypeID();
542 if (isSupported(node)) {
557 private void configureTextArea(BlackboardAttribute.ATTRIBUTE_TYPE type,
int index)
throws TskCoreException {
558 String attributeText = getAttributeValueSafe(artifact, type);
560 if (index == HTML_TAB_INDEX && StringUtils.isNotBlank(attributeText)) {
562 attributeText = wrapInHtmlBody(cleanseHTML(attributeText));
564 JTextComponent textComponent = textAreas.get(index);
565 textComponent.setText(attributeText);
566 textComponent.setCaretPosition(0);
567 final boolean hasText = attributeText.length() > 0;
569 msgbodyTabbedPane.setEnabledAt(index, hasText);
571 msgbodyTabbedPane.setSelectedIndex(index);
576 msgbodyTabbedPane.setEnabled(
true);
577 fromLabel.setEnabled(
true);
578 toLabel.setEnabled(
true);
579 subjectLabel.setEnabled(
true);
580 datetimeText.setEnabled(
true);
585 final Set<AbstractFile> attachments = artifact.getChildren().stream()
586 .filter(AbstractFile.class::isInstance)
587 .map(AbstractFile.class::cast)
588 .collect(Collectors.toSet());
589 final int numberOfAttachments = attachments.size();
591 msgbodyTabbedPane.setEnabledAt(ATTM_TAB_INDEX, numberOfAttachments > 0);
592 msgbodyTabbedPane.setTitleAt(ATTM_TAB_INDEX,
"Attachments (" + numberOfAttachments +
")");
598 return "<html><body>" + htmlText +
"</body></html>";
602 enableCommonFields();
604 directionText.setEnabled(
false);
605 ccLabel.setEnabled(
true);
607 showImagesToggleButton.setEnabled(
true);
608 showImagesToggleButton.setText(
"Show Images");
609 showImagesToggleButton.setSelected(
false);
612 this.fromText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_FROM));
613 this.fromText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_FROM));
614 this.toText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_TO));
615 this.toText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_TO));
616 this.directionText.setText(
"");
617 this.ccText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_CC));
618 this.ccText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_CC));
619 this.subjectText.setText(getAttributeValueSafe(artifact, TSK_SUBJECT));
620 this.datetimeText.setText(getAttributeValueSafe(artifact, TSK_DATETIME_RCVD));
622 configureTextArea(TSK_HEADERS, HDR_TAB_INDEX);
623 configureTextArea(TSK_EMAIL_CONTENT_PLAIN, TEXT_TAB_INDEX);
624 configureTextArea(TSK_EMAIL_CONTENT_HTML, HTML_TAB_INDEX);
625 configureTextArea(TSK_EMAIL_CONTENT_RTF, RTF_TAB_INDEX);
626 configureAttachments();
627 }
catch (TskCoreException ex) {
628 LOGGER.log(Level.WARNING,
"Failed to get attributes for email message.", ex);
633 enableCommonFields();
635 directionText.setEnabled(
true);
636 ccLabel.setEnabled(
false);
639 this.fromText.setText(getAttributeValueSafe(artifact, TSK_PHONE_NUMBER_FROM));
640 this.toText.setText(getAttributeValueSafe(artifact, TSK_PHONE_NUMBER_TO));
641 this.directionText.setText(getAttributeValueSafe(artifact, TSK_DIRECTION));
642 this.ccText.setText(
"");
643 this.subjectText.setText(getAttributeValueSafe(artifact, TSK_SUBJECT));
644 this.datetimeText.setText(getAttributeValueSafe(artifact, TSK_DATETIME));
646 msgbodyTabbedPane.setEnabledAt(HTML_TAB_INDEX,
false);
647 msgbodyTabbedPane.setEnabledAt(RTF_TAB_INDEX,
false);
648 msgbodyTabbedPane.setEnabledAt(HDR_TAB_INDEX,
false);
649 msgbodyTabbedPane.setEnabledAt(HDR_TAB_INDEX,
false);
650 configureTextArea(TSK_TEXT, TEXT_TAB_INDEX);
651 configureAttachments();
652 }
catch (TskCoreException ex) {
653 LOGGER.log(Level.WARNING,
"Failed to get attributes for message.", ex);
657 private static String
getAttributeValueSafe(BlackboardArtifact artifact, BlackboardAttribute.ATTRIBUTE_TYPE type) throws TskCoreException {
658 return Optional.ofNullable(artifact.getAttribute(
new BlackboardAttribute.Type(type)))
659 .map(BlackboardAttribute::getDisplayString)
672 Document doc = Jsoup.parse(htmlInString);
675 doc.select(
"img[src]").forEach(img -> img.attr(
"src",
""));
685 this.attachments = attachments;
696 setKeys(attachments);
714 Sheet s =
new Sheet();
715 Sheet.Set ss = s.get(Sheet.PROPERTIES);
717 ss = Sheet.createPropertiesSet();
720 AbstractFile file = getContent();
721 ss.put(
new NodeProperty<>(
"Name",
"Name",
"Name", file.getName()));
722 ss.put(
new NodeProperty<>(
"Size",
"Size",
"Size", file.getSize()));
723 ss.put(
new NodeProperty<>(
"Mime Type",
"Mime Type",
"Mime Type", StringUtils.defaultString(file.getMIMEType())));
724 ss.put(
new NodeProperty<>(
"Known",
"Known",
"Known", file.getKnown().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
final ExplorerManager drpExplorerManager
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 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
static DataResultPanel createInstanceUninitialized(String title, String pathText, Node rootNode, int totalMatches, DataContent customContentView)
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