Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
RelationshipsNodeUtilities.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 
20 package org.sleuthkit.autopsy.communications.relationships;
21 
22 import java.util.List;
23 import java.util.TimeZone;
24 import java.util.concurrent.ExecutionException;
25 import java.util.logging.Level;
26 import org.openide.nodes.Node;
27 import org.openide.util.NbBundle;
33 import org.sleuthkit.datamodel.Account;
34 import org.sleuthkit.datamodel.BlackboardArtifact;
35 import org.sleuthkit.datamodel.BlackboardAttribute;
36 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME;
37 import static org.sleuthkit.datamodel.BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME;
38 import org.sleuthkit.datamodel.TimeUtilities;
39 import org.sleuthkit.datamodel.TskCoreException;
40 
45 final public class RelationshipsNodeUtilities {
46 
47  private static final Logger logger = Logger.getLogger(RelationshipsNodeUtilities.class.getName());
48  private static final BlackboardAttribute.Type NAME_ATTRIBUTE = new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(TSK_NAME.getTypeID()));
49 
50 
51  // Here to make codacy happy
53  }
54 
66  static String getAttributeDisplayString(final BlackboardArtifact artifact, final BlackboardAttribute.ATTRIBUTE_TYPE attributeType) {
67  try {
68  BlackboardAttribute attribute = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attributeType.getTypeID())));
69  if (attribute == null) {
70  return "";
71  } else if (attributeType.getValueType() == DATETIME) {
72  return TimeUtilities.epochToTime(attribute.getValueLong(),
73  TimeZone.getTimeZone(Utils.getUserPreferredZoneId()));
74  } else {
75  return attribute.getDisplayString();
76  }
77  } catch (TskCoreException tskCoreException) {
78  logger.log(Level.WARNING, "Error getting attribute value.", tskCoreException); //NON-NLS
79  return "";
80  }
81  }
82 
83  @NbBundle.Messages({
84  "# {0} - Contact Name",
85  "# {1} - Persona Name",
86  "RelationshipsNodeUtilities_Tooltip_Template=Contact: {0} - Persona: {1}",
87  "# {0} - PersonaAccount count",
88  "RelationshipsNodeUtilities_Tooltip_suffix=(1 of {0})"
89  })
90  static public String getAccoutToolTipText(String displayName, Account account) {
91  if(account == null) {
92  return displayName;
93  }
94 
95  List<PersonaAccount> personaList;
96  List<BlackboardArtifact> contactArtifactList;
97  try {
98  personaList = CVTPersonaCache.getPersonaAccounts(account);
99  contactArtifactList = ContactCache.getContacts(account);
100  } catch (ExecutionException ex) {
101  logger.log(Level.WARNING, "Failed to retrieve Persona details for node.", ex);
102  return displayName;
103  }
104 
105  String personaName;
106  if (personaList != null && !personaList.isEmpty()) {
107  personaName = personaList.get(0).getPersona().getName();
108  if (personaList.size() > 1) {
109  personaName += Bundle.RelationshipsNodeUtilities_Tooltip_suffix(Integer.toString(personaList.size()));
110  }
111  } else {
112  personaName = "None";
113  }
114 
115  String contactName = displayName;
116  if (contactArtifactList != null && !contactArtifactList.isEmpty()) {
117  try {
118  BlackboardArtifact contactArtifact = contactArtifactList.get(0);
119  BlackboardAttribute attribute = contactArtifact.getAttribute(NAME_ATTRIBUTE);
120  if (attribute != null) {
121  contactName = attribute.getValueString();
122  }
123  } catch (TskCoreException ex) {
124  logger.log(Level.WARNING, "Failed to retrive name attribute from contact artifact.", ex);
125  }
126  }
127 
128  return Bundle.RelationshipsNodeUtilities_Tooltip_Template(contactName, personaName);
129  }
130 
131 }
static synchronized List< PersonaAccount > getPersonaAccounts(Account account)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static synchronized List< BlackboardArtifact > getContacts(Account account)

Copyright © 2012-2022 Basis Technology. Generated on: Thu Sep 29 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.