Autopsy  4.11.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
MessagesChildNodeFactory.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 org.sleuthkit.datamodel.BlackboardAttribute;
31 import org.sleuthkit.datamodel.CommunicationsManager;
32 import org.sleuthkit.datamodel.Content;
33 import org.sleuthkit.datamodel.TskCoreException;
34 
40 public class MessagesChildNodeFactory extends ChildFactory<BlackboardArtifact>{
41 
42  private static final Logger logger = Logger.getLogger(MessagesChildNodeFactory.class.getName());
43 
45 
46  private List<String> threadIDs;
47 
48  MessagesChildNodeFactory(SelectionInfo selectionInfo, List<String> threadIDs) {
49  this.selectionInfo = selectionInfo;
50  this.threadIDs = threadIDs;
51  }
52 
54  this(null, null);
55  }
56 
64  public void refresh(SelectionInfo selectionInfo, List<String> threadIDs) {
65  this.threadIDs = threadIDs;
66  this.selectionInfo = selectionInfo;
67  refresh(true);
68 
69  }
70 
71  @Override
72  protected boolean createKeys(List<BlackboardArtifact> list) {
73  CommunicationsManager communicationManager;
74 
75  try {
76  communicationManager = Case.getCurrentCaseThrows().getSleuthkitCase().getCommunicationsManager();
77  } catch (NoCurrentCaseException | TskCoreException ex) {
78  logger.log(Level.SEVERE, "Failed to get communications manager from case.", ex); //NON-NLS
79  return false;
80  }
81 
82  if(selectionInfo == null) {
83  return true;
84  }
85 
86  final Set<Content> relationshipSources;
87 
88  try {
89 
90  relationshipSources = communicationManager.getRelationshipSources(selectionInfo.getAccountDevicesInstances(), selectionInfo.getCommunicationsFilter());
91  for(Content content: relationshipSources) {
92  if( !(content instanceof BlackboardArtifact)){
93  continue;
94  }
95 
96  BlackboardArtifact bba = (BlackboardArtifact) content;
97  BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(bba.getArtifactTypeID());
98 
99  if (fromID != BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG
100  && fromID != BlackboardArtifact.ARTIFACT_TYPE.TSK_CALLLOG
101  && fromID != BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE) {
102  continue;
103  }
104 
105  // We want all artifacts that do not have "threadIDs" to appear as one thread in the UI
106  // To achive this assign any artifact that does not have a threadID
107  // the "UNTHREADED_ID"
108  String artifactThreadID = MessageNode.UNTHREADED_ID;
109  BlackboardAttribute attribute = bba.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_THREAD_ID));
110 
111  if(attribute != null) {
112  artifactThreadID = attribute.getValueString();
113  }
114 
115  if(threadIDs == null || threadIDs.contains(artifactThreadID)) {
116  list.add(bba);
117  }
118 
119  }
120 
121  } catch (TskCoreException ex) {
122  logger.log(Level.SEVERE, "Failed to get relationship sources.", ex); //NON-NLS
123  }
124 
125  return true;
126  }
127 
128  @Override
129  protected Node createNodeForKey(BlackboardArtifact key) {
130  return new MessageNode(key, null, null);
131  }
132 
133 }
void refresh(SelectionInfo selectionInfo, List< String > threadIDs)
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.