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;
52 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG;
53 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT;
54 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE;
56 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT;
57 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME;
58 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_RCVD;
59 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DIRECTION;
60 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CC;
61 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_HTML;
62 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_PLAIN;
63 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_RTF;
64 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_FROM;
65 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_TO;
66 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_HEADERS;
67 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
68 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
69 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT;
70 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEXT;
77 @ServiceProvider(service = DataContentViewer.class, position = 5)
78 @SuppressWarnings(
"PMD.SingularField")
81 private static final long serialVersionUID = 1L;
83 private static final BlackboardAttribute.Type TSK_ASSOCIATED_TYPE =
new BlackboardAttribute.Type(TSK_ASSOCIATED_ARTIFACT);
85 private static final int HDR_TAB_INDEX = 0;
86 private static final int TEXT_TAB_INDEX = 1;
87 private static final int HTML_TAB_INDEX = 2;
88 private static final int RTF_TAB_INDEX = 3;
89 private static final int ATTM_TAB_INDEX = 4;
103 @NbBundle.Messages(
"MessageContentViewer.AtrachmentsPanel.title=Attachments")
107 attachmentsScrollPane.setViewportView(drp);
108 msgbodyTabbedPane.setEnabledAt(ATTM_TAB_INDEX,
true);
110 textAreas = Arrays.asList(headersTextArea, textbodyTextArea, htmlbodyTextPane, rtfbodyTextPane);
124 drpExplorerManager.addPropertyChangeListener(evt
125 -> viewInNewWindowButton.setEnabled(drpExplorerManager.getSelectedNodes().length == 1));
133 @SuppressWarnings(
"unchecked")
135 private
void initComponents() {
137 envelopePanel =
new javax.swing.JPanel();
138 fromLabel =
new javax.swing.JLabel();
139 datetimeText =
new javax.swing.JLabel();
140 fromText =
new javax.swing.JLabel();
141 toLabel =
new javax.swing.JLabel();
142 toText =
new javax.swing.JLabel();
143 ccLabel =
new javax.swing.JLabel();
144 ccText =
new javax.swing.JLabel();
145 subjectLabel =
new javax.swing.JLabel();
146 subjectText =
new javax.swing.JLabel();
147 directionText =
new javax.swing.JLabel();
148 msgbodyTabbedPane =
new javax.swing.JTabbedPane();
149 headersScrollPane =
new javax.swing.JScrollPane();
150 headersTextArea =
new javax.swing.JTextArea();
151 textbodyScrollPane =
new javax.swing.JScrollPane();
152 textbodyTextArea =
new javax.swing.JTextArea();
153 htmlPane =
new javax.swing.JPanel();
154 htmlScrollPane =
new javax.swing.JScrollPane();
155 htmlbodyTextPane =
new javax.swing.JTextPane();
156 showImagesToggleButton =
new javax.swing.JToggleButton();
157 rtfbodyScrollPane =
new javax.swing.JScrollPane();
158 rtfbodyTextPane =
new javax.swing.JTextPane();
159 attachmentsPanel =
new javax.swing.JPanel();
160 viewInNewWindowButton =
new javax.swing.JButton();
161 attachmentsScrollPane =
new javax.swing.JScrollPane();
163 envelopePanel.setBackground(
new java.awt.Color(204, 204, 204));
165 org.openide.awt.Mnemonics.setLocalizedText(fromLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.fromLabel.text"));
167 datetimeText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
168 org.openide.awt.Mnemonics.setLocalizedText(datetimeText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.datetimeText.text"));
170 org.openide.awt.Mnemonics.setLocalizedText(fromText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.fromText.text"));
172 org.openide.awt.Mnemonics.setLocalizedText(toLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.toLabel.text"));
174 org.openide.awt.Mnemonics.setLocalizedText(toText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.toText.text"));
175 toText.setAutoscrolls(
true);
176 toText.setMinimumSize(
new java.awt.Dimension(27, 14));
178 org.openide.awt.Mnemonics.setLocalizedText(ccLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.ccLabel.text"));
180 org.openide.awt.Mnemonics.setLocalizedText(ccText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.ccText.text"));
181 ccText.setMinimumSize(
new java.awt.Dimension(27, 14));
183 org.openide.awt.Mnemonics.setLocalizedText(subjectLabel,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.subjectLabel.text"));
185 org.openide.awt.Mnemonics.setLocalizedText(subjectText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.subjectText.text"));
186 subjectText.setMinimumSize(
new java.awt.Dimension(26, 14));
188 directionText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
189 org.openide.awt.Mnemonics.setLocalizedText(directionText,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.directionText.text"));
191 javax.swing.GroupLayout envelopePanelLayout =
new javax.swing.GroupLayout(envelopePanel);
192 envelopePanel.setLayout(envelopePanelLayout);
193 envelopePanelLayout.setHorizontalGroup(
194 envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
195 .addGroup(envelopePanelLayout.createSequentialGroup()
197 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
198 .addGroup(envelopePanelLayout.createSequentialGroup()
199 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
200 .addComponent(fromLabel)
201 .addComponent(toLabel))
202 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
203 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
204 .addGroup(envelopePanelLayout.createSequentialGroup()
205 .addComponent(toText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
206 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
207 .addComponent(directionText, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
208 .addGroup(envelopePanelLayout.createSequentialGroup()
209 .addComponent(fromText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
210 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
211 .addComponent(datetimeText, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))))
212 .addGroup(envelopePanelLayout.createSequentialGroup()
213 .addComponent(ccLabel)
215 .addComponent(ccText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
216 .addGroup(envelopePanelLayout.createSequentialGroup()
217 .addComponent(subjectLabel)
218 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
219 .addComponent(subjectText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
222 envelopePanelLayout.setVerticalGroup(
223 envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
224 .addGroup(envelopePanelLayout.createSequentialGroup()
226 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
227 .addComponent(fromLabel)
228 .addComponent(datetimeText)
229 .addComponent(fromText))
230 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
231 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
232 .addComponent(toLabel)
233 .addComponent(toText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
234 .addComponent(directionText))
235 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
236 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
237 .addComponent(ccLabel)
238 .addComponent(ccText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
239 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
240 .addGroup(envelopePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
241 .addComponent(subjectLabel)
242 .addComponent(subjectText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
246 headersScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
247 headersScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
249 headersTextArea.setEditable(
false);
250 headersTextArea.setColumns(20);
251 headersTextArea.setLineWrap(
true);
252 headersTextArea.setRows(5);
253 headersTextArea.setWrapStyleWord(
true);
254 headersScrollPane.setViewportView(headersTextArea);
256 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.headersScrollPane.TabConstraints.tabTitle"), headersScrollPane);
258 textbodyScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
259 textbodyScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
261 textbodyTextArea.setEditable(
false);
262 textbodyTextArea.setLineWrap(
true);
263 textbodyTextArea.setRows(5);
264 textbodyTextArea.setWrapStyleWord(
true);
265 textbodyScrollPane.setViewportView(textbodyTextArea);
267 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.textbodyScrollPane.TabConstraints.tabTitle"), textbodyScrollPane);
269 htmlScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
271 htmlbodyTextPane.setEditable(
false);
272 htmlScrollPane.setViewportView(htmlbodyTextPane);
274 org.openide.awt.Mnemonics.setLocalizedText(showImagesToggleButton,
"Show Images");
275 showImagesToggleButton.addActionListener(
new java.awt.event.ActionListener() {
276 public void actionPerformed(java.awt.event.ActionEvent evt) {
277 showImagesToggleButtonActionPerformed(evt);
281 javax.swing.GroupLayout htmlPaneLayout =
new javax.swing.GroupLayout(htmlPane);
282 htmlPane.setLayout(htmlPaneLayout);
283 htmlPaneLayout.setHorizontalGroup(
284 htmlPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
285 .addComponent(htmlScrollPane)
286 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, htmlPaneLayout.createSequentialGroup()
287 .addContainerGap(533, Short.MAX_VALUE)
288 .addComponent(showImagesToggleButton)
291 htmlPaneLayout.setVerticalGroup(
292 htmlPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
293 .addGroup(htmlPaneLayout.createSequentialGroup()
294 .addComponent(showImagesToggleButton)
295 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
296 .addComponent(htmlScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE)
300 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.htmlPane.TabConstraints.tabTitle"), htmlPane);
302 rtfbodyScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
304 rtfbodyTextPane.setEditable(
false);
305 rtfbodyScrollPane.setViewportView(rtfbodyTextPane);
307 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.rtfbodyScrollPane.TabConstraints.tabTitle"), rtfbodyScrollPane);
309 org.openide.awt.Mnemonics.setLocalizedText(viewInNewWindowButton,
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.viewInNewWindowButton.text"));
310 viewInNewWindowButton.addActionListener(
new java.awt.event.ActionListener() {
311 public void actionPerformed(java.awt.event.ActionEvent evt) {
312 viewInNewWindowButtonActionPerformed(evt);
316 javax.swing.GroupLayout attachmentsPanelLayout =
new javax.swing.GroupLayout(attachmentsPanel);
317 attachmentsPanel.setLayout(attachmentsPanelLayout);
318 attachmentsPanelLayout.setHorizontalGroup(
319 attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
320 .addGroup(attachmentsPanelLayout.createSequentialGroup()
322 .addGroup(attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
323 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, attachmentsPanelLayout.createSequentialGroup()
324 .addComponent(viewInNewWindowButton)
326 .addComponent(attachmentsScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 647, Short.MAX_VALUE)))
328 attachmentsPanelLayout.setVerticalGroup(
329 attachmentsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
330 .addGroup(attachmentsPanelLayout.createSequentialGroup()
332 .addComponent(viewInNewWindowButton)
333 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
334 .addComponent(attachmentsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE)
338 msgbodyTabbedPane.addTab(
org.openide.util.NbBundle.getMessage(
MessageContentViewer.class,
"MessageContentViewer.attachmentsPanel.TabConstraints.tabTitle"), attachmentsPanel);
340 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
341 this.setLayout(layout);
342 layout.setHorizontalGroup(
343 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
344 .addGroup(layout.createSequentialGroup()
346 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
347 .addComponent(msgbodyTabbedPane)
348 .addComponent(envelopePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
351 layout.setVerticalGroup(
352 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
353 .addGroup(layout.createSequentialGroup()
355 .addComponent(envelopePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
356 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
357 .addComponent(msgbodyTabbedPane)
363 "MessageContentViewer.showImagesToggleButton.hide.text=Hide Images",
364 "MessageContentViewer.showImagesToggleButton.text=Show Images"})
367 String htmlText = getAttributeValueSafe(artifact, TSK_EMAIL_CONTENT_HTML);
368 if (
false == htmlText.isEmpty()) {
369 if (showImagesToggleButton.isSelected()) {
370 showImagesToggleButton.setText(Bundle.MessageContentViewer_showImagesToggleButton_hide_text());
371 this.htmlbodyTextPane.setText(wrapInHtmlBody(htmlText));
373 showImagesToggleButton.setText(Bundle.MessageContentViewer_showImagesToggleButton_text());
374 this.htmlbodyTextPane.setText(wrapInHtmlBody(cleanseHTML(htmlText)));
377 }
catch (TskCoreException ex) {
378 LOGGER.log(Level.WARNING,
"Failed to get attributes for email message.", ex);
383 new NewWindowViewAction(
"View in new window", drpExplorerManager.getSelectedNodes()[0]).actionPerformed(evt);
422 artifact = node.getLookup().lookup(BlackboardArtifact.class);
423 if (artifact == null) {
432 if (artifact.getArtifactTypeID() == TSK_KEYWORD_HIT.getTypeID()) {
434 getAssociatedArtifact(artifact).ifPresent(associatedArtifact -> {
435 artifact = associatedArtifact;
437 }
catch (TskCoreException ex) {
438 LOGGER.log(Level.SEVERE,
"error getting associated artifact", ex);
442 if (artifact.getArtifactTypeID() == TSK_MESSAGE.getTypeID()) {
444 }
else if (artifact.getArtifactTypeID() == TSK_EMAIL_MSG.getTypeID()) {
461 private static Optional<BlackboardArtifact>
getAssociatedArtifact(
final BlackboardArtifact artifact)
throws TskCoreException {
462 BlackboardAttribute attribute = artifact.getAttribute(TSK_ASSOCIATED_TYPE);
463 if (attribute != null) {
464 return Optional.of(artifact.getSleuthkitCase().getArtifactByArtifactId(attribute.getValueLong()));
466 return Optional.empty();
470 @NbBundle.Messages(
"MessageContentViewer.title=Message")
472 return Bundle.MessageContentViewer_title();
476 @NbBundle.Messages(
"MessageContentViewer.toolTip=Displays messages.")
478 return Bundle.MessageContentViewer_toolTip();
494 fromText.setText(
"");
495 fromLabel.setEnabled(
false);
497 toLabel.setEnabled(
false);
499 ccLabel.setEnabled(
false);
500 subjectText.setText(
"");
501 subjectLabel.setEnabled(
false);
502 datetimeText.setText(
"");
503 datetimeText.setEnabled(
false);
504 directionText.setText(
"");
505 directionText.setEnabled(
false);
507 headersTextArea.setText(
"");
508 rtfbodyTextPane.setText(
"");
509 htmlbodyTextPane.setText(
"");
510 textbodyTextArea.setText(
"");
511 showImagesToggleButton.setEnabled(
false);
512 msgbodyTabbedPane.setEnabled(
false);
517 BlackboardArtifact nodeArtifact = node.getLookup().lookup(BlackboardArtifact.class);
519 if (nodeArtifact == null) {
523 if (nodeArtifact.getArtifactTypeID() == TSK_KEYWORD_HIT.getTypeID()) {
528 }
catch (TskCoreException ex) {
529 LOGGER.log(Level.SEVERE,
"error getting associated artifact", ex);
532 return isMessageArtifact(nodeArtifact);
545 final int artifactTypeID = nodeArtifact.getArtifactTypeID();
546 return artifactTypeID == TSK_EMAIL_MSG.getTypeID()
547 || artifactTypeID == TSK_MESSAGE.getTypeID();
552 if (isSupported(node)) {
567 private void configureTextArea(BlackboardAttribute.ATTRIBUTE_TYPE type,
int index)
throws TskCoreException {
568 String attributeText = getAttributeValueSafe(artifact, type);
570 if (index == HTML_TAB_INDEX && StringUtils.isNotBlank(attributeText)) {
572 attributeText = wrapInHtmlBody(cleanseHTML(attributeText));
574 JTextComponent textComponent = textAreas.get(index);
575 textComponent.setText(attributeText);
576 textComponent.setCaretPosition(0);
577 final boolean hasText = attributeText.length() > 0;
579 msgbodyTabbedPane.setEnabledAt(index, hasText);
581 msgbodyTabbedPane.setSelectedIndex(index);
586 msgbodyTabbedPane.setEnabled(
true);
587 fromLabel.setEnabled(
true);
588 toLabel.setEnabled(
true);
589 subjectLabel.setEnabled(
true);
590 datetimeText.setEnabled(
true);
595 final Set<AbstractFile> attachments = artifact.getChildren().stream()
596 .filter(AbstractFile.class::isInstance)
597 .map(AbstractFile.class::cast)
598 .collect(Collectors.toSet());
599 final int numberOfAttachments = attachments.size();
601 msgbodyTabbedPane.setEnabledAt(ATTM_TAB_INDEX, numberOfAttachments > 0);
602 msgbodyTabbedPane.setTitleAt(ATTM_TAB_INDEX,
"Attachments (" + numberOfAttachments +
")");
608 return "<html><body>" + htmlText +
"</body></html>";
612 enableCommonFields();
614 directionText.setEnabled(
false);
615 ccLabel.setEnabled(
true);
617 showImagesToggleButton.setEnabled(
true);
618 showImagesToggleButton.setText(
"Show Images");
619 showImagesToggleButton.setSelected(
false);
622 this.fromText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_FROM));
623 this.fromText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_FROM));
624 this.toText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_TO));
625 this.toText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_TO));
626 this.directionText.setText(
"");
627 this.ccText.setText(getAttributeValueSafe(artifact, TSK_EMAIL_CC));
628 this.ccText.setToolTipText(getAttributeValueSafe(artifact, TSK_EMAIL_CC));
629 this.subjectText.setText(getAttributeValueSafe(artifact, TSK_SUBJECT));
630 this.datetimeText.setText(getAttributeValueSafe(artifact, TSK_DATETIME_RCVD));
632 configureTextArea(TSK_HEADERS, HDR_TAB_INDEX);
633 configureTextArea(TSK_EMAIL_CONTENT_PLAIN, TEXT_TAB_INDEX);
634 configureTextArea(TSK_EMAIL_CONTENT_HTML, HTML_TAB_INDEX);
635 configureTextArea(TSK_EMAIL_CONTENT_RTF, RTF_TAB_INDEX);
636 configureAttachments();
637 }
catch (TskCoreException ex) {
638 LOGGER.log(Level.WARNING,
"Failed to get attributes for email message.", ex);
643 enableCommonFields();
645 directionText.setEnabled(
true);
646 ccLabel.setEnabled(
false);
649 this.fromText.setText(getAttributeValueSafe(artifact, TSK_PHONE_NUMBER_FROM));
650 this.toText.setText(getAttributeValueSafe(artifact, TSK_PHONE_NUMBER_TO));
651 this.directionText.setText(getAttributeValueSafe(artifact, TSK_DIRECTION));
652 this.ccText.setText(
"");
653 this.subjectText.setText(getAttributeValueSafe(artifact, TSK_SUBJECT));
654 this.datetimeText.setText(getAttributeValueSafe(artifact, TSK_DATETIME));
656 msgbodyTabbedPane.setEnabledAt(HTML_TAB_INDEX,
false);
657 msgbodyTabbedPane.setEnabledAt(RTF_TAB_INDEX,
false);
658 msgbodyTabbedPane.setEnabledAt(HDR_TAB_INDEX,
false);
659 msgbodyTabbedPane.setEnabledAt(HDR_TAB_INDEX,
false);
660 configureTextArea(TSK_TEXT, TEXT_TAB_INDEX);
661 configureAttachments();
662 }
catch (TskCoreException ex) {
663 LOGGER.log(Level.WARNING,
"Failed to get attributes for message.", ex);
667 private static String
getAttributeValueSafe(BlackboardArtifact artifact, BlackboardAttribute.ATTRIBUTE_TYPE type) throws TskCoreException {
668 return Optional.ofNullable(artifact.getAttribute(
new BlackboardAttribute.Type(type)))
669 .map(BlackboardAttribute::getDisplayString)
682 Document doc = Jsoup.parse(htmlInString);
685 doc.select(
"img[src]").forEach(img -> img.attr(
"src",
""));
695 this.attachments = attachments;
706 setKeys(attachments);
724 Sheet sheet =
new Sheet();
725 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
726 if (sheetSet == null) {
727 sheetSet = Sheet.createPropertiesSet();
730 List<ContentTag> tags = getContentTagsFromDatabase();
732 AbstractFile file = getContent();
733 sheetSet.put(
new NodeProperty<>(
"Name",
"Name",
"Name", file.getName()));
735 addScoreProperty(sheetSet, tags);
739 correlationAttribute = getCorrelationAttributeInstance();
741 addCommentProperty(sheetSet, tags, correlationAttribute);
744 addCountProperty(sheetSet, correlationAttribute);
746 sheetSet.put(
new NodeProperty<>(
"Size",
"Size",
"Size", file.getSize()));
747 sheetSet.put(
new NodeProperty<>(
"Mime Type",
"Mime Type",
"Mime Type", StringUtils.defaultString(file.getMIMEType())));
748 sheetSet.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)
static boolean useCentralRepo()
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
static boolean hideCentralRepoCommentsAndOccurrences()
void configureAttachments()
javax.swing.JLabel subjectText
DataContentViewer createInstance()
javax.swing.JToggleButton showImagesToggleButton
final void resetComponent()
javax.swing.JTextArea headersTextArea