Autopsy  4.7.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
RelationshipNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2017-18 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;
20 
21 import java.util.TimeZone;
22 import java.util.logging.Level;
23 import org.apache.commons.lang3.StringUtils;
24 import org.openide.nodes.Sheet;
28 import org.sleuthkit.datamodel.BlackboardArtifact;
29 import org.sleuthkit.datamodel.BlackboardAttribute;
30 import org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
31 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME;
32 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_SENT;
33 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START;
34 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_FROM;
35 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_TO;
36 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
37 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
38 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT;
39 import static org.sleuthkit.datamodel.BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME;
40 import org.sleuthkit.datamodel.TimeUtilities;
41 import org.sleuthkit.datamodel.TskCoreException;
42 
46 final class RelationshipNode extends BlackboardArtifactNode {
47 
48  private static final Logger logger = Logger.getLogger(RelationshipNode.class.getName());
49 
50  RelationshipNode(BlackboardArtifact artifact) {
51  super(artifact);
52  final String stripEnd = StringUtils.stripEnd(artifact.getDisplayName(), "s");
53  String removeEndIgnoreCase = StringUtils.removeEndIgnoreCase(stripEnd, "message");
54  setDisplayName(removeEndIgnoreCase.isEmpty() ? stripEnd : removeEndIgnoreCase);
55  }
56 
57  @Override
58  protected Sheet createSheet() {
59  Sheet sheet = new Sheet();
60  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
61  if (sheetSet == null) {
62  sheetSet = Sheet.createPropertiesSet();
63  sheet.put(sheetSet);
64  }
65 
66  sheetSet.put(new NodeProperty<>("Type", "Type", "Type", getDisplayName()));
67 
68  final BlackboardArtifact artifact = getArtifact();
69  BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(getArtifact().getArtifactTypeID());
70  if (null != fromID) {
71  //Consider refactoring this to reduce boilerplate
72  switch (fromID) {
73  case TSK_EMAIL_MSG:
74  sheetSet.put(new NodeProperty<>("From", "From", "From",
75  StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_FROM), " \t\n;")));
76  sheetSet.put(new NodeProperty<>("To", "To", "To",
77  StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_TO), " \t\n;")));
78  sheetSet.put(new NodeProperty<>("Date", "Date", "Date",
79  getAttributeDisplayString(artifact, TSK_DATETIME_SENT)));
80  sheetSet.put(new NodeProperty<>("Subject", "Subject", "Subject",
81  getAttributeDisplayString(artifact, TSK_SUBJECT)));
82  try {
83  sheetSet.put(new NodeProperty<>("Attms", "Attms", "Attms", artifact.getChildrenCount()));
84  } catch (TskCoreException ex) {
85  logger.log(Level.WARNING, "Error loading attachment count for " + artifact, ex);
86  }
87 
88  break;
89  case TSK_MESSAGE:
90  sheetSet.put(new NodeProperty<>("From", "From", "From",
91  getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM)));
92  sheetSet.put(new NodeProperty<>("To", "To", "To",
93  getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO)));
94  sheetSet.put(new NodeProperty<>("Date", "Date", "Date",
95  getAttributeDisplayString(artifact, TSK_DATETIME)));
96  sheetSet.put(new NodeProperty<>("Subject", "Subject", "Subject",
97  getAttributeDisplayString(artifact, TSK_SUBJECT)));
98  try {
99  sheetSet.put(new NodeProperty<>("Attms", "Attms", "Attms", artifact.getChildrenCount()));
100  } catch (TskCoreException ex) {
101  logger.log(Level.WARNING, "Error loading attachment count for " + artifact, ex);
102  }
103  break;
104  case TSK_CALLLOG:
105  sheetSet.put(new NodeProperty<>("From", "From", "From",
106  getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM)));
107  sheetSet.put(new NodeProperty<>("To", "To", "To",
108  getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO)));
109  sheetSet.put(new NodeProperty<>("Date", "Date", "Date",
110  getAttributeDisplayString(artifact, TSK_DATETIME_START)));
111  break;
112  default:
113  break;
114  }
115  }
116 
117  addTagProperty(sheetSet);
118 
119  return sheet;
120  }
121 
133  private static String getAttributeDisplayString(final BlackboardArtifact artifact, final ATTRIBUTE_TYPE attributeType) {
134  try {
135  BlackboardAttribute attribute = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attributeType.getTypeID())));
136  if (attribute == null) {
137  return "";
138  } else if (attributeType.getValueType() == DATETIME) {
139  return TimeUtilities.epochToTime(attribute.getValueLong(),
140  TimeZone.getTimeZone(Utils.getUserPreferredZoneId()));
141  } else {
142  return attribute.getDisplayString();
143  }
144  } catch (TskCoreException tskCoreException) {
145  logger.log(Level.WARNING, "Error getting attribute value.", tskCoreException);
146  return "";
147  }
148  }
149 
156  @Override
157  public String getSourceName() {
158  return getDisplayName();
159  }
160 }

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