Autopsy  4.11.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
SelectionInfo.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2019 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obt ain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.communications.relationships;
20 
21 import java.util.HashSet;
22 import java.util.Set;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
27 import org.sleuthkit.datamodel.Account;
28 import org.sleuthkit.datamodel.AccountDeviceInstance;
29 import org.sleuthkit.datamodel.BlackboardArtifact;
30 import org.sleuthkit.datamodel.CommunicationsFilter;
31 import org.sleuthkit.datamodel.CommunicationsManager;
32 import org.sleuthkit.datamodel.Content;
33 import org.sleuthkit.datamodel.TskCoreException;
34 
39 public final class SelectionInfo {
40 
41  private static final Logger logger = Logger.getLogger(SelectionInfo.class.getName());
42 
43  private final Set<AccountDeviceInstance> accountDeviceInstances;
44  private final CommunicationsFilter communicationFilter;
45  private final Set<Account> accounts;
46 
47  private Set<BlackboardArtifact> accountArtifacts = null;
48  private SelectionSummary summary = null;
49 
56  public SelectionInfo(Set<AccountDeviceInstance> accountDeviceInstances, CommunicationsFilter communicationFilter) {
57  this.accountDeviceInstances = accountDeviceInstances;
58  this.communicationFilter = communicationFilter;
59 
60  accounts = new HashSet<>();
61  accountDeviceInstances.forEach((instance) -> {
62  accounts.add(instance.getAccount());
63  });
64  }
65 
71  public Set<AccountDeviceInstance> getAccountDevicesInstances() {
73  }
74 
80  public CommunicationsFilter getCommunicationsFilter() {
81  return communicationFilter;
82  }
83 
84  public Set<Account> getAccounts() {
85  return accounts;
86  }
87 
88  public Set<BlackboardArtifact> getArtifacts() {
89  if(accountArtifacts == null) {
90  accountArtifacts = new HashSet<>();
91  CommunicationsManager communicationManager;
92  try {
93  communicationManager = Case.getCurrentCaseThrows().getSleuthkitCase().getCommunicationsManager();
94  } catch (NoCurrentCaseException | TskCoreException ex) {
95  logger.log(Level.SEVERE, "Failed to get communications manager from case.", ex); //NON-NLS
96  return null;
97  }
98 
99  final Set<Content> relationshipSources;
100 
101  try {
102  relationshipSources = communicationManager.getRelationshipSources(getAccountDevicesInstances(), getCommunicationsFilter());
103 
104  relationshipSources.stream().filter((content) -> (content instanceof BlackboardArtifact)).forEachOrdered((content) -> {
105  accountArtifacts.add((BlackboardArtifact) content);
106  });
107 
108  } catch (TskCoreException ex) {
109  logger.log(Level.SEVERE, "Failed to get relationship sources.", ex); //NON-NLS
110  }
111  }
112 
113  return accountArtifacts;
114  }
115 
116  public SelectionSummary getSummary() {
117  if(summary == null) {
118  summary = new SelectionSummary();
119  }
120 
121  return summary;
122  }
123 
124  final class SelectionSummary{
125  int attachmentCnt;
126  int messagesCnt;
127  int emailCnt;
128  int callLogCnt;
129  int contactsCnt;
130 
131  SelectionSummary() {
132  getCounts();
133  }
134 
135  private void getCounts(){
136  for(BlackboardArtifact artifact: getArtifacts()) {
137  BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
138  if(null != fromID) switch (fromID) {
139  case TSK_EMAIL_MSG:
140  emailCnt++;
141  break;
142  case TSK_CALLLOG:
143  callLogCnt++;
144  break;
145  case TSK_MESSAGE:
146  messagesCnt++;
147  break;
148  case TSK_CONTACT:
149  contactsCnt++;
150  break;
151  default:
152  break;
153  }
154  try{
155  attachmentCnt+= artifact.getChildrenCount();
156  } catch (TskCoreException ex) {
157  logger.log(Level.WARNING, String.format("Exception thrown "
158  + "from getChildrenCount artifactID: %d",
159  artifact.getArtifactID()), ex); //NON-NLS
160  }
161  }
162  }
163 
164  public int getAttachmentCnt() {
165  return attachmentCnt;
166  }
167 
168  public int getMessagesCnt() {
169  return messagesCnt;
170  }
171 
172  public int getEmailCnt() {
173  return emailCnt;
174  }
175 
176  public int getCallLogCnt() {
177  return callLogCnt;
178  }
179 
180  public int getContactsCnt() {
181  return contactsCnt;
182  }
183  }
184 
185 }
SelectionInfo(Set< AccountDeviceInstance > accountDeviceInstances, CommunicationsFilter communicationFilter)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2018 Basis Technology. Generated on: Fri Jun 21 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.