Autopsy  4.11.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ContactsChildNodeFactory.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 obtain 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.List;
22 import java.util.Set;
23 import java.util.logging.Level;
24 import org.openide.nodes.ChildFactory;
25 import org.openide.nodes.Node;
29 import org.sleuthkit.datamodel.BlackboardArtifact;
30 import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT;
31 import org.sleuthkit.datamodel.CommunicationsManager;
32 import org.sleuthkit.datamodel.Content;
33 import org.sleuthkit.datamodel.TskCoreException;
34 
38 final class ContactsChildNodeFactory extends ChildFactory<BlackboardArtifact>{
39  private static final Logger logger = Logger.getLogger(ContactsChildNodeFactory.class.getName());
40 
41  private SelectionInfo selectionInfo;
42 
49  ContactsChildNodeFactory(SelectionInfo selectionInfo) {
50  this.selectionInfo = selectionInfo;
51  }
52 
58  public void refresh(SelectionInfo selectionInfo) {
59  this.selectionInfo = selectionInfo;
60  refresh(true);
61  }
62 
69  @Override
70  protected boolean createKeys(List<BlackboardArtifact> list) {
71  CommunicationsManager communicationManager;
72  try {
73  communicationManager = Case.getCurrentCaseThrows().getSleuthkitCase().getCommunicationsManager();
74  } catch (NoCurrentCaseException | TskCoreException ex) {
75  logger.log(Level.SEVERE, "Failed to get communications manager from case.", ex); //NON-NLS
76  return false;
77  }
78 
79  if(selectionInfo == null) {
80  return true;
81  }
82 
83  final Set<Content> relationshipSources;
84 
85  try {
86  relationshipSources = communicationManager.getRelationshipSources(selectionInfo.getAccountDevicesInstances(), selectionInfo.getCommunicationsFilter());
87 
88  relationshipSources.stream().filter((content) -> (content instanceof BlackboardArtifact)).forEachOrdered((content) -> {
89 
90  BlackboardArtifact bba = (BlackboardArtifact) content;
91  BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(bba.getArtifactTypeID());
92 
93  if (fromID == TSK_CONTACT) {
94  list.add(bba);
95  }
96  });
97 
98  } catch (TskCoreException ex) {
99  logger.log(Level.SEVERE, "Failed to get relationship sources.", ex); //NON-NLS
100  }
101 
102  return true;
103  }
104 
105  @Override
106  protected Node createNodeForKey(BlackboardArtifact key) {
107  return new ContactNode(key);
108  }
109 }

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.