Autopsy  4.19.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.Content;
32 import org.sleuthkit.datamodel.TskCoreException;
33 
38 public class Waypoint {
39 
40  final private Long timestamp;
41  final private Double longitude;
42  final private Double latitude;
43  final private Double altitude;
44  final private String label;
45  final private AbstractFile image;
46  final private BlackboardArtifact artifact;
47  final private GeoPath parentGeoPath;
48  final private Content content;
49 
50  final private List<Waypoint.Property> propertiesList;
51 
56  static final 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, GeoPath parentGeoPath) 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.parentGeoPath = parentGeoPath;
96 
97  propertiesList = createGeolocationProperties(attributeMap);
98  try {
99  content = artifact.getSleuthkitCase().getContentById(artifact.getObjectID());
100  } catch (TskCoreException ex) {
101  throw new GeoLocationDataException(String.format("Failed to get contend for artifact id (%d)", artifact.getId()), ex);
102  }
103  }
104 
110  public BlackboardArtifact getArtifact() {
111  return artifact;
112  }
113 
122  public Long getTimestamp() {
123  return timestamp;
124  }
125 
131  public String getLabel() {
132  return label;
133  }
134 
140  public Double getLatitude() {
141  return latitude;
142  }
143 
149  public Double getLongitude() {
150  return longitude;
151  }
152 
158  public Double getAltitude() {
159  return altitude;
160  }
161 
167  public AbstractFile getImage() {
168  return image;
169  }
170 
179  return Collections.unmodifiableList(propertiesList);
180  }
181 
189  return parentGeoPath;
190  }
191 
203  static Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> getAttributesFromArtifactAsMap(BlackboardArtifact artifact) throws GeoLocationDataException {
204  Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap = new HashMap<>();
205  try {
206  List<BlackboardAttribute> attributeList = artifact.getAttributes();
207  for (BlackboardAttribute attribute : attributeList) {
208  try{
209  BlackboardAttribute.ATTRIBUTE_TYPE type = BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attribute.getAttributeType().getTypeID());
210  attributeMap.put(type, attribute);
211  } catch(IllegalArgumentException ex) {
212  // This was thrown due to a custom attribute that geolocation
213  // does not currently support.
214  }
215  }
216  } catch (TskCoreException ex) {
217  throw new GeoLocationDataException("Unable to get attributes from artifact", ex);
218  }
219 
220  return attributeMap;
221  }
222 
234  static List<Waypoint.Property> createGeolocationProperties(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
235  List<Waypoint.Property> list = new ArrayList<>();
236 
237  if(attributeMap != null) {
238 
239  Set<BlackboardAttribute.ATTRIBUTE_TYPE> keys = new HashSet<>(attributeMap.keySet());
240 
241  for (BlackboardAttribute.ATTRIBUTE_TYPE type : ALREADY_HANDLED_ATTRIBUTES) {
242  keys.remove(type);
243  }
244 
245  for (BlackboardAttribute.ATTRIBUTE_TYPE type : keys) {
246  // Don't add JSON properties to this list.
247  if (type.getValueType() == BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.JSON) {
248  continue;
249  }
250  String key = type.getDisplayName();
251  String value = attributeMap.get(type).getDisplayString();
252 
253  list.add(new Waypoint.Property(key, value));
254  }
255  }
256  return list;
257  }
258 
259  public Content getContent() {
260  return content;
261  }
262 
267  public final static class Property {
268 
269  private final String displayName;
270  private final String value;
271 
279  Property(String displayName, String value) {
280  this.displayName = displayName;
281  this.value = value;
282  }
283 
289  public String getDisplayName() {
290  return displayName;
291  }
292 
298  public String getValue() {
299  return value;
300  }
301  }
302 }
final List< Waypoint.Property > propertiesList
Definition: Waypoint.java:50

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