Autopsy  4.12.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.openide.nodes.Sheet;
24 import static org.sleuthkit.autopsy.communications.relationships.RelationshipsNodeUtilities.getAttributeDisplayString;
28 import org.sleuthkit.datamodel.Account;
29 import org.sleuthkit.datamodel.BlackboardArtifact;
30 import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_CALLLOG;
31 import org.sleuthkit.datamodel.BlackboardAttribute;
32 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START;
33 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END;
34 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
35 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
36 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DIRECTION;
37 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER;
38 import org.sleuthkit.datamodel.TskCoreException;
39 
43 final class CallLogNode extends BlackboardArtifactNode {
44 
45  private static final Logger logger = Logger.getLogger(CallLogNode.class.getName());
46 
47  final static String DURATION_PROP = "duration";
48 
49  CallLogNode(BlackboardArtifact artifact, String deviceID) {
50  super(artifact, Utils.getIconFilePath(Account.Type.PHONE));
51  setDisplayName(deviceID);
52  }
53 
54  @Override
55  protected Sheet createSheet() {
56  Sheet sheet = super.createSheet();
57  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
58  if (sheetSet == null) {
59  sheetSet = Sheet.createPropertiesSet();
60  sheet.put(sheetSet);
61  }
62 
63  final BlackboardArtifact artifact = getArtifact();
64 
65  BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
66  if (null != fromID && fromID != TSK_CALLLOG) {
67  return sheet;
68  }
69 
70  String phoneNumber = getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM);
71  if(phoneNumber == null || phoneNumber.isEmpty()) {
72  phoneNumber = getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO);
73  }
74 
75  long duration = -1;
76  try{
77  duration = getCallDuration(artifact);
78  } catch(TskCoreException ex) {
79  logger.log(Level.WARNING, String.format("Unable to get calllog duration for artifact: %d", artifact.getArtifactID()), ex);
80  }
81 
82  sheetSet.put(createNode(TSK_DATETIME_START, artifact));
83  sheetSet.put(createNode(TSK_DIRECTION, artifact));
84  sheetSet.put(new NodeProperty<>(TSK_PHONE_NUMBER.getLabel(), TSK_PHONE_NUMBER.getDisplayName(), "", phoneNumber));
85  if(duration != -1) {
86  sheetSet.put(new NodeProperty<>("duration", "Duration", "", Long.toString(duration)));
87  }
88 
89  return sheet;
90  }
91 
92  NodeProperty<?> createNode(BlackboardAttribute.ATTRIBUTE_TYPE type, BlackboardArtifact artifact) {
93  return new NodeProperty<>(type.getLabel(), type.getDisplayName(), type.getDisplayName(), getAttributeDisplayString(artifact, type));
94  }
95 
96  long getCallDuration(BlackboardArtifact artifact) throws TskCoreException {
97  BlackboardAttribute startAttribute = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(TSK_DATETIME_START.getTypeID())));
98  BlackboardAttribute endAttribute = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(TSK_DATETIME_END.getTypeID())));
99 
100  if(startAttribute == null || endAttribute == null) {
101  return -1;
102  }
103 
104  return endAttribute.getValueLong() - startAttribute.getValueLong();
105  }
106 
113  @Override
114  public String getSourceName() {
115  return getDisplayName();
116  }
117 }

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