19 package org.sleuthkit.autopsy.communications.relationships;
21 import java.util.Collection;
22 import java.util.List;
24 import java.util.logging.Level;
33 import org.
sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments.FileAttachment;
34 import org.
sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments;
36 import org.
sleuthkit.datamodel.blackboardutils.attributes.BlackboardJsonAttrUtil;
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) {
141 MessageAttachments msgAttachments = BlackboardJsonAttrUtil.fromAttribute(attachmentsAttr, MessageAttachments.class);
142 Collection<FileAttachment> fileAttachments = msgAttachments.getFileAttachments();
143 for (FileAttachment fileAttachment : fileAttachments) {
145 long attachedFileObjId = fileAttachment.getObjectId();
146 if (attachedFileObjId >= 0) {
147 AbstractFile attachedFile = artifact.getSleuthkitCase().getAbstractFileById(attachedFileObjId);
148 if (ImageUtils.thumbnailSupported(attachedFile)) {
154 catch (BlackboardJsonAttrUtil.InvalidJsonException ex) {
155 logger.log(Level.WARNING, String.format(
"Unable to parse json for MessageAttachments object in artifact: %s", artifact.getName()), ex);
158 attachmentCnt += artifact.getChildrenCount();
159 for (Content childContent : artifact.getChildren()) {
160 if (ImageUtils.thumbnailSupported(childContent)) {
165 }
catch (TskCoreException ex) {
166 logger.log(Level.WARNING, String.format(
"Exception thrown "
167 +
"from getChildrenCount artifactID: %d",
168 artifact.getArtifactID()), ex);
178 public int getAttachmentCnt() {
179 return attachmentCnt;
187 public int getMessagesCnt() {
196 public int getEmailCnt() {
205 public int getCallLogCnt() {
214 public int getContactsCnt() {
223 public int getThumbnailCnt() {
232 public int getReferenceCnt() {