Autopsy  4.17.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-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.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 GeoPath parentGeoPath;
47 
48  final private List<Waypoint.Property> propertiesList;
49 
54  static final BlackboardAttribute.ATTRIBUTE_TYPE[] ALREADY_HANDLED_ATTRIBUTES = {
55  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME,
56  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE,
57  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE,
58  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE,
59  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME,
60  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED,
61  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_START,
62  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_START,
63  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_END,
64  BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_END,};
65 
81  Waypoint(BlackboardArtifact artifact, String label, Long timestamp, Double latitude, Double longitude, Double altitude, AbstractFile image, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap, GeoPath parentGeoPath) throws GeoLocationDataException {
82  if (longitude == null || latitude == null) {
83  throw new GeoLocationDataException("Invalid waypoint, null value passed for longitude or latitude");
84  }
85 
86  this.artifact = artifact;
87  this.label = label;
88  this.image = image;
89  this.timestamp = timestamp;
90  this.longitude = longitude;
91  this.latitude = latitude;
92  this.altitude = altitude;
93  this.parentGeoPath = parentGeoPath;
94 
95  propertiesList = createGeolocationProperties(attributeMap);
96  }
97 
103  public BlackboardArtifact getArtifact() {
104  return artifact;
105  }
106 
115  public Long getTimestamp() {
116  return timestamp;
117  }
118 
124  public String getLabel() {
125  return label;
126  }
127 
133  public Double getLatitude() {
134  return latitude;
135  }
136 
142  public Double getLongitude() {
143  return longitude;
144  }
145 
151  public Double getAltitude() {
152  return altitude;
153  }
154 
160  public AbstractFile getImage() {
161  return image;
162  }
163 
172  return Collections.unmodifiableList(propertiesList);
173  }
174 
182  return parentGeoPath;
183  }
184 
196  static Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> getAttributesFromArtifactAsMap(BlackboardArtifact artifact) throws GeoLocationDataException {
197  Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap = new HashMap<>();
198  try {
199  List<BlackboardAttribute> attributeList = artifact.getAttributes();
200  for (BlackboardAttribute attribute : attributeList) {
201  try{
202  BlackboardAttribute.ATTRIBUTE_TYPE type = BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attribute.getAttributeType().getTypeID());
203  attributeMap.put(type, attribute);
204  } catch(IllegalArgumentException ex) {
205  // This was thrown due to a custom attribute that geolocation
206  // does not currently support.
207  }
208  }
209  } catch (TskCoreException ex) {
210  throw new GeoLocationDataException("Unable to get attributes from artifact", ex);
211  }
212 
213  return attributeMap;
214  }
215 
227  static List<Waypoint.Property> createGeolocationProperties(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
228  List<Waypoint.Property> list = new ArrayList<>();
229 
230  if(attributeMap != null) {
231 
232  Set<BlackboardAttribute.ATTRIBUTE_TYPE> keys = new HashSet<>(attributeMap.keySet());
233 
234  for (BlackboardAttribute.ATTRIBUTE_TYPE type : ALREADY_HANDLED_ATTRIBUTES) {
235  keys.remove(type);
236  }
237 
238  for (BlackboardAttribute.ATTRIBUTE_TYPE type : keys) {
239  // Don't add JSON properties to this list.
240  if (type.getValueType() == BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.JSON) {
241  continue;
242  }
243  String key = type.getDisplayName();
244  String value = attributeMap.get(type).getDisplayString();
245 
246  list.add(new Waypoint.Property(key, value));
247  }
248  }
249  return list;
250  }
251 
256  public final static class Property {
257 
258  private final String displayName;
259  private final String value;
260 
268  Property(String displayName, String value) {
269  this.displayName = displayName;
270  this.value = value;
271  }
272 
278  public String getDisplayName() {
279  return displayName;
280  }
281 
287  public String getValue() {
288  return value;
289  }
290  }
291 }
final List< Waypoint.Property > propertiesList
Definition: Waypoint.java:48

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