Autopsy  4.12.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
MessageNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2019 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.communications.relationships;
20 
21 import java.util.logging.Level;
22 import javax.swing.Action;
23 import org.apache.commons.lang3.StringUtils;
24 import org.openide.nodes.Sheet;
25 import org.openide.util.NbBundle.Messages;
28 import org.sleuthkit.datamodel.BlackboardArtifact;
29 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME;
30 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_SENT;
31 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_FROM;
32 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_TO;
33 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
34 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
35 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT;
36 import org.sleuthkit.datamodel.TskCoreException;
37 import static org.sleuthkit.autopsy.communications.relationships.RelationshipsNodeUtilities.getAttributeDisplayString;
39 import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG;
40 import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE;
41 
45 class MessageNode extends BlackboardArtifactNode {
46 
47  public static final String UNTHREADED_ID = "<UNTHREADED>";
48 
49  private static final Logger logger = Logger.getLogger(MessageNode.class.getName());
50 
51  private final String threadID;
52 
53  private final Action preferredAction;
54 
55  MessageNode(BlackboardArtifact artifact, String threadID, Action preferredAction) {
56  super(artifact);
57 
58  this.preferredAction = preferredAction;
59 
60  final String stripEnd = StringUtils.stripEnd(artifact.getDisplayName(), "s"); // NON-NLS
61  String removeEndIgnoreCase = StringUtils.removeEndIgnoreCase(stripEnd, "message"); // NON-NLS
62  setDisplayName(removeEndIgnoreCase.isEmpty() ? stripEnd : removeEndIgnoreCase);
63 
64  this.threadID = threadID;
65  }
66 
67  @Messages({
68  "MessageNode_Node_Property_Type=Type",
69  "MessageNode_Node_Property_From=From",
70  "MessageNode_Node_Property_To=To",
71  "MessageNode_Node_Property_Date=Date",
72  "MessageNode_Node_Property_Subject=Subject",
73  "MessageNode_Node_Property_Attms=Attachments"
74  })
75 
76  @Override
77  protected Sheet createSheet() {
78  Sheet sheet = super.createSheet();
79  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
80  if (sheetSet == null) {
81  sheetSet = Sheet.createPropertiesSet();
82  sheet.put(sheetSet);
83  }
84 
85  sheetSet.put(new NodeProperty<>("Type", Bundle.MessageNode_Node_Property_Type(), "", getDisplayName())); //NON-NLS
86 
87  final BlackboardArtifact artifact = getArtifact();
88  BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
89 
90  if(fromID == null ||
91  (fromID != TSK_EMAIL_MSG &&
92  fromID != TSK_MESSAGE)) {
93  return sheet;
94  }
95 
96  sheetSet.put(new NodeProperty<>("ThreadID", "ThreadID","",threadID == null ? UNTHREADED_ID : threadID)); //NON-NLS
97  sheetSet.put(new NodeProperty<>("Subject", Bundle.MessageNode_Node_Property_Subject(), "",
98  getAttributeDisplayString(artifact, TSK_SUBJECT))); //NON-NLS
99  try {
100  sheetSet.put(new NodeProperty<>("Attms", Bundle.MessageNode_Node_Property_Attms(), "", artifact.getChildrenCount())); //NON-NLS
101  } catch (TskCoreException ex) {
102  logger.log(Level.WARNING, "Error loading attachment count for " + artifact, ex); //NON-NLS
103  }
104 
105  switch (fromID) {
106  case TSK_EMAIL_MSG:
107  sheetSet.put(new NodeProperty<>("From", Bundle.MessageNode_Node_Property_From(), "",
108  StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_FROM), " \t\n;"))); //NON-NLS
109  sheetSet.put(new NodeProperty<>("To", Bundle.MessageNode_Node_Property_To(), "",
110  StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_TO), " \t\n;"))); //NON-NLS
111  sheetSet.put(new NodeProperty<>("Date", Bundle.MessageNode_Node_Property_Date(), "",
112  getAttributeDisplayString(artifact, TSK_DATETIME_SENT))); //NON-NLS
113  break;
114  case TSK_MESSAGE:
115  sheetSet.put(new NodeProperty<>("From", Bundle.MessageNode_Node_Property_From(), "",
116  getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM))); //NON-NLS
117  sheetSet.put(new NodeProperty<>("To", Bundle.MessageNode_Node_Property_To(), "",
118  getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO))); //NON-NLS
119  sheetSet.put(new NodeProperty<>("Date", Bundle.MessageNode_Node_Property_Date(), "",
120  getAttributeDisplayString(artifact, TSK_DATETIME))); //NON-NLS
121  break;
122  default:
123  break;
124  }
125  return sheet;
126  }
127 
134  @Override
135  public String getSourceName() {
136  return getDisplayName();
137  }
138 
139  String getThreadID() {
140  return threadID;
141  }
142 
143  @Override
144  public Action getPreferredAction() {
145  return preferredAction;
146  }
147 }

Copyright © 2012-2018 Basis Technology. Generated on: Wed Sep 18 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.