Autopsy  4.13.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
Waypoint.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 package org.sleuthkit.autopsy.geolocation.datamodel;
20 
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.HashMap;
24 import java.util.HashSet;
25 import java.util.List;
26 import java.util.Map;
27 import java.util.Set;
28 import org.sleuthkit.datamodel.AbstractFile;
29 import org.sleuthkit.datamodel.BlackboardArtifact;
30 import org.sleuthkit.datamodel.BlackboardAttribute;
31 import org.sleuthkit.datamodel.TskCoreException;
32 
37 public class Waypoint {
38 
39  final private Long timestamp;
40  final private Double longitude;
41  final private Double latitude;
42  final private Double altitude;
43  final private String label;
44  final private AbstractFile image;
45  final private BlackboardArtifact artifact;
46  final private Route route;
47 
48  // This list is not expected to change after construction. The
49  // constructor will take care of making an unmodifiable List
51 
56  static final private BlackboardAttribute.ATTRIBUTE_TYPE[] ALREADY_HANDLED_ATTRIBUTES = {
57  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME,
58  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE,
59  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE,
60  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE,
61  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME,
62  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED,
63  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_START,
64  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_START,
65  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_END,
66  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_END,};
67 
83  Waypoint(BlackboardArtifact artifact, String label, Long timestamp, Double latitude, Double longitude, Double altitude, AbstractFile image, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap, Route route) throws GeoLocationDataException {
84  if (longitude == null || latitude == null) {
85  throw new GeoLocationDataException("Invalid waypoint, null value passed for longitude or latitude");
86  }
87 
88  this.artifact = artifact;
89  this.label = label;
90  this.image = image;
91  this.timestamp = timestamp;
92  this.longitude = longitude;
93  this.latitude = latitude;
94  this.altitude = altitude;
95  this.route = null;
96 
97  immutablePropertiesList = Collections.unmodifiableList(createGeolocationProperties(attributeMap));
98  }
99 
105  public BlackboardArtifact getArtifact() {
106  return artifact;
107  }
108 
117  public Long getTimestamp() {
118  return timestamp;
119  }
120 
126  public String getLabel() {
127  return label;
128  }
129 
135  public Double getLatitude() {
136  return latitude;
137  }
138 
144  public Double getLongitude() {
145  return longitude;
146  }
147 
153  public Double getAltitude() {
154  return altitude;
155  }
156 
162  public AbstractFile getImage() {
163  return image;
164  }
165 
175  }
176 
183  public Route getRoute() {
184  return route;
185  }
186 
195  private static String getLabelFromArtifact(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) {
196  BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME);
197  if (attribute != null) {
198  return attribute.getDisplayString();
199  }
200 
201  return "";
202  }
203 
215  static Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> getAttributesFromArtifactAsMap(BlackboardArtifact artifact) throws GeoLocationDataException {
216  Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap = new HashMap<>();
217  try {
218  List<BlackboardAttribute> attributeList = artifact.getAttributes();
219  for (BlackboardAttribute attribute : attributeList) {
220  BlackboardAttribute.ATTRIBUTE_TYPE type = BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attribute.getAttributeType().getTypeID());
221  attributeMap.put(type, attribute);
222  }
223  } catch (TskCoreException ex) {
224  throw new GeoLocationDataException("Unable to get attributes from artifact", ex);
225  }
226 
227  return attributeMap;
228  }
229 
241  static public List<Waypoint.Property> createGeolocationProperties(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
242  List<Waypoint.Property> list = new ArrayList<>();
243 
244  Set<BlackboardAttribute.ATTRIBUTE_TYPE> keys = new HashSet<>(attributeMap.keySet());
245 
246  for (BlackboardAttribute.ATTRIBUTE_TYPE type : ALREADY_HANDLED_ATTRIBUTES) {
247  keys.remove(type);
248  }
249 
250  for (BlackboardAttribute.ATTRIBUTE_TYPE type : keys) {
251  String key = type.getDisplayName();
252  String value = attributeMap.get(type).getDisplayString();
253 
254  list.add(new Waypoint.Property(key, value));
255  }
256  return list;
257  }
258 
263  public static final class Property {
264 
265  private final String displayName;
266  private final String value;
267 
275  private Property(String displayName, String value) {
276  this.displayName = displayName;
277  this.value = value;
278  }
279 
285  public String getDisplayName() {
286  return displayName;
287  }
288 
294  public String getValue() {
295  return value;
296  }
297  }
298 }
static String getLabelFromArtifact(Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Waypoint.java:195
static final BlackboardAttribute.ATTRIBUTE_TYPE[] ALREADY_HANDLED_ATTRIBUTES
Definition: Waypoint.java:56
static List< Waypoint.Property > createGeolocationProperties(Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Waypoint.java:241
final List< Waypoint.Property > immutablePropertiesList
Definition: Waypoint.java:50

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