Autopsy  4.19.3
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 javax.swing.Action;
24 import org.openide.nodes.AbstractNode;
25 import org.openide.nodes.Children;
26 import org.openide.nodes.Sheet;
27 import org.openide.util.NbBundle;
28 import org.openide.util.lookup.Lookups;
32 import org.sleuthkit.datamodel.Account;
33 import org.sleuthkit.datamodel.AccountDeviceInstance;
34 import org.sleuthkit.datamodel.BlackboardAttribute;
35 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME;
36 import org.sleuthkit.datamodel.CommunicationsFilter;
37 import org.sleuthkit.datamodel.CommunicationsManager;
38 
42 final class AccountDeviceInstanceNode extends AbstractNode {
43 
44  private static final Logger logger = Logger.getLogger(AccountDeviceInstanceNode.class.getName());
45 
46  private final AccountDeviceInstanceKey accountDeviceInstanceKey;
47  private final CommunicationsManager commsManager;
48  private final Account account;
49 
50  private static final BlackboardAttribute.Type NAME_ATTRIBUTE = new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(TSK_NAME.getTypeID()));
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<>();
110  actions.add(PinAccountsAction.getInstance());
111  actions.add(ResetAndPinAccountsAction.getInstance());
112  actions.add(null);
113  actions.addAll(Arrays.asList(super.getActions(context)));
114  return actions.toArray(new Action[actions.size()]);
115  }
116 
117  @Override
118  public String getShortDescription() {
119  return RelationshipsNodeUtilities.getAccoutToolTipText(getDisplayName(), account);
120  }
121 }

Copyright © 2012-2022 Basis Technology. Generated on: Tue Jun 27 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.