19 package org.sleuthkit.autopsy.contentviewers.artifactviewers;
21 import java.awt.Component;
22 import java.awt.GridBagConstraints;
23 import java.awt.GridBagLayout;
24 import java.util.ArrayList;
25 import java.util.Arrays;
26 import java.util.HashMap;
27 import java.util.HashSet;
28 import java.util.List;
31 import java.util.logging.Level;
32 import javax.swing.JScrollPane;
33 import org.apache.commons.lang3.ObjectUtils;
34 import org.apache.commons.lang3.StringUtils;
35 import org.openide.util.NbBundle;
36 import org.openide.util.lookup.ServiceProvider;
50 @ServiceProvider(service = ArtifactContentViewer.class)
54 private static final long serialVersionUID = 1L;
56 private static final Set<Integer> HANDLED_ATTRIBUTE_TYPES =
new HashSet<Integer>(Arrays.asList(
57 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER.getTypeID(),
58 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO.getTypeID(),
59 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM.getTypeID(),
60 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ID.getTypeID(),
61 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DIRECTION.getTypeID(),
62 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID(),
63 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START.getTypeID(),
64 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END.getTypeID()
67 private GridBagLayout m_gridBagLayout =
new GridBagLayout();
68 private GridBagConstraints m_constraints =
new GridBagConstraints();
70 private PersonaAccountFetcher currentAccountFetcher = null;
84 @SuppressWarnings(
"unchecked")
86 private
void initComponents() {
88 setLayout(
new java.awt.GridBagLayout());
95 if (artifact == null) {
99 CallLogViewData callLogViewData = null;
101 callLogViewData = getCallLogViewData(artifact);
102 }
catch (TskCoreException ex) {
103 logger.log(Level.SEVERE, String.format(
"Error getting attributes for Calllog artifact (artifact_id=%d, obj_id=%d)", artifact.getArtifactID(), artifact.getObjectID()), ex);
107 if (callLogViewData != null) {
108 List<AccountPersonaSearcherData> personaSearchDataList = updateView(callLogViewData);
109 if(!personaSearchDataList.isEmpty()) {
110 currentAccountFetcher =
new PersonaAccountFetcher(artifact, personaSearchDataList,
this);
111 currentAccountFetcher.execute();
113 currentAccountFetcher = null;
131 if (artifact == null) {
135 BlackboardAttribute directionAttr = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DIRECTION));
136 BlackboardAttribute toAccountAttr = null;
137 BlackboardAttribute fromAccountAttr = null;
138 BlackboardAttribute localAccountAttr = null;
140 CallLogViewData callLogViewData = null;
142 String direction = null;
143 String fromAccountIdentifier = null;
144 String toAccountIdentifier = null;
145 List<String> otherParties = null;
147 Content dataSource = artifact.getDataSource();
148 String deviceId = ((DataSource) dataSource).getDeviceId();
150 if (directionAttr != null) {
151 direction = directionAttr.getValueString();
152 if (direction.equalsIgnoreCase(
"Incoming")) {
153 fromAccountAttr = ObjectUtils.firstNonNull(
154 artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM)),
155 artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER)),
156 artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ID))
159 toAccountAttr = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO));
160 localAccountAttr = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO));
161 }
else if (direction.equalsIgnoreCase(
"Outgoing")) {
162 toAccountAttr = ObjectUtils.firstNonNull(
163 artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO)),
164 artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER)),
165 artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ID))
168 fromAccountAttr = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM));
169 localAccountAttr = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM));
175 if (fromAccountAttr == null) {
176 fromAccountAttr = ObjectUtils.firstNonNull(
177 artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM)),
178 artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO)),
179 artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER)),
180 artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ID))
185 if (fromAccountAttr != null) {
186 String fromAccountAttrValue = fromAccountAttr.getValueString();
187 if (fromAccountAttrValue.equalsIgnoreCase(deviceId) ==
false) {
188 fromAccountIdentifier = fromAccountAttrValue;
192 if (toAccountAttr != null) {
194 String[] numbers = toAccountAttr.getValueString().split(
",");
195 String toAccountAttrValue = StringUtils.trim(numbers[0]);
196 if (toAccountAttrValue.equalsIgnoreCase(deviceId) ==
false) {
197 toAccountIdentifier = toAccountAttrValue;
202 if (numbers.length > 1) {
203 otherParties =
new ArrayList<>();
204 for (
int i = 1; i < numbers.length; i++) {
205 otherParties.add(StringUtils.trim(numbers[i]));
211 if (null != fromAccountAttr || null != toAccountAttr) {
212 callLogViewData =
new CallLogViewData(fromAccountIdentifier, toAccountIdentifier);
213 callLogViewData.setDirection(direction);
215 callLogViewData.setOtherParties(otherParties);
217 extractTimeAndDuration(artifact, callLogViewData);
219 callLogViewData.setDataSourceName(dataSource.getName());
222 if (localAccountAttr != null) {
223 String attrValue = localAccountAttr.getValueString();
225 if (attrValue.equalsIgnoreCase(deviceId) ==
false && attrValue.contains(
",") ==
false) {
226 callLogViewData.setLocalAccountId(attrValue);
230 callLogViewData.setOtherAttributes(extractOtherAttributes(artifact));
233 return callLogViewData;
246 private void extractTimeAndDuration(BlackboardArtifact artifact, CallLogViewData callLogViewData)
throws TskCoreException {
248 BlackboardAttribute startTimeAttr = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START));
249 if (startTimeAttr == null) {
250 startTimeAttr = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME));
252 if (startTimeAttr != null) {
253 long startTime = startTimeAttr.getValueLong();
254 callLogViewData.setDateTimeStr(startTimeAttr.getDisplayString());
256 BlackboardAttribute endTimeAttr = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END));
257 if (endTimeAttr != null) {
258 long endTime = endTimeAttr.getValueLong();
259 if (endTime > 0 && (endTime - startTime) > 0) {
260 callLogViewData.setDuration(String.format(
"%d seconds", (endTime - startTime)));
277 List<BlackboardAttribute> attributes = artifact.getAttributes();
278 Map<String, String> otherAttributes =
new HashMap<>();
280 for (BlackboardAttribute attr : attributes) {
281 if (HANDLED_ATTRIBUTE_TYPES.contains(attr.getAttributeType().getTypeID()) ==
false) {
282 otherAttributes.put(attr.getAttributeType().getDisplayName(), attr.getDisplayString());
286 return otherAttributes;
297 "CallLogArtifactViewer_heading_parties=Parties",
298 "CallLogArtifactViewer_value_unknown=Unknown",
299 "CallLogArtifactViewer_label_from=From",
300 "CallLogArtifactViewer_label_to=To"
302 private List<AccountPersonaSearcherData>
updateView(CallLogViewData callLogViewData) {
304 CommunicationArtifactViewerHelper.addHeader(
this, m_gridBagLayout, this.m_constraints, Bundle.CallLogArtifactViewer_heading_parties());
306 List<AccountPersonaSearcherData> dataList =
new ArrayList<>();
308 CommunicationArtifactViewerHelper.addKey(
this, m_gridBagLayout, this.m_constraints, Bundle.CallLogArtifactViewer_label_from());
310 if (callLogViewData.getFromAccount() != null) {
312 String accountDisplayString = getAccountDisplayString(callLogViewData.getFromAccount(), callLogViewData);
313 CommunicationArtifactViewerHelper.addValue(
this, m_gridBagLayout, this.m_constraints, accountDisplayString);
316 dataList.addAll( CommunicationArtifactViewerHelper.addPersonaRow(
this, m_gridBagLayout,
this.m_constraints, callLogViewData.getFromAccount()));
318 CommunicationArtifactViewerHelper.addValue(
this, m_gridBagLayout, this.m_constraints, Bundle.CallLogArtifactViewer_value_unknown());
322 CommunicationArtifactViewerHelper.addKey(
this, m_gridBagLayout, this.m_constraints, Bundle.CallLogArtifactViewer_label_to());
323 if (callLogViewData.getToAccount() != null) {
324 String accountDisplayString = getAccountDisplayString(callLogViewData.getToAccount(), callLogViewData);
325 CommunicationArtifactViewerHelper.addValue(
this, m_gridBagLayout, this.m_constraints, accountDisplayString);
327 dataList.addAll( CommunicationArtifactViewerHelper.addPersonaRow(
this, m_gridBagLayout,
this.m_constraints, callLogViewData.getToAccount()));
330 CommunicationArtifactViewerHelper.addValue(
this, m_gridBagLayout, this.m_constraints, Bundle.CallLogArtifactViewer_value_unknown());
334 for (String otherParty : callLogViewData.getOtherParties()) {
335 CommunicationArtifactViewerHelper.addKey(
this, m_gridBagLayout, this.m_constraints, Bundle.CallLogArtifactViewer_label_to());
336 CommunicationArtifactViewerHelper.addValue(
this, m_gridBagLayout, this.m_constraints, otherParty);
338 dataList.addAll( CommunicationArtifactViewerHelper.addPersonaRow(
this, m_gridBagLayout,
this.m_constraints, otherParty));
341 updateMetadataView(callLogViewData);
343 updateOtherAttributesView(callLogViewData);
345 updateSourceView(callLogViewData);
348 showCRDisabledMessage();
351 CommunicationArtifactViewerHelper.addPageEndGlue(
this, m_gridBagLayout, this.m_constraints);
353 this.setLayout(m_gridBagLayout);
366 "CallLogArtifactViewer_heading_metadata=Metadata",
367 "CallLogArtifactViewer_label_direction=Direction",
368 "CallLogArtifactViewer_label_date=Date",
369 "CallLogArtifactViewer_label_duration=Duration"
373 CommunicationArtifactViewerHelper.addHeader(
this, m_gridBagLayout, this.m_constraints, Bundle.CallLogArtifactViewer_heading_metadata());
375 CommunicationArtifactViewerHelper.addKey(
this, m_gridBagLayout, this.m_constraints, Bundle.CallLogArtifactViewer_label_direction());
376 if (callLogViewData.getDirection() != null) {
377 CommunicationArtifactViewerHelper.addValue(
this, m_gridBagLayout, this.m_constraints, callLogViewData.getDirection());
379 CommunicationArtifactViewerHelper.addValue(
this, m_gridBagLayout, this.m_constraints, Bundle.CallLogArtifactViewer_value_unknown());
382 if (callLogViewData.getDateTimeStr() != null) {
383 CommunicationArtifactViewerHelper.addKey(
this, m_gridBagLayout, this.m_constraints, Bundle.CallLogArtifactViewer_label_date());
384 CommunicationArtifactViewerHelper.addValue(
this, m_gridBagLayout, this.m_constraints, callLogViewData.getDateTimeStr());
387 if (callLogViewData.getDuration() != null) {
388 CommunicationArtifactViewerHelper.addKey(
this, m_gridBagLayout, this.m_constraints, Bundle.CallLogArtifactViewer_label_duration());
389 CommunicationArtifactViewerHelper.addValue(
this, m_gridBagLayout, this.m_constraints, callLogViewData.getDuration());
400 "CallLogArtifactViewer_heading_Source=Source",
401 "CallLogArtifactViewer_label_datasource=Data Source",})
403 CommunicationArtifactViewerHelper.addHeader(
this, m_gridBagLayout, this.m_constraints, Bundle.CallLogArtifactViewer_heading_Source());
404 CommunicationArtifactViewerHelper.addKey(
this, m_gridBagLayout, this.m_constraints, Bundle.CallLogArtifactViewer_label_datasource());
405 CommunicationArtifactViewerHelper.addValue(
this, m_gridBagLayout, this.m_constraints, callLogViewData.getDataSourceName());
414 "CallLogArtifactViewer_heading_others=Other Attributes"
418 if (callLogViewData.getOtherAttributes().isEmpty()) {
421 CommunicationArtifactViewerHelper.addHeader(
this, m_gridBagLayout, this.m_constraints, Bundle.CallLogArtifactViewer_heading_others());
423 for (Map.Entry<String, String> entry : callLogViewData.getOtherAttributes().entrySet()) {
424 CommunicationArtifactViewerHelper.addKey(
this, m_gridBagLayout, this.m_constraints, entry.getKey());
425 CommunicationArtifactViewerHelper.addValue(
this, m_gridBagLayout, this.m_constraints, entry.getValue());
430 "CalllogArtifactViewer_cr_disabled_message=Enable Central Repository to view, create and edit personas."
433 CommunicationArtifactViewerHelper.addBlankLine(
this, m_gridBagLayout, m_constraints);
434 m_constraints.gridy++;
435 CommunicationArtifactViewerHelper.addMessageRow(
this, m_gridBagLayout, m_constraints, Bundle.ContactArtifactViewer_cr_disabled_message());
436 m_constraints.gridy++;
450 "CallLogArtifactViewer_suffix_local=(Local)",})
452 String accountDisplayValue = accountIdentifier;
453 if (callLogViewDataNew.getLocalAccountId() != null && callLogViewDataNew.getLocalAccountId().equalsIgnoreCase(accountIdentifier)) {
454 accountDisplayValue +=
" " + Bundle.CallLogArtifactViewer_suffix_local();
456 return accountDisplayValue;
461 return new JScrollPane(
this, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
467 return (artifact != null)
468 && (artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_CALLLOG.getTypeID());
477 if(currentAccountFetcher != null && !currentAccountFetcher.isDone()) {
478 currentAccountFetcher.cancel(
true);
479 currentAccountFetcher = null;
484 this.setLayout(null);
486 m_gridBagLayout =
new GridBagLayout();
487 m_constraints =
new GridBagConstraints();
489 m_constraints.anchor = GridBagConstraints.FIRST_LINE_START;
490 m_constraints.gridy = 0;
491 m_constraints.gridx = 0;
492 m_constraints.weighty = 0.0;
493 m_constraints.weightx = 0.0;
494 m_constraints.insets =
new java.awt.Insets(0, CommunicationArtifactViewerHelper.LEFT_INSET, 0, 0);
495 m_constraints.fill = GridBagConstraints.NONE;
boolean isSupported(BlackboardArtifact artifact)
CallLogViewData getCallLogViewData(BlackboardArtifact artifact)
void extractTimeAndDuration(BlackboardArtifact artifact, CallLogViewData callLogViewData)
void updateMetadataView(CallLogViewData callLogViewData)
List< AccountPersonaSearcherData > updateView(CallLogViewData callLogViewData)
void updateSourceView(CallLogViewData callLogViewData)
String getAccountDisplayString(String accountIdentifier, CallLogViewData callLogViewDataNew)
void showCRDisabledMessage()
void updateOtherAttributesView(CallLogViewData callLogViewData)
Map< String, String > extractOtherAttributes(BlackboardArtifact artifact)
void setArtifact(BlackboardArtifact artifact)
synchronized static Logger getLogger(String name)
static boolean isEnabled()