Autopsy  4.10.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-2018 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.List;
22 import java.util.TimeZone;
23 import java.util.logging.Level;
24 import org.apache.commons.lang3.StringUtils;
25 import org.openide.nodes.Sheet;
31 import org.sleuthkit.datamodel.BlackboardArtifact;
32 import org.sleuthkit.datamodel.BlackboardAttribute;
33 import org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
34 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME;
35 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_SENT;
36 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START;
37 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_FROM;
38 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_TO;
39 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
40 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
41 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT;
42 import static org.sleuthkit.datamodel.BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME;
43 import org.sleuthkit.datamodel.Tag;
44 import org.sleuthkit.datamodel.TimeUtilities;
45 import org.sleuthkit.datamodel.TskCoreException;
46 
50 final class RelationshipNode extends BlackboardArtifactNode {
51 
52  private static final Logger logger = Logger.getLogger(RelationshipNode.class.getName());
53 
54  RelationshipNode(BlackboardArtifact artifact) {
55  super(artifact);
56  final String stripEnd = StringUtils.stripEnd(artifact.getDisplayName(), "s");
57  String removeEndIgnoreCase = StringUtils.removeEndIgnoreCase(stripEnd, "message");
58  setDisplayName(removeEndIgnoreCase.isEmpty() ? stripEnd : removeEndIgnoreCase);
59  }
60 
61  @Override
62  protected Sheet createSheet() {
63  Sheet sheet = new Sheet();
64  List<Tag> tags = getAllTagsFromDatabase();
65  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
66  if (sheetSet == null) {
67  sheetSet = Sheet.createPropertiesSet();
68  sheet.put(sheetSet);
69  }
70 
71  sheetSet.put(new NodeProperty<>("Type", "Type", "Type", getDisplayName()));
72 
73  addScoreProperty(sheetSet, tags);
74 
75  CorrelationAttributeInstance correlationAttribute = null;
76  if (UserPreferences.hideCentralRepoCommentsAndOccurrences()== false) {
77  correlationAttribute = getCorrelationAttributeInstance();
78  }
79  addCommentProperty(sheetSet, tags, correlationAttribute);
80 
81  if (UserPreferences.hideCentralRepoCommentsAndOccurrences()== false) {
82  addCountProperty(sheetSet, correlationAttribute);
83  }
84  final BlackboardArtifact artifact = getArtifact();
85  BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(getArtifact().getArtifactTypeID());
86  if (null != fromID) {
87  //Consider refactoring this to reduce boilerplate
88  switch (fromID) {
89  case TSK_EMAIL_MSG:
90  sheetSet.put(new NodeProperty<>("From", "From", "From",
91  StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_FROM), " \t\n;")));
92  sheetSet.put(new NodeProperty<>("To", "To", "To",
93  StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_TO), " \t\n;")));
94  sheetSet.put(new NodeProperty<>("Date", "Date", "Date",
95  getAttributeDisplayString(artifact, TSK_DATETIME_SENT)));
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 
104  break;
105  case TSK_MESSAGE:
106  sheetSet.put(new NodeProperty<>("From", "From", "From",
107  getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM)));
108  sheetSet.put(new NodeProperty<>("To", "To", "To",
109  getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO)));
110  sheetSet.put(new NodeProperty<>("Date", "Date", "Date",
111  getAttributeDisplayString(artifact, TSK_DATETIME)));
112  sheetSet.put(new NodeProperty<>("Subject", "Subject", "Subject",
113  getAttributeDisplayString(artifact, TSK_SUBJECT)));
114  try {
115  sheetSet.put(new NodeProperty<>("Attms", "Attms", "Attms", artifact.getChildrenCount()));
116  } catch (TskCoreException ex) {
117  logger.log(Level.WARNING, "Error loading attachment count for " + artifact, ex);
118  }
119  break;
120  case TSK_CALLLOG:
121  sheetSet.put(new NodeProperty<>("From", "From", "From",
122  getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM)));
123  sheetSet.put(new NodeProperty<>("To", "To", "To",
124  getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO)));
125  sheetSet.put(new NodeProperty<>("Date", "Date", "Date",
126  getAttributeDisplayString(artifact, TSK_DATETIME_START)));
127  break;
128  default:
129  break;
130  }
131  }
132 
133  return sheet;
134  }
135 
147  private static String getAttributeDisplayString(final BlackboardArtifact artifact, final ATTRIBUTE_TYPE attributeType) {
148  try {
149  BlackboardAttribute attribute = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attributeType.getTypeID())));
150  if (attribute == null) {
151  return "";
152  } else if (attributeType.getValueType() == DATETIME) {
153  return TimeUtilities.epochToTime(attribute.getValueLong(),
154  TimeZone.getTimeZone(Utils.getUserPreferredZoneId()));
155  } else {
156  return attribute.getDisplayString();
157  }
158  } catch (TskCoreException tskCoreException) {
159  logger.log(Level.WARNING, "Error getting attribute value.", tskCoreException);
160  return "";
161  }
162  }
163 
170  @Override
171  public String getSourceName() {
172  return getDisplayName();
173  }
174 }
final void addScoreProperty(Sheet.Set sheetSet, List< Tag > tags)
final void addCommentProperty(Sheet.Set sheetSet, List< Tag > tags, CorrelationAttributeInstance attribute)
final CorrelationAttributeInstance getCorrelationAttributeInstance()
final void addCountProperty(Sheet.Set sheetSet, CorrelationAttributeInstance attribute)

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