19 package org.sleuthkit.autopsy.communications.relationships;
21 import com.google.gson.Gson;
22 import java.util.Collection;
23 import java.util.List;
25 import java.util.logging.Level;
34 import org.
sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments.FileAttachment;
35 import org.
sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments;
42 class AccountSummary {
44 private int attachmentCnt;
45 private int messagesCnt;
47 private int callLogCnt;
48 private int contactsCnt;
50 private int referenceCnt;
52 private final Account selectedAccount;
53 private final Set<BlackboardArtifact> artifacts;
55 private static final Logger logger = Logger.getLogger(AccountSummary.class.getName());
63 AccountSummary(Account selectedAccount, Set<BlackboardArtifact> artifacts) {
64 this.selectedAccount = selectedAccount;
65 this.artifacts = artifacts;
72 private void initCounts() {
73 for (BlackboardArtifact artifact : artifacts) {
74 BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
87 if (selectedAccount.getAccountType() != Account.Type.DEVICE) {
88 String typeSpecificID = selectedAccount.getTypeSpecificID();
90 List<BlackboardAttribute> attributes = null;
93 attributes = artifact.getAttributes();
94 }
catch(TskCoreException ex) {
95 logger.log(Level.WARNING, String.format(
"Unable to getAttributes for artifact: %d", artifact.getArtifactID()), ex);
99 boolean isReference =
false;
101 for (BlackboardAttribute attribute : attributes) {
103 String attributeTypeName = attribute.getAttributeType().getTypeName();
104 String attributeValue = attribute.getValueString();
106 if (attributeTypeName.contains(
"PHONE")) {
107 attributeValue = CommunicationsUtils.normalizePhoneNum(attributeValue);
108 }
else if (attributeTypeName.contains(
"EMAIL")) {
109 attributeValue = CommunicationsUtils.normalizeEmailAddress(attributeValue);
112 if (typeSpecificID.equals(attributeValue)) {
116 }
catch (TskCoreException ex) {
117 logger.log(Level.WARNING, String.format(
"Exception thrown "
118 +
"in trying to normalize attribute value: %s",
119 attributeValue), ex);
138 BlackboardAttribute attachmentsAttr = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ATTACHMENTS));
139 if (attachmentsAttr != null) {
140 String jsonVal = attachmentsAttr.getValueString();
141 MessageAttachments msgAttachments =
new Gson().fromJson(jsonVal, MessageAttachments.class);
143 Collection<FileAttachment> fileAttachments = msgAttachments.getFileAttachments();
144 for (FileAttachment fileAttachment : fileAttachments) {
146 long attachedFileObjId = fileAttachment.getObjectId();
147 if (attachedFileObjId >= 0) {
148 AbstractFile attachedFile = artifact.getSleuthkitCase().getAbstractFileById(attachedFileObjId);
149 if (ImageUtils.thumbnailSupported(attachedFile)) {
155 attachmentCnt += artifact.getChildrenCount();
156 for (Content childContent : artifact.getChildren()) {
157 if (ImageUtils.thumbnailSupported(childContent)) {
162 }
catch (TskCoreException ex) {
163 logger.log(Level.WARNING, String.format(
"Exception thrown "
164 +
"from getChildrenCount artifactID: %d",
165 artifact.getArtifactID()), ex);
175 public int getAttachmentCnt() {
176 return attachmentCnt;
184 public int getMessagesCnt() {
193 public int getEmailCnt() {
202 public int getCallLogCnt() {
211 public int getContactsCnt() {
220 public int getThumbnailCnt() {
229 public int getReferenceCnt() {