From 24c256f3d2988c61bf262b08aa06c35bcda5b9fb Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Thu, 18 Apr 2019 14:00:03 -0400 Subject: [PATCH] Modified ContactNode so that all attributes are correctly being displayed from vcards and contacts with multiple attrbutes of the same type --- .../communications/ContactDetailsPane.java | 2 + .../autopsy/communications/ContactNode.java | 55 ++++++++++++++++++- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/communications/ContactDetailsPane.java b/Core/src/org/sleuthkit/autopsy/communications/ContactDetailsPane.java index c22f60fb7e..d699c7cddf 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/ContactDetailsPane.java +++ b/Core/src/org/sleuthkit/autopsy/communications/ContactDetailsPane.java @@ -34,6 +34,8 @@ public final class ContactDetailsPane extends javax.swing.JPanel implements Expl public ContactDetailsPane() { initComponents(); this.setEnabled(false); + + nameLabel.setText(""); } /** diff --git a/Core/src/org/sleuthkit/autopsy/communications/ContactNode.java b/Core/src/org/sleuthkit/autopsy/communications/ContactNode.java index 9a59b82a99..e58161b4f0 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/ContactNode.java +++ b/Core/src/org/sleuthkit/autopsy/communications/ContactNode.java @@ -18,6 +18,8 @@ */ package org.sleuthkit.autopsy.communications; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.TimeZone; import java.util.logging.Level; @@ -63,7 +65,7 @@ final class ContactNode extends BlackboardArtifactNode { super(artifact); String name = getAttributeDisplayString(artifact, TSK_NAME); - if(name == null || name.trim().isEmpty()) { + if (name == null || name.trim().isEmpty()) { // VCards use TSK_NAME_PERSON instead of TSK_NAME name = getAttributeDisplayString(artifact, TSK_NAME_PERSON); } @@ -84,10 +86,57 @@ final class ContactNode extends BlackboardArtifactNode { sheetSet = Sheet.createPropertiesSet(); sheet.put(sheetSet); } - + + // Sorting the attributes by type so that the duplicates can be removed + // and they can be grouped by type for display. try { + HashMap phoneNumList = new HashMap<>(); + HashMap emailList = new HashMap<>(); + HashMap nameList = new HashMap<>(); + HashMap otherList = new HashMap<>(); for (BlackboardAttribute bba : artifact.getAttributes()) { - sheetSet.put(new NodeProperty<>(bba.getAttributeType().getTypeName(), bba.getAttributeType().getDisplayName(), "", bba.getDisplayString())); + if (bba.getAttributeType().getTypeName().contains("TSK_PHONE")) { + phoneNumList.put(bba.getDisplayString(), bba); + } else if (bba.getAttributeType().getTypeName().contains("TSK_EMAIL")) { + emailList.put(bba.getDisplayString(), bba); + } else if (bba.getAttributeType().getTypeName().contains("TSK_NAME")) { + nameList.put(bba.getDisplayString(), bba); + } else { + otherList.put(bba.getDisplayString(), bba); + } + } + String propertyID = BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getLabel(); + int count = 0; + for (BlackboardAttribute bba : nameList.values()) { + if (count++ > 0) { + sheetSet.put(new NodeProperty<>(propertyID + "_" + count, bba.getAttributeType().getDisplayName(), "", bba.getDisplayString())); + } else { + sheetSet.put(new NodeProperty<>(propertyID, bba.getAttributeType().getDisplayName(), "", bba.getDisplayString())); + } + } + + propertyID = BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER.getLabel(); + count = 0; + for (BlackboardAttribute bba : phoneNumList.values()) { + if (count++ > 0) { + sheetSet.put(new NodeProperty<>(propertyID + "_" + count, bba.getAttributeType().getDisplayName(), "", bba.getDisplayString())); + } else { + sheetSet.put(new NodeProperty<>(propertyID, bba.getAttributeType().getDisplayName(), "", bba.getDisplayString())); + } + } + + propertyID = BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL.getLabel(); + count = 0; + for (BlackboardAttribute bba : emailList.values()) { + if (count++ > 0) { + sheetSet.put(new NodeProperty<>(propertyID + "_" + count, bba.getAttributeType().getDisplayName(), "", bba.getDisplayString())); + } else { + sheetSet.put(new NodeProperty<>(propertyID, bba.getAttributeType().getDisplayName(), "", bba.getDisplayString())); + } + } + + for (BlackboardAttribute bba1 : otherList.values()) { + sheetSet.put(new NodeProperty<>(bba1.getAttributeType().getTypeName(), bba1.getAttributeType().getDisplayName(), "", bba1.getDisplayString())); } } catch (TskCoreException ex) {