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