Autopsy  4.15.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AccountDeviceInstanceNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2017-18 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;
20 
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.List;
24 import java.util.concurrent.ExecutionException;
25 import java.util.logging.Level;
26 import javax.swing.Action;
27 import org.openide.nodes.AbstractNode;
28 import org.openide.nodes.Children;
29 import org.openide.nodes.Sheet;
30 import org.openide.util.NbBundle;
31 import org.openide.util.NbBundle.Messages;
32 import org.openide.util.lookup.Lookups;
36 import org.sleuthkit.datamodel.Account;
37 import org.sleuthkit.datamodel.AccountDeviceInstance;
38 import org.sleuthkit.datamodel.CommunicationsFilter;
39 import org.sleuthkit.datamodel.CommunicationsManager;
40 
44 final class AccountDeviceInstanceNode extends AbstractNode {
45 
46  private static final Logger logger = Logger.getLogger(AccountDeviceInstanceNode.class.getName());
47 
48  private final AccountDeviceInstanceKey accountDeviceInstanceKey;
49  private final CommunicationsManager commsManager;
50  private final Account account;
51 
52  AccountDeviceInstanceNode(AccountDeviceInstanceKey accountDeviceInstanceKey, CommunicationsManager commsManager) {
53  super(Children.LEAF, Lookups.fixed(accountDeviceInstanceKey, commsManager));
54  this.accountDeviceInstanceKey = accountDeviceInstanceKey;
55  this.commsManager = commsManager;
56  this.account = accountDeviceInstanceKey.getAccountDeviceInstance().getAccount();
57  setName(account.getTypeSpecificID());
58  setDisplayName(getName());
59  String iconPath = Utils.getIconFilePath(account.getAccountType());
60  this.setIconBaseWithExtension(iconPath != null && iconPath.charAt(0) == '/' ? iconPath.substring(1) : iconPath);
61  }
62 
63  AccountDeviceInstance getAccountDeviceInstance() {
64  return accountDeviceInstanceKey.getAccountDeviceInstance();
65  }
66 
67  AccountDeviceInstanceKey getAccountDeviceInstanceKey() {
68  return accountDeviceInstanceKey;
69  }
70 
71  CommunicationsManager getCommsManager() {
72  return commsManager;
73  }
74 
75  long getMessageCount() {
76  return accountDeviceInstanceKey.getMessageCount();
77  }
78 
79  CommunicationsFilter getFilter() {
80  return accountDeviceInstanceKey.getCommunicationsFilter();
81  }
82 
83  @Override
84  @NbBundle.Messages(value = {"AccountNode.device=Device", "AccountNode.accountName=Account", "AccountNode.accountType=Type", "AccountNode.messageCount=Items"})
85  protected Sheet createSheet() {
86  Sheet sheet = super.createSheet();
87  Sheet.Set properties = sheet.get(Sheet.PROPERTIES);
88  if (properties == null) {
89  properties = Sheet.createPropertiesSet();
90  sheet.put(properties);
91  }
92  properties.put(new NodeProperty<>("type",
93  Bundle.AccountNode_accountType(),
94  "type",
95  account.getAccountType().getDisplayName())); // NON-NLS
96  properties.put(new NodeProperty<>("count",
97  Bundle.AccountNode_messageCount(),
98  "count",
99  accountDeviceInstanceKey.getMessageCount())); // NON-NLS
100  properties.put(new NodeProperty<>("device",
101  Bundle.AccountNode_device(),
102  "device",
103  accountDeviceInstanceKey.getDataSourceName())); // NON-NLS
104  return sheet;
105  }
106 
107  @Override
108  public Action[] getActions(boolean context) {
109  ArrayList<Action> actions = new ArrayList<>(Arrays.asList(super.getActions(context)));
110  actions.add(PinAccountsAction.getInstance());
111  actions.add(ResetAndPinAccountsAction.getInstance());
112  return actions.toArray(new Action[actions.size()]);
113  }
114 
115  @Messages({
116  "# {0} - Contact Name",
117  "# {1} - Persona Name",
118  "AccountInstanceNode_Tooltip_Template=Contact: {0} - Persona: {1}",
119  "# {0} - PersonaAccount count",
120  "AccountInstanceNode_Tooltip_suffix=(1 of {0})"
121  })
122  @Override
123  public String getShortDescription() {
124  List<PersonaAccount> personaList;
125  try {
126  personaList = CVTPersonaCache.getPersonaAccounts(account);
127  } catch (ExecutionException ex) {
128  logger.log(Level.WARNING, "Failed to retrieve Persona details for node.", ex);
129  return getDisplayName();
130  }
131 
132  String personaName;
133  if (!personaList.isEmpty()) {
134  personaName = personaList.get(0).getPersona().getName();
135  if (personaList.size() > 1) {
136  personaName += Bundle.AccountInstanceNode_Tooltip_suffix(Integer.toString(personaList.size()));
137  }
138  } else {
139  personaName = "None";
140  }
141 
142  return Bundle.AccountInstanceNode_Tooltip_Template(getDisplayName(), personaName);
143  }
144 }

Copyright © 2012-2020 Basis Technology. Generated on: Mon Jul 6 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.