Autopsy 4.22.1
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 */
19package org.sleuthkit.autopsy.communications.relationships;
20
21import java.util.logging.Level;
22import org.apache.commons.lang.StringUtils;
23import org.openide.nodes.Sheet;
24import org.sleuthkit.autopsy.communications.Utils;
25import static org.sleuthkit.autopsy.communications.relationships.RelationshipsNodeUtilities.getAttributeDisplayString;
26import org.sleuthkit.autopsy.coreutils.Logger;
27import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode;
28import org.sleuthkit.autopsy.datamodel.NodeProperty;
29import org.sleuthkit.datamodel.Account;
30import org.sleuthkit.datamodel.BlackboardArtifact;
31import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_CALLLOG;
32import org.sleuthkit.datamodel.BlackboardAttribute;
33import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START;
34import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END;
35import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
36import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
37import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DIRECTION;
38import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER;
39import org.sleuthkit.datamodel.TskCoreException;
40
44final 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
81 String phoneNumber = getPhoneNumber(artifact);
82 Account account = null;
83 try {
84 account = artifact.getSleuthkitCase().getCommunicationsManager().getAccount(Account.Type.PHONE, phoneNumber);
85 } catch (TskCoreException ex) {
86 logger.log(Level.SEVERE, "Failed to get instance of communications manager", ex);
87 }
88
89 sheetSet.put(new AccountNodeProperty<>(TSK_PHONE_NUMBER.getLabel(), TSK_PHONE_NUMBER.getDisplayName(), phoneNumber, account));
90 if(duration != -1) {
91 sheetSet.put(new NodeProperty<>("duration", "Duration", "", Long.toString(duration)));
92 }
93
94 return sheet;
95 }
96
97 NodeProperty<?> createNode(BlackboardAttribute.ATTRIBUTE_TYPE type, BlackboardArtifact artifact) {
98 return new NodeProperty<>(type.getLabel(), type.getDisplayName(), type.getDisplayName(), getAttributeDisplayString(artifact, type));
99 }
100
101 long getCallDuration(BlackboardArtifact artifact) throws TskCoreException {
102 BlackboardAttribute startAttribute = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(TSK_DATETIME_START.getTypeID())));
103 BlackboardAttribute endAttribute = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(TSK_DATETIME_END.getTypeID())));
104
105 if(startAttribute == null || endAttribute == null) {
106 return -1;
107 }
108
109 return endAttribute.getValueLong() - startAttribute.getValueLong();
110 }
111
121 private String getPhoneNumber(BlackboardArtifact artifact) {
122 String direction = getAttributeDisplayString(artifact, TSK_DIRECTION);
123
124 String phoneNumberToReturn;
125 String fromPhoneNumber = getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM);
126 String toPhoneNumber = getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO);
127 String phoneNumber = getAttributeDisplayString(artifact, TSK_PHONE_NUMBER);
128 switch (direction.toLowerCase()) {
129 case "incoming": // NON-NLS
130 phoneNumberToReturn = getFirstNonBlank(fromPhoneNumber, phoneNumber, toPhoneNumber);
131 break;
132 case "outgoing": // NON-NLS
133 phoneNumberToReturn = getFirstNonBlank(toPhoneNumber, phoneNumber, fromPhoneNumber);
134 break;
135 default:
136 phoneNumberToReturn = getFirstNonBlank(toPhoneNumber, fromPhoneNumber, phoneNumber );
137 break;
138 }
139
140 return phoneNumberToReturn;
141 }
142
154 private String getFirstNonBlank(String string1, String string2, String string3 ) {
155
156 if (!StringUtils.isBlank(string1)) {
157 return string1;
158 } else if (!StringUtils.isBlank(string2)) {
159 return string2;
160 } else if (!StringUtils.isBlank(string3)) {
161 return string3;
162 }
163 return "";
164 }
171 @Override
172 public String getSourceName() {
173 return getDisplayName();
174 }
175}

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.