Autopsy  4.5.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 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 
47 
48  private static final Logger logger = Logger.getLogger(RelationShipNode.class.getName());
49 
50  public 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 s = new Sheet();
60  Sheet.Set ss = s.get(Sheet.PROPERTIES);
61  if (ss == null) {
62  ss = Sheet.createPropertiesSet();
63  s.put(ss);
64  }
65 
66  ss.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  ss.put(new NodeProperty<>("From", "From", "From",
75  StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_FROM), " \t\n;")));
76  ss.put(new NodeProperty<>("To", "To", "To",
77  StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_TO), " \t\n;")));
78  ss.put(new NodeProperty<>("Date", "Date", "Date",
79  getAttributeDisplayString(artifact, TSK_DATETIME_SENT)));
80  ss.put(new NodeProperty<>("Subject", "Subject", "Subject",
81  getAttributeDisplayString(artifact, TSK_SUBJECT)));
82  try {
83  ss.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  ss.put(new NodeProperty<>("From", "From", "From",
91  getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM)));
92  ss.put(new NodeProperty<>("To", "To", "To",
93  getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO)));
94  ss.put(new NodeProperty<>("Date", "Date", "Date",
95  getAttributeDisplayString(artifact, TSK_DATETIME)));
96  ss.put(new NodeProperty<>("Subject", "Subject", "Subject",
97  getAttributeDisplayString(artifact, TSK_SUBJECT)));
98  try {
99  ss.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  ss.put(new NodeProperty<>("From", "From", "From",
106  getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM)));
107  ss.put(new NodeProperty<>("To", "To", "To",
108  getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO)));
109  ss.put(new NodeProperty<>("Date", "Date", "Date",
110  getAttributeDisplayString(artifact, TSK_DATETIME_START)));
111  break;
112  default:
113  break;
114  }
115  }
116  return s;
117  }
118 
130  private static String getAttributeDisplayString(final BlackboardArtifact artifact, final ATTRIBUTE_TYPE attributeType) {
131  try {
132  BlackboardAttribute attribute = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attributeType.getTypeID())));
133  if (attribute == null) {
134  return "";
135  } else if (attributeType.getValueType() == DATETIME) {
136  return TimeUtilities.epochToTime(attribute.getValueLong(),
137  TimeZone.getTimeZone(Utils.getUserPreferredZoneId()));
138  } else {
139  return attribute.getDisplayString();
140  }
141  } catch (TskCoreException tskCoreException) {
142  logger.log(Level.WARNING, "Error getting attribute value.", tskCoreException);
143  return "";
144  }
145  }
146 
147 }
static String getAttributeDisplayString(final BlackboardArtifact artifact, final ATTRIBUTE_TYPE attributeType)
synchronized static Logger getLogger(String name)
Definition: Logger.java:161

Copyright © 2012-2016 Basis Technology. Generated on: Fri Dec 15 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.