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.InvalidAccountIDException;
37 import org.
sleuthkit.datamodel.blackboardutils.attributes.BlackboardJsonAttrUtil;
43 class AccountSummary {
45 private int attachmentCnt;
46 private int messagesCnt;
48 private int callLogCnt;
49 private int contactsCnt;
51 private int referenceCnt;
53 private final Account selectedAccount;
54 private final Set<BlackboardArtifact> artifacts;
56 private static final Logger logger = Logger.getLogger(AccountSummary.class.getName());
64 AccountSummary(Account selectedAccount, Set<BlackboardArtifact> artifacts) {
65 this.selectedAccount = selectedAccount;
66 this.artifacts = artifacts;
73 private void initCounts() {
74 for (BlackboardArtifact artifact : artifacts) {
75 BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
88 if (selectedAccount.getAccountType() != Account.Type.DEVICE) {
89 String typeSpecificID = selectedAccount.getTypeSpecificID();
91 List<BlackboardAttribute> attributes = null;
94 attributes = artifact.getAttributes();
95 }
catch(TskCoreException ex) {
96 logger.log(Level.WARNING, String.format(
"Unable to getAttributes for artifact: %d", artifact.getArtifactID()), ex);
100 boolean isReference =
false;
102 for (BlackboardAttribute attribute : attributes) {
104 String attributeTypeName = attribute.getAttributeType().getTypeName();
105 String attributeValue = attribute.getValueString();
107 if (attributeTypeName.contains(
"PHONE")) {
108 attributeValue = CommunicationsUtils.normalizePhoneNum(attributeValue);
109 }
else if (attributeTypeName.contains(
"EMAIL")) {
110 attributeValue = CommunicationsUtils.normalizeEmailAddress(attributeValue);
113 if (typeSpecificID.equals(attributeValue)) {
117 }
catch (InvalidAccountIDException ex) {
118 logger.log(Level.WARNING, String.format(
"Exception thrown "
119 +
"in trying to normalize attribute value: %s",
120 attributeValue), ex);
139 BlackboardAttribute attachmentsAttr = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ATTACHMENTS));
140 if (attachmentsAttr != null) {
142 MessageAttachments msgAttachments = BlackboardJsonAttrUtil.fromAttribute(attachmentsAttr, 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 catch (BlackboardJsonAttrUtil.InvalidJsonException ex) {
156 logger.log(Level.WARNING, String.format(
"Unable to parse json for MessageAttachments object in artifact: %s", artifact.getName()), ex);
159 attachmentCnt += artifact.getChildrenCount();
160 for (Content childContent : artifact.getChildren()) {
161 if (ImageUtils.thumbnailSupported(childContent)) {
166 }
catch (TskCoreException ex) {
167 logger.log(Level.WARNING, String.format(
"Exception thrown "
168 +
"from getChildrenCount artifactID: %d",
169 artifact.getArtifactID()), ex);
179 public int getAttachmentCnt() {
180 return attachmentCnt;
188 public int getMessagesCnt() {
197 public int getEmailCnt() {
206 public int getCallLogCnt() {
215 public int getContactsCnt() {
224 public int getThumbnailCnt() {
233 public int getReferenceCnt() {