19package org.sleuthkit.autopsy.communications;
21import com.google.common.cache.CacheBuilder;
22import com.google.common.cache.CacheLoader;
23import com.google.common.cache.LoadingCache;
24import java.beans.PropertyChangeEvent;
25import java.beans.PropertyChangeListener;
26import java.sql.SQLException;
27import java.util.ArrayList;
28import java.util.EnumSet;
29import java.util.HashMap;
32import java.util.concurrent.ExecutionException;
33import java.util.concurrent.TimeUnit;
34import java.util.logging.Level;
35import org.sleuthkit.autopsy.casemodule.Case;
36import org.sleuthkit.autopsy.coreutils.Logger;
37import org.sleuthkit.autopsy.ingest.IngestManager;
38import static org.sleuthkit.autopsy.ingest.IngestManager.IngestModuleEvent.DATA_ADDED;
39import org.sleuthkit.autopsy.ingest.ModuleDataEvent;
40import org.sleuthkit.datamodel.Account;
41import org.sleuthkit.datamodel.BlackboardArtifact;
42import org.sleuthkit.datamodel.BlackboardAttribute;
43import org.sleuthkit.datamodel.TskCoreException;
57 private final LoadingCache<String, Map<String, List<BlackboardArtifact>>>
accountMap;
69 static public synchronized List<BlackboardArtifact>
getContacts(Account account)
throws ExecutionException {
76 static synchronized void invalidateCache() {
85 accountMap = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).build(
86 new CacheLoader<String, Map<String, List<BlackboardArtifact>>>() {
88 public Map<String, List<BlackboardArtifact>> load(String key) {
91 }
catch (SQLException | TskCoreException ex) {
92 logger.log(Level.WARNING,
"Failed to build account to contact map", ex);
94 return new HashMap<>();
98 PropertyChangeListener ingestListener = pce -> {
99 String eventType = pce.getPropertyName();
100 if (eventType.equals(DATA_ADDED.toString())) {
109 if (event.getNewValue() == null) {
138 private Map<String, List<BlackboardArtifact>>
buildMap() throws TskCoreException, SQLException {
139 Map<String, List<BlackboardArtifact>> acctMap =
new HashMap<>();
142 for (BlackboardArtifact contactArtifact : contactList) {
143 List<BlackboardAttribute> contactAttributes = contactArtifact.getAttributes();
144 for (BlackboardAttribute attribute : contactAttributes) {
145 String typeName = attribute.getAttributeType().getTypeName();
147 if (typeName.startsWith(
"TSK_EMAIL")
148 || typeName.startsWith(
"TSK_PHONE")
149 || typeName.startsWith(
"TSK_NAME")
150 || typeName.startsWith(
"TSK_ID")) {
151 String accountID = attribute.getValueString();
152 List<BlackboardArtifact> artifactList = acctMap.getOrDefault(accountID,
new ArrayList<>());
154 acctMap.put(accountID, artifactList);
156 if (!artifactList.contains(contactArtifact)) {
157 artifactList.add(contactArtifact);
SleuthkitCase getSleuthkitCase()
static Case getCurrentCase()
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
synchronized static Logger getLogger(String name)
static synchronized IngestManager getInstance()
void addIngestModuleEventListener(final PropertyChangeListener listener)
BlackboardArtifact.Type getBlackboardArtifactType()