Autopsy  4.16.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
UserActivityPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2020 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.datasourcesummary.ui;
20 
21 import java.awt.Component;
22 import java.text.DateFormat;
23 import java.text.SimpleDateFormat;
24 import java.util.Arrays;
25 import java.util.Date;
26 import java.util.List;
27 import java.util.Locale;
28 import org.apache.commons.lang.StringUtils;
29 import org.openide.util.NbBundle.Messages;
43 import org.sleuthkit.datamodel.DataSource;
44 
48 @Messages({
49  "UserActivityPanel_tab_title=User Activity",
50  "UserActivityPanel_TopProgramsTableModel_name_header=Program",
51  "UserActivityPanel_TopProgramsTableModel_folder_header=Folder",
52  "UserActivityPanel_TopProgramsTableModel_count_header=Run Times",
53  "UserActivityPanel_TopProgramsTableModel_lastrun_header=Last Run",
54  "UserActivityPanel_TopDomainsTableModel_domain_header=Domain",
55  "UserActivityPanel_TopDomainsTableModel_count_header=Visits",
56  "UserActivityPanel_TopDomainsTableModel_lastAccess_header=Last Accessed",
57  "UserActivityPanel_TopWebSearchTableModel_searchString_header=Search String",
58  "UserActivityPanel_TopWebSearchTableModel_dateAccessed_header=Date Accessed",
59  "UserActivityPanel_TopWebSearchTableModel_translatedResult_header=Translated",
60  "UserActivityPanel_TopDeviceAttachedTableModel_deviceId_header=Device Id",
61  "UserActivityPanel_TopDeviceAttachedTableModel_makeModel_header=Make and Model",
62  "UserActivityPanel_TopDeviceAttachedTableModel_dateAccessed_header=Last Accessed",
63  "UserActivityPanel_TopAccountTableModel_accountType_header=Account Type",
64  "UserActivityPanel_TopAccountTableModel_lastAccess_header=Last Accessed",
65  "UserActivityPanel_noDataExists=No communication data exists"})
66 public class UserActivityPanel extends BaseDataSourceSummaryPanel {
67 
68  private static final long serialVersionUID = 1L;
69  private static final DateFormat DATETIME_FORMAT = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.getDefault());
70  private static final int TOP_PROGS_COUNT = 10;
71  private static final int TOP_DOMAINS_COUNT = 10;
72  private static final int TOP_SEARCHES_COUNT = 10;
73  private static final int TOP_ACCOUNTS_COUNT = 5;
74  private static final int TOP_DEVICES_COUNT = 10;
75  private static final String ANDROID_FACTORY = "org.python.proxies.module$AndroidModuleFactory";
76  private static final String ANDROID_MODULE_NAME = "Android Analyzer";
77 
85  private static String getFormatted(Date date) {
86  return date == null ? "" : DATETIME_FORMAT.format(date);
87  }
88 
89  // set up recent programs table
90  private final JTablePanel<TopProgramsResult> topProgramsTable = JTablePanel.getJTablePanel(Arrays.asList(
91  // program name column
93  Bundle.UserActivityPanel_TopProgramsTableModel_name_header(),
94  (prog) -> {
95  return new DefaultCellModel(prog.getProgramName())
96  .setTooltip(prog.getProgramPath());
97  },
98  250),
99  // program folder column
100  new ColumnModel<>(
101  Bundle.UserActivityPanel_TopProgramsTableModel_folder_header(),
102  (prog) -> {
103  return new DefaultCellModel(
104  getShortFolderName(
105  prog.getProgramPath(),
106  prog.getProgramName()))
107  .setTooltip(prog.getProgramPath());
108  },
109  150),
110  // run count column
111  new ColumnModel<>(
112  Bundle.UserActivityPanel_TopProgramsTableModel_count_header(),
113  (prog) -> {
114  String runTimes = prog.getRunTimes() == null ? "" : Long.toString(prog.getRunTimes());
115  return new DefaultCellModel(runTimes);
116  },
117  80),
118  // last run date column
119  new ColumnModel<>(
120  Bundle.UserActivityPanel_TopProgramsTableModel_lastrun_header(),
121  (prog) -> new DefaultCellModel(getFormatted(prog.getLastRun())),
122  150)
123  ))
124  .setKeyFunction((prog) -> prog.getProgramPath() + ":" + prog.getProgramName());
125 
126  // set up recent domains table
127  private final JTablePanel<TopDomainsResult> recentDomainsTable = JTablePanel.getJTablePanel(Arrays.asList(
128  // domain column
130  Bundle.UserActivityPanel_TopDomainsTableModel_domain_header(),
131  (recentDomain) -> new DefaultCellModel(recentDomain.getDomain()),
132  250),
133  // count column
134  new ColumnModel<>(
135  Bundle.UserActivityPanel_TopDomainsTableModel_count_header(),
136  (recentDomain) -> {
137  String visitTimes = recentDomain.getVisitTimes() == null ? "" : Long.toString(recentDomain.getVisitTimes());
138  return new DefaultCellModel(visitTimes);
139  },
140  100),
141  // last accessed column
142  new ColumnModel<>(
143  Bundle.UserActivityPanel_TopDomainsTableModel_lastAccess_header(),
144  (recentDomain) -> new DefaultCellModel(getFormatted(recentDomain.getLastVisit())),
145  150)
146  ))
147  .setKeyFunction((domain) -> domain.getDomain());
148 
149  // top web searches table
150  private final JTablePanel<TopWebSearchResult> topWebSearchesTable = JTablePanel.getJTablePanel(Arrays.asList(
151  // search string column
153  Bundle.UserActivityPanel_TopWebSearchTableModel_searchString_header(),
154  (webSearch) -> new DefaultCellModel(webSearch.getSearchString()),
155  250
156  ),
157  // last accessed
158  new ColumnModel<>(
159  Bundle.UserActivityPanel_TopWebSearchTableModel_dateAccessed_header(),
160  (webSearch) -> new DefaultCellModel(getFormatted(webSearch.getDateAccessed())),
161  150
162  ),
163  // translated value
164  new ColumnModel<>(
165  Bundle.UserActivityPanel_TopWebSearchTableModel_translatedResult_header(),
166  (webSearch) -> new DefaultCellModel(webSearch.getTranslatedResult()),
167  250
168  )
169  ))
170  .setKeyFunction((query) -> query.getSearchString());
171 
172  // top devices attached table
173  private final JTablePanel<TopDeviceAttachedResult> topDevicesAttachedTable = JTablePanel.getJTablePanel(Arrays.asList(
174  // device id column
176  Bundle.UserActivityPanel_TopDeviceAttachedTableModel_deviceId_header(),
177  (device) -> new DefaultCellModel(device.getDeviceId()),
178  250
179  ),
180  // last accessed
181  new ColumnModel<>(
182  Bundle.UserActivityPanel_TopDeviceAttachedTableModel_dateAccessed_header(),
183  (device) -> new DefaultCellModel(getFormatted(device.getDateAccessed())),
184  150
185  ),
186  // make and model
187  new ColumnModel<>(
188  Bundle.UserActivityPanel_TopDeviceAttachedTableModel_makeModel_header(),
189  (device) -> {
190  String make = StringUtils.isBlank(device.getDeviceMake()) ? "" : device.getDeviceMake().trim();
191  String model = StringUtils.isBlank(device.getDeviceModel()) ? "" : device.getDeviceModel().trim();
192  String makeModelString = (make.isEmpty() || model.isEmpty())
193  ? make + model
194  : String.format("%s - %s", make, model);
195  return new DefaultCellModel(makeModelString);
196  },
197  250
198  )
199  ))
200  .setKeyFunction((topDevice) -> topDevice.getDeviceId());
201 
202  // top accounts table
203  private final JTablePanel<TopAccountResult> topAccountsTable = JTablePanel.getJTablePanel(Arrays.asList(
204  // account type column
206  Bundle.UserActivityPanel_TopAccountTableModel_accountType_header(),
207  (account) -> new DefaultCellModel(account.getAccountType()),
208  250
209  ),
210  // last accessed
211  new ColumnModel<>(
212  Bundle.UserActivityPanel_TopAccountTableModel_lastAccess_header(),
213  (account) -> new DefaultCellModel(getFormatted(account.getLastAccess())),
214  150
215  )
216  ))
217  .setKeyFunction((topAccount) -> topAccount.getAccountType());
218 
219  private final List<JTablePanel<?>> tables = Arrays.asList(
220  topProgramsTable,
221  recentDomainsTable,
222  topWebSearchesTable,
223  topDevicesAttachedTable,
224  topAccountsTable
225  );
226 
227  private final IngestRunningLabel ingestRunningLabel = new IngestRunningLabel();
228 
229  private final List<DataFetchComponents<DataSource, ?>> dataFetchComponents;
231 
235  public UserActivityPanel() {
236  this(new TopProgramsSummary(), new UserActivitySummary());
237  }
238 
247  TopProgramsSummary topProgramsData,
248  UserActivitySummary userActivityData) {
249 
250  super(topProgramsData, userActivityData);
251 
252  this.topProgramsData = topProgramsData;
253 
254  // set up data acquisition methods
255  this.dataFetchComponents = Arrays.asList(
256  // top programs query
257  new DataFetchComponents<DataSource, List<TopProgramsResult>>(
258  (dataSource) -> topProgramsData.getTopPrograms(dataSource, TOP_PROGS_COUNT),
259  (result) -> {
260  showResultWithModuleCheck(topProgramsTable, result,
263  }),
264  // top domains query
265  new DataFetchComponents<DataSource, List<TopDomainsResult>>(
266  (dataSource) -> userActivityData.getRecentDomains(dataSource, TOP_DOMAINS_COUNT),
267  (result) -> {
268  showResultWithModuleCheck(recentDomainsTable, result,
271  }),
272  // top web searches query
273  new DataFetchComponents<DataSource, List<TopWebSearchResult>>(
274  (dataSource) -> userActivityData.getMostRecentWebSearches(dataSource, TOP_SEARCHES_COUNT),
275  (result) -> {
276  showResultWithModuleCheck(topWebSearchesTable, result,
279  }),
280  // top devices query
281  new DataFetchComponents<DataSource, List<TopDeviceAttachedResult>>(
282  (dataSource) -> userActivityData.getRecentDevices(dataSource, TOP_DEVICES_COUNT),
283  (result) -> {
284  showResultWithModuleCheck(topDevicesAttachedTable, result,
287  }),
288  // top accounts query
289  new DataFetchComponents<DataSource, List<TopAccountResult>>(
290  (dataSource) -> userActivityData.getRecentAccounts(dataSource, TOP_ACCOUNTS_COUNT),
291  (result) -> {
292  showResultWithModuleCheck(topAccountsTable, result,
293  ANDROID_FACTORY,
294  ANDROID_MODULE_NAME);
295  })
296  );
297 
298  initComponents();
299  }
300 
309  private String getShortFolderName(String path, String appName) {
310  return this.topProgramsData.getShortFolderName(path, appName);
311  }
312 
313  @Override
314  protected void fetchInformation(DataSource dataSource) {
315  fetchInformation(dataFetchComponents, dataSource);
316  }
317 
318  @Override
319  protected void onNewDataSource(DataSource dataSource) {
320  onNewDataSource(dataFetchComponents, tables, dataSource);
321  }
322 
323  @Override
324  public void close() {
325  ingestRunningLabel.unregister();
326  super.close();
327  }
328 
334  @SuppressWarnings("unchecked")
335  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
336  private void initComponents() {
337 
338  javax.swing.JScrollPane contentScrollPane = new javax.swing.JScrollPane();
339  javax.swing.JPanel contentPanel = new javax.swing.JPanel();
340  javax.swing.JPanel ingestRunningPanel = ingestRunningLabel;
341  javax.swing.JLabel programsRunLabel = new javax.swing.JLabel();
342  javax.swing.Box.Filler filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2));
343  javax.swing.JPanel topProgramsTablePanel = topProgramsTable;
344  javax.swing.Box.Filler filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20));
345  javax.swing.JLabel recentDomainsLabel = new javax.swing.JLabel();
346  javax.swing.Box.Filler filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2));
347  javax.swing.JPanel recentDomainsTablePanel = recentDomainsTable;
348  javax.swing.Box.Filler filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20));
349  javax.swing.JLabel topWebSearchLabel = new javax.swing.JLabel();
350  javax.swing.Box.Filler filler5 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2));
351  javax.swing.JPanel topWebSearches = topWebSearchesTable;
352  javax.swing.Box.Filler filler6 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20));
353  javax.swing.JLabel topDevicesAttachedLabel = new javax.swing.JLabel();
354  javax.swing.Box.Filler filler7 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2));
355  javax.swing.JPanel recentDevicesAttached = topDevicesAttachedTable;
356  javax.swing.Box.Filler filler8 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20));
357  javax.swing.JLabel recentAccountsLabel = new javax.swing.JLabel();
358  javax.swing.Box.Filler filler9 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2));
359  javax.swing.JPanel topAccounts = topAccountsTable;
360 
361  setLayout(new java.awt.BorderLayout());
362 
363  contentScrollPane.setMaximumSize(null);
364  contentScrollPane.setMinimumSize(null);
365 
366  contentPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
367  contentPanel.setMaximumSize(new java.awt.Dimension(32767, 450));
368  contentPanel.setMinimumSize(new java.awt.Dimension(10, 450));
369  contentPanel.setLayout(new javax.swing.BoxLayout(contentPanel, javax.swing.BoxLayout.PAGE_AXIS));
370 
371  ingestRunningPanel.setAlignmentX(0.0F);
372  ingestRunningPanel.setMaximumSize(new java.awt.Dimension(32767, 25));
373  ingestRunningPanel.setMinimumSize(new java.awt.Dimension(10, 25));
374  ingestRunningPanel.setPreferredSize(new java.awt.Dimension(10, 25));
375  contentPanel.add(ingestRunningPanel);
376 
377  programsRunLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
378  org.openide.awt.Mnemonics.setLocalizedText(programsRunLabel, org.openide.util.NbBundle.getMessage(UserActivityPanel.class, "UserActivityPanel.programsRunLabel.text")); // NOI18N
379  programsRunLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
380  contentPanel.add(programsRunLabel);
381  contentPanel.add(filler1);
382 
383  topProgramsTablePanel.setAlignmentX(0.0F);
384  topProgramsTablePanel.setMaximumSize(new java.awt.Dimension(32767, 106));
385  topProgramsTablePanel.setMinimumSize(new java.awt.Dimension(10, 106));
386  topProgramsTablePanel.setPreferredSize(new java.awt.Dimension(10, 106));
387  contentPanel.add(topProgramsTablePanel);
388  contentPanel.add(filler3);
389 
390  recentDomainsLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
391  org.openide.awt.Mnemonics.setLocalizedText(recentDomainsLabel, org.openide.util.NbBundle.getMessage(UserActivityPanel.class, "UserActivityPanel.recentDomainsLabel.text")); // NOI18N
392  contentPanel.add(recentDomainsLabel);
393  contentPanel.add(filler2);
394 
395  recentDomainsTablePanel.setAlignmentX(0.0F);
396  recentDomainsTablePanel.setMaximumSize(new java.awt.Dimension(32767, 106));
397  recentDomainsTablePanel.setMinimumSize(new java.awt.Dimension(10, 106));
398  recentDomainsTablePanel.setPreferredSize(new java.awt.Dimension(10, 106));
399  contentPanel.add(recentDomainsTablePanel);
400  contentPanel.add(filler4);
401 
402  topWebSearchLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
403  org.openide.awt.Mnemonics.setLocalizedText(topWebSearchLabel, org.openide.util.NbBundle.getMessage(UserActivityPanel.class, "UserActivityPanel.topWebSearchLabel.text")); // NOI18N
404  contentPanel.add(topWebSearchLabel);
405  contentPanel.add(filler5);
406 
407  topWebSearches.setAlignmentX(0.0F);
408  topWebSearches.setMaximumSize(new java.awt.Dimension(32767, 106));
409  topWebSearches.setMinimumSize(new java.awt.Dimension(10, 106));
410  topWebSearches.setPreferredSize(new java.awt.Dimension(10, 106));
411  contentPanel.add(topWebSearches);
412  contentPanel.add(filler6);
413 
414  topDevicesAttachedLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
415  org.openide.awt.Mnemonics.setLocalizedText(topDevicesAttachedLabel, org.openide.util.NbBundle.getMessage(UserActivityPanel.class, "UserActivityPanel.topDevicesAttachedLabel.text")); // NOI18N
416  contentPanel.add(topDevicesAttachedLabel);
417  contentPanel.add(filler7);
418 
419  recentDevicesAttached.setAlignmentX(0.0F);
420  recentDevicesAttached.setMaximumSize(new java.awt.Dimension(32767, 106));
421  recentDevicesAttached.setMinimumSize(new java.awt.Dimension(10, 106));
422  recentDevicesAttached.setPreferredSize(new java.awt.Dimension(10, 106));
423  contentPanel.add(recentDevicesAttached);
424  contentPanel.add(filler8);
425 
426  recentAccountsLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
427  org.openide.awt.Mnemonics.setLocalizedText(recentAccountsLabel, org.openide.util.NbBundle.getMessage(UserActivityPanel.class, "UserActivityPanel.recentAccountsLabel.text")); // NOI18N
428  contentPanel.add(recentAccountsLabel);
429  contentPanel.add(filler9);
430 
431  topAccounts.setAlignmentX(0.0F);
432  topAccounts.setMaximumSize(new java.awt.Dimension(32767, 106));
433  topAccounts.setMinimumSize(new java.awt.Dimension(10, 106));
434  topAccounts.setPreferredSize(new java.awt.Dimension(10, 106));
435  contentPanel.add(topAccounts);
436 
437  contentScrollPane.setViewportView(contentPanel);
438 
439  add(contentScrollPane, java.awt.BorderLayout.CENTER);
440  }// </editor-fold>//GEN-END:initComponents
441 
442  // Variables declaration - do not modify//GEN-BEGIN:variables
443  // End of variables declaration//GEN-END:variables
444 }
final List< DataFetchComponents< DataSource,?> > dataFetchComponents
List< TopAccountResult > getRecentAccounts(DataSource dataSource, int count)
List< TopWebSearchResult > getMostRecentWebSearches(DataSource dataSource, int count)
List< TopDeviceAttachedResult > getRecentDevices(DataSource dataSource, int count)
UserActivityPanel(TopProgramsSummary topProgramsData, UserActivitySummary userActivityData)
List< TopProgramsResult > getTopPrograms(DataSource dataSource, int count)
static< T > JTablePanel< T > getJTablePanel(List< ColumnModel< T >> columns)
List< TopDomainsResult > getRecentDomains(DataSource dataSource, int count)
String getShortFolderName(String strPath, String applicationName)

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