Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AbstractWaypointFetcher.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2019-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.geolocation;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 import java.util.Set;
24 import java.util.logging.Level;
31 import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
32 
36 abstract class AbstractWaypointFetcher implements WaypointBuilder.WaypointFilterQueryCallBack {
37 
38  private static final Logger logger = Logger.getLogger(AbstractWaypointFetcher.class.getName());
39 
40  private final GeoFilterPanel.GeoFilter filters;
41 
47  AbstractWaypointFetcher(GeoFilterPanel.GeoFilter filters) {
48  this.filters = filters;
49  }
50 
60  void getWaypoints() throws GeoLocationDataException {
61  Case currentCase = Case.getCurrentCase();
63  filters.getDataSources(),
64  filters.getArtifactTypes(),
65  filters.showAllWaypoints(),
66  filters.getMostRecentNumDays(),
67  filters.showWaypointsWithoutTimeStamp(),
68  this);
69 
70  }
71 
78  abstract void handleFilteredWaypointSet(Set<MapWaypoint> mapWaypoints);
79 
80  @Override
81  public void process(List<Waypoint> waypoints) {
82  List<Track> tracks = null;
83  if (filters.getArtifactTypes().contains(ARTIFACT_TYPE.TSK_GPS_TRACK)) {
84  try {
85  tracks = Track.getTracks(Case.getCurrentCase().getSleuthkitCase(), filters.getDataSources());
86  } catch (GeoLocationDataException ex) {
87  logger.log(Level.WARNING, "Exception thrown while retrieving list of Tracks", ex);
88  }
89  }
90 
91  List<Waypoint> completeList = createWaypointList(waypoints, tracks);
92  final Set<MapWaypoint> pointSet = MapWaypoint.getWaypoints(completeList);
93 
94  handleFilteredWaypointSet(pointSet);
95  }
96 
107  private List<Waypoint> createWaypointList(List<Waypoint> waypoints, List<Track> tracks) {
108  final List<Waypoint> completeList = new ArrayList<>();
109 
110  if (tracks != null) {
111  Long timeRangeEnd;
112  Long timeRangeStart;
113  if (!filters.showAllWaypoints()) {
114  // Figure out what the most recent time is given the filtered
115  // waypoints and the tracks.
116  timeRangeEnd = getMostRecent(waypoints, tracks);
117  timeRangeStart = timeRangeEnd - (86400 * filters.getMostRecentNumDays());
118 
119  completeList.addAll(getWaypointsInRange(timeRangeStart, timeRangeEnd, waypoints));
120  completeList.addAll(getTracksInRange(timeRangeStart, timeRangeEnd, tracks));
121 
122  } else {
123  completeList.addAll(waypoints);
124  for (Track track : tracks) {
125  completeList.addAll(track.getPath());
126  }
127  }
128  } else {
129  completeList.addAll(waypoints);
130  }
131 
132  return completeList;
133  }
134 
144  private List<Waypoint> getWaypointsInRange(Long timeRangeStart, Long timeRangeEnd, List<Waypoint> waypoints) {
145  List<Waypoint> completeList = new ArrayList<>();
146  // Add all of the waypoints that fix into the time range.
147  if (waypoints != null) {
148  for (Waypoint point : waypoints) {
149  Long time = point.getTimestamp();
150  if ((time == null && filters.showWaypointsWithoutTimeStamp())
151  || (time != null && (time >= timeRangeStart && time <= timeRangeEnd))) {
152 
153  completeList.add(point);
154  }
155  }
156  }
157  return completeList;
158  }
159 
172  private List<Waypoint> getTracksInRange(Long timeRangeStart, Long timeRangeEnd, List<Track> tracks) {
173  List<Waypoint> completeList = new ArrayList<>();
174  if (tracks != null) {
175  for (Track track : tracks) {
176  Long trackTime = track.getStartTime();
177 
178  if ((trackTime == null && filters.showWaypointsWithoutTimeStamp())
179  || (trackTime != null && (trackTime >= timeRangeStart && trackTime <= timeRangeEnd))) {
180 
181  completeList.addAll(track.getPath());
182  }
183  }
184  }
185  return completeList;
186  }
187 
195  private Long findMostRecentTimestamp(List<Waypoint> points) {
196 
197  Long mostRecent = null;
198 
199  for (Waypoint point : points) {
200  if (mostRecent == null) {
201  mostRecent = point.getTimestamp();
202  } else {
203  mostRecent = Math.max(mostRecent, point.getTimestamp());
204  }
205  }
206 
207  return mostRecent;
208  }
209 
217  private Long findMostRecentTracks(List<Track> tracks) {
218  Long mostRecent = null;
219 
220  for (Track track : tracks) {
221  if (mostRecent == null) {
222  mostRecent = track.getStartTime();
223  } else if (track.getStartTime() != null) {
224  mostRecent = Math.max(mostRecent, track.getStartTime());
225  }
226  }
227 
228  return mostRecent;
229  }
230 
240  private Long getMostRecent(List<Waypoint> points, List<Track> tracks) {
241  Long waypointMostRecent = findMostRecentTimestamp(points);
242  Long trackMostRecent = findMostRecentTracks(tracks);
243 
244  if (waypointMostRecent != null && trackMostRecent != null) {
245  return Math.max(waypointMostRecent, trackMostRecent);
246  } else if (waypointMostRecent == null && trackMostRecent != null) {
247  return trackMostRecent;
248  } else if (waypointMostRecent != null && trackMostRecent == null) {
249  return waypointMostRecent;
250  }
251 
252  return null;
253  }
254 }
static List< Track > getTracks(SleuthkitCase skCase, List<?extends Content > sourceList)
Definition: GeoPath.java:77
static List< Waypoint > getAllWaypoints(SleuthkitCase skCase)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

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