Autopsy  4.16.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  BlackboardAttribute.ATTRIBUTE_TYPE type = BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attribute.getAttributeType().getTypeID());
202  attributeMap.put(type, attribute);
203  }
204  } catch (TskCoreException ex) {
205  throw new GeoLocationDataException("Unable to get attributes from artifact", ex);
206  }
207 
208  return attributeMap;
209  }
210 
222  static List<Waypoint.Property> createGeolocationProperties(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
223  List<Waypoint.Property> list = new ArrayList<>();
224 
225  if(attributeMap != null) {
226 
227  Set<BlackboardAttribute.ATTRIBUTE_TYPE> keys = new HashSet<>(attributeMap.keySet());
228 
229  for (BlackboardAttribute.ATTRIBUTE_TYPE type : ALREADY_HANDLED_ATTRIBUTES) {
230  keys.remove(type);
231  }
232 
233  for (BlackboardAttribute.ATTRIBUTE_TYPE type : keys) {
234  // Don't add JSON properties to this list.
235  if (type.getValueType() == BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.JSON) {
236  continue;
237  }
238  String key = type.getDisplayName();
239  String value = attributeMap.get(type).getDisplayString();
240 
241  list.add(new Waypoint.Property(key, value));
242  }
243  }
244  return list;
245  }
246 
251  public final static class Property {
252 
253  private final String displayName;
254  private final String value;
255 
263  Property(String displayName, String value) {
264  this.displayName = displayName;
265  this.value = value;
266  }
267 
273  public String getDisplayName() {
274  return displayName;
275  }
276 
282  public String getValue() {
283  return value;
284  }
285  }
286 }
final List< Waypoint.Property > propertiesList
Definition: Waypoint.java:48

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.