Autopsy  4.15.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
CallLogNode.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 org.apache.commons.lang.StringUtils;
23 import org.openide.nodes.Sheet;
25 import static org.sleuthkit.autopsy.communications.relationships.RelationshipsNodeUtilities.getAttributeDisplayString;
29 import org.sleuthkit.datamodel.Account;
30 import org.sleuthkit.datamodel.BlackboardArtifact;
31 import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_CALLLOG;
32 import org.sleuthkit.datamodel.BlackboardAttribute;
33 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START;
34 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END;
35 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
36 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
37 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DIRECTION;
38 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER;
39 import org.sleuthkit.datamodel.TskCoreException;
40 
44 final class CallLogNode extends BlackboardArtifactNode {
45 
46  private static final Logger logger = Logger.getLogger(CallLogNode.class.getName());
47 
48  final static String DURATION_PROP = "duration";
49 
50  CallLogNode(BlackboardArtifact artifact, String deviceID) {
51  super(artifact, Utils.getIconFilePath(Account.Type.PHONE));
52  setDisplayName(deviceID);
53  }
54 
55  @Override
56  protected Sheet createSheet() {
57  Sheet sheet = super.createSheet();
58  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
59  if (sheetSet == null) {
60  sheetSet = Sheet.createPropertiesSet();
61  sheet.put(sheetSet);
62  }
63 
64  final BlackboardArtifact artifact = getArtifact();
65 
66  BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
67  if (null != fromID && fromID != TSK_CALLLOG) {
68  return sheet;
69  }
70 
71  long duration = -1;
72  try{
73  duration = getCallDuration(artifact);
74  } catch(TskCoreException ex) {
75  logger.log(Level.WARNING, String.format("Unable to get calllog duration for artifact: %d", artifact.getArtifactID()), ex);
76  }
77 
78  sheetSet.put(createNode(TSK_DATETIME_START, artifact));
79  sheetSet.put(createNode(TSK_DIRECTION, artifact));
80  sheetSet.put(new NodeProperty<>(TSK_PHONE_NUMBER.getLabel(), TSK_PHONE_NUMBER.getDisplayName(), "", getPhoneNumber(artifact)));
81  if(duration != -1) {
82  sheetSet.put(new NodeProperty<>("duration", "Duration", "", Long.toString(duration)));
83  }
84 
85  return sheet;
86  }
87 
88  NodeProperty<?> createNode(BlackboardAttribute.ATTRIBUTE_TYPE type, BlackboardArtifact artifact) {
89  return new NodeProperty<>(type.getLabel(), type.getDisplayName(), type.getDisplayName(), getAttributeDisplayString(artifact, type));
90  }
91 
92  long getCallDuration(BlackboardArtifact artifact) throws TskCoreException {
93  BlackboardAttribute startAttribute = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(TSK_DATETIME_START.getTypeID())));
94  BlackboardAttribute endAttribute = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(TSK_DATETIME_END.getTypeID())));
95 
96  if(startAttribute == null || endAttribute == null) {
97  return -1;
98  }
99 
100  return endAttribute.getValueLong() - startAttribute.getValueLong();
101  }
102 
112  private String getPhoneNumber(BlackboardArtifact artifact) {
113  String direction = getAttributeDisplayString(artifact, TSK_DIRECTION);
114 
115  String phoneNumberToReturn;
116  String fromPhoneNumber = getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM);
117  String toPhoneNumber = getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO);
118  String phoneNumber = getAttributeDisplayString(artifact, TSK_PHONE_NUMBER);
119  switch (direction.toLowerCase()) {
120  case "incoming": // NON-NLS
121  phoneNumberToReturn = getFirstNonBlank(fromPhoneNumber, phoneNumber, toPhoneNumber);
122  break;
123  case "outgoing": // NON-NLS
124  phoneNumberToReturn = getFirstNonBlank(toPhoneNumber, phoneNumber, fromPhoneNumber);
125  break;
126  default:
127  phoneNumberToReturn = getFirstNonBlank(toPhoneNumber, fromPhoneNumber, phoneNumber );
128  break;
129  }
130 
131  return phoneNumberToReturn;
132  }
133 
145  private String getFirstNonBlank(String string1, String string2, String string3 ) {
146 
147  if (!StringUtils.isBlank(string1)) {
148  return string1;
149  } else if (!StringUtils.isBlank(string2)) {
150  return string2;
151  } else if (!StringUtils.isBlank(string3)) {
152  return string3;
153  }
154  return "";
155  }
162  @Override
163  public String getSourceName() {
164  return getDisplayName();
165  }
166 }

Copyright © 2012-2020 Basis Technology. Generated on: Mon Jul 6 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.