mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
merged in the datamodel again
This commit is contained in:
commit
c54861d6df
@ -18,155 +18,48 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.geolocation.datamodel;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
* Utilities for simplifying and reducing redundant when getting Artifact
|
||||
* attributes.
|
||||
* Utilities for simplifying the use of Waypoint Artifacts.
|
||||
*/
|
||||
final class ArtifactUtils {
|
||||
|
||||
|
||||
/**
|
||||
* Private constructor for this Utility class.
|
||||
*/
|
||||
private ArtifactUtils() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for getting a String attribute from an artifact. This
|
||||
* will work for all attributes
|
||||
* Gets the list of attributes from the artifact and puts them into a map
|
||||
* with the ATRIBUTE_TYPE as the key.
|
||||
*
|
||||
* @param artifact The BlackboardArtifact to get the attributeType
|
||||
* @param attributeType BlackboardAttribute attributeType
|
||||
* @param artifact BlackboardArtifact current artifact
|
||||
*
|
||||
* @return String value for the given attribute or null if attribute was not
|
||||
* set for the given artifact
|
||||
* @return A Map of BlackboardAttributes for the given artifact with
|
||||
* ATTRIBUTE_TYPE as the key.
|
||||
*
|
||||
* @throws TskCoreException
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
static String getString(BlackboardArtifact artifact, BlackboardAttribute.ATTRIBUTE_TYPE attributeType) throws GeoLocationDataException {
|
||||
if (artifact == null) {
|
||||
return null;
|
||||
static Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> getAttributesFromArtifactAsMap(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap = new HashMap<>();
|
||||
try {
|
||||
List<BlackboardAttribute> attributeList = artifact.getAttributes();
|
||||
for (BlackboardAttribute attribute : attributeList) {
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE type = BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attribute.getAttributeType().getTypeID());
|
||||
attributeMap.put(type, attribute);
|
||||
}
|
||||
} catch (TskCoreException ex) {
|
||||
throw new GeoLocationDataException("Unable to get attributes from artifact", ex);
|
||||
}
|
||||
|
||||
BlackboardAttribute attribute;
|
||||
try{
|
||||
attribute = artifact.getAttribute(new BlackboardAttribute.Type(attributeType));
|
||||
} catch(TskCoreException ex) {
|
||||
throw new GeoLocationDataException(String.format("Failed to get double attribute for artifact: %d", artifact.getArtifactID()), ex);
|
||||
}
|
||||
return (attribute != null ? attribute.getDisplayString() : null);
|
||||
return attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for getting a Double attribute from an artifact.
|
||||
*
|
||||
* @param artifact The BlackboardArtifact to get the attributeType
|
||||
* @param attributeType BlackboardAttribute attributeType
|
||||
*
|
||||
* @return Double value for the given attribute.
|
||||
*
|
||||
* @throws TskCoreException
|
||||
*/
|
||||
static Double getDouble(BlackboardArtifact artifact, BlackboardAttribute.ATTRIBUTE_TYPE attributeType) throws GeoLocationDataException {
|
||||
if (artifact == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (attributeType.getValueType() != BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DOUBLE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BlackboardAttribute attribute;
|
||||
try{
|
||||
attribute = artifact.getAttribute(new BlackboardAttribute.Type(attributeType));
|
||||
} catch(TskCoreException ex) {
|
||||
throw new GeoLocationDataException(String.format("Failed to get double attribute for artifact: %d", artifact.getArtifactID()), ex);
|
||||
}
|
||||
return (attribute != null ? attribute.getValueDouble() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for getting a Long attribute from an artifact.
|
||||
*
|
||||
* @param artifact The BlackboardArtifact to get the attributeType
|
||||
* @param attributeType BlackboardAttribute attributeType
|
||||
*
|
||||
* @return Long value for the given attribute.
|
||||
*
|
||||
* @throws TskCoreException
|
||||
*/
|
||||
static Long getLong(BlackboardArtifact artifact, BlackboardAttribute.ATTRIBUTE_TYPE attributeType) throws GeoLocationDataException {
|
||||
if (artifact == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (attributeType.getValueType() != BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.LONG
|
||||
|| attributeType.getValueType() != BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BlackboardAttribute attribute;
|
||||
try{
|
||||
attribute = artifact.getAttribute(new BlackboardAttribute.Type(attributeType));
|
||||
} catch(TskCoreException ex) {
|
||||
throw new GeoLocationDataException(String.format("Failed to get double attribute for artifact: %d", artifact.getArtifactID()), ex);
|
||||
}
|
||||
return (attribute != null ? attribute.getValueLong() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for getting a Integer attribute from an artifact.
|
||||
*
|
||||
* @param artifact The BlackboardArtifact to get the attributeType
|
||||
* @param attributeType BlackboardAttribute attributeType
|
||||
*
|
||||
* @return Integer value for the given attribute.
|
||||
*
|
||||
* @throws TskCoreException
|
||||
*/
|
||||
static Integer getInteger(BlackboardArtifact artifact, BlackboardAttribute.ATTRIBUTE_TYPE attributeType) throws GeoLocationDataException {
|
||||
if (artifact == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (attributeType.getValueType() != BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.INTEGER) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BlackboardAttribute attribute;
|
||||
try{
|
||||
attribute = artifact.getAttribute(new BlackboardAttribute.Type(attributeType));
|
||||
} catch(TskCoreException ex) {
|
||||
throw new GeoLocationDataException(String.format("Failed to get double attribute for artifact: %d", artifact.getArtifactID()), ex);
|
||||
}
|
||||
return (attribute != null ? attribute.getValueInt() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of artifacts for the given BlackboardArtifact.Type.
|
||||
*
|
||||
* @param skCase Currently open case
|
||||
* @param type BlackboardArtifact.Type to retrieve
|
||||
*
|
||||
* @return List of BlackboardArtifacts
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
static List<BlackboardArtifact> getArtifactsForType(SleuthkitCase skCase, BlackboardArtifact.ARTIFACT_TYPE type) throws GeoLocationDataException {
|
||||
List<BlackboardArtifact> artifacts;
|
||||
try{
|
||||
artifacts = skCase.getBlackboardArtifacts(type);
|
||||
} catch(TskCoreException ex) {
|
||||
throw new GeoLocationDataException(String.format("Unable to get artifacts for type: %s", type.getLabel()), ex);
|
||||
}
|
||||
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.geolocation.datamodel;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
@ -43,81 +44,39 @@ class ArtifactWaypoint implements Waypoint {
|
||||
final private List<Waypoint.Property> immutablePropertiesList;
|
||||
|
||||
/**
|
||||
* Construct a simple waypoint with the given artifact and assign the given
|
||||
* type.
|
||||
*
|
||||
* This constructor is for use with artifacts that use the basic attributes
|
||||
* of: TSK_NAME TSK_GEO_LONGITUDE TSK_GEO_LATITUDE TSK_GEO_ALITUDE
|
||||
* TSK_DATETIME
|
||||
* Construct a waypoint with the given artifact.
|
||||
*
|
||||
* @param artifact BlackboardArtifact for this waypoint
|
||||
* @param type Waypoint type
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
* @throws GeoLocationDataException Exception will be thrown if artifact did
|
||||
* not have a valid longitude and latitude.
|
||||
*/
|
||||
protected ArtifactWaypoint(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
this(artifact,
|
||||
getLabelFromArtifact(artifact));
|
||||
ArtifactUtils.getAttributesFromArtifactAsMap(artifact));
|
||||
}
|
||||
|
||||
/**
|
||||
* For use by subclasses that want to customize the label, but use the basic
|
||||
* attributes of: TSK_GEO_LONGITUDE TSK_GEO_LATITUDE TSK_GEO_ALITUDE
|
||||
* TSK_DATETIME
|
||||
* Constructor that sets all of the member variables.
|
||||
*
|
||||
* @param artifact BlackboardArtifact for this waypoint
|
||||
* @param label String label for this waypoint
|
||||
* @param type Waypoint type
|
||||
* @param artifact BlackboardArtifact for this waypoint
|
||||
* @param label String waypoint label
|
||||
* @param timestamp Long timestamp, epoch seconds
|
||||
* @param latitude Double waypoint latitude
|
||||
* @param longitude Double waypoint longitude
|
||||
* @param altitude Double waypoint altitude
|
||||
* @param image AbstractFile image for waypoint, this maybe null
|
||||
* @param type Waypoint.Type value for waypoint
|
||||
* @param attributeMap A Map of attributes for the given artifact
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
* @throws GeoLocationDataException Exception will be thrown if artifact did
|
||||
* not have a valid longitude and latitude.
|
||||
*/
|
||||
protected ArtifactWaypoint(BlackboardArtifact artifact, String label) throws GeoLocationDataException {
|
||||
this(artifact,
|
||||
label,
|
||||
getTimestampFromArtifact(artifact),
|
||||
null);
|
||||
}
|
||||
protected ArtifactWaypoint(BlackboardArtifact artifact, String label, Long timestamp, Double latitude, Double longitude, Double altitude, AbstractFile image, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
|
||||
if (longitude == null || latitude == null) {
|
||||
throw new GeoLocationDataException("Invalid waypoint, null value passed for longitude or latitude");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for use by Waypoint subclasses that want to customize the
|
||||
* label, specify the timestamp or supply and image.
|
||||
*
|
||||
* Uses the following attributes to set longitude, latitude, altitude:
|
||||
* TSK_GEO_LONGITUDE TSK_GEO_LATITUDE TSK_GEO_ALITUDE
|
||||
*
|
||||
* @param artifact BlackboardArtifact for this waypoint
|
||||
* @param label String waypoint label
|
||||
* @param timestamp Long timestamp, epoch seconds
|
||||
* @param image AbstractFile image for waypoint, this maybe null
|
||||
* @param type Waypoint.Type value for waypoint
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
protected ArtifactWaypoint(BlackboardArtifact artifact, String label, Long timestamp, AbstractFile image) throws GeoLocationDataException {
|
||||
this(artifact,
|
||||
label,
|
||||
timestamp,
|
||||
ArtifactUtils.getDouble(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE),
|
||||
ArtifactUtils.getDouble(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE),
|
||||
ArtifactUtils.getDouble(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE),
|
||||
image);
|
||||
}
|
||||
|
||||
/**
|
||||
* Private constructor that sets all of the member variables.
|
||||
*
|
||||
* @param artifact BlackboardArtifact for this waypoint
|
||||
* @param label String waypoint label
|
||||
* @param timestamp Long timestamp, epoch seconds
|
||||
* @param latitude Double waypoint latitude
|
||||
* @param longitude Double waypoint longitude
|
||||
* @param altitude Double waypoint altitude
|
||||
* @param image AbstractFile image for waypoint, this maybe null
|
||||
* @param type Waypoint.Type value for waypoint
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
private ArtifactWaypoint(BlackboardArtifact artifact, String label, Long timestamp, Double latitude, Double longitude, Double altitude, AbstractFile image) throws GeoLocationDataException {
|
||||
this.artifact = artifact;
|
||||
this.label = label;
|
||||
this.image = image;
|
||||
@ -126,7 +85,26 @@ class ArtifactWaypoint implements Waypoint {
|
||||
this.latitude = latitude;
|
||||
this.altitude = altitude;
|
||||
|
||||
immutablePropertiesList = Collections.unmodifiableList(GeolocationUtils.getOtherGeolocationProperties(artifact));
|
||||
immutablePropertiesList = Collections.unmodifiableList(GeolocationUtils.createGeolocationProperties(attributeMap));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ArtifactWaypoint.
|
||||
*
|
||||
* @param artifact BlackboardArtifact for this waypoint
|
||||
* @param attributeMap A Map of the BlackboardAttributes for the given
|
||||
* artifact.
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
private ArtifactWaypoint(BlackboardArtifact artifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
|
||||
this(artifact,
|
||||
getLabelFromArtifact(attributeMap),
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME).getValueLong() : null,
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE).getValueDouble() : null,
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE).getValueDouble() : null,
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE).getValueDouble() : null,
|
||||
null, attributeMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,48 +145,26 @@ class ArtifactWaypoint implements Waypoint {
|
||||
public AbstractFile getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Waypoint.Property> getOtherProperties() {
|
||||
return immutablePropertiesList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the timestamp attribute based on type for the given artifact.
|
||||
* Gets the label for this waypoint.
|
||||
*
|
||||
* @param artifact BlackboardArtifact for waypoint
|
||||
*
|
||||
* @return Long timestamp or null if a value was not found.
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
* @return Returns a label for the waypoint, or empty string if no label was
|
||||
* found.
|
||||
*/
|
||||
private static Long getTimestampFromArtifact(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
if (artifact == null) {
|
||||
return null;
|
||||
private static String getLabelFromArtifact(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) {
|
||||
BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME);
|
||||
if (attribute != null) {
|
||||
return attribute.getDisplayString();
|
||||
}
|
||||
|
||||
return ArtifactUtils.getLong(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the label for this waypoint based on the artifact type.
|
||||
*
|
||||
* This is the original waypoint naming code from the KML report, we may
|
||||
* what to thinki about better ways to name some of the point.
|
||||
*
|
||||
* @param artifact BlackboardArtifact for waypoint
|
||||
*
|
||||
* @return Returns a label for the waypoint based on artifact type, or empty
|
||||
* string if no label was found.
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
private static String getLabelFromArtifact(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
|
||||
String typeLabel = ArtifactUtils.getString(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME);
|
||||
if (typeLabel == null) {
|
||||
typeLabel = "";
|
||||
}
|
||||
return typeLabel;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.geolocation.datamodel;
|
||||
|
||||
import java.util.Map;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
@ -36,22 +37,26 @@ final class EXIFWaypoint extends ArtifactWaypoint {
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
protected EXIFWaypoint(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
this(artifact, getImageFromArtifact(artifact));
|
||||
this(artifact, ArtifactUtils.getAttributesFromArtifactAsMap(artifact), getImageFromArtifact(artifact));
|
||||
}
|
||||
|
||||
/**
|
||||
* Private constructor to help with the construction of EXIFWaypoints.
|
||||
* Constructs new waypoint using the given artifact and attribute map.
|
||||
*
|
||||
* @param artifact Waypoint BlackboardArtifact
|
||||
* @param image EXIF AbstractFile image
|
||||
* @param artifact Waypoint BlackboardArtifact
|
||||
* @param attributeMap Map of artifact attributes
|
||||
* @param image EXIF AbstractFile image
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
private EXIFWaypoint(BlackboardArtifact artifact, AbstractFile image) throws GeoLocationDataException {
|
||||
private EXIFWaypoint(BlackboardArtifact artifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap, AbstractFile image) throws GeoLocationDataException {
|
||||
super(artifact,
|
||||
image != null ? image.getName() : "",
|
||||
ArtifactUtils.getLong(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED),
|
||||
image);
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED).getValueLong() : null,
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE).getValueDouble() : null,
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE).getValueDouble() : null,
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE).getValueDouble() : null,
|
||||
image, attributeMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,15 +73,14 @@ final class EXIFWaypoint extends ArtifactWaypoint {
|
||||
AbstractFile abstractFile = null;
|
||||
BlackboardArtifact.ARTIFACT_TYPE artifactType = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
|
||||
if (artifactType == BlackboardArtifact.ARTIFACT_TYPE.TSK_METADATA_EXIF) {
|
||||
|
||||
try{
|
||||
|
||||
try {
|
||||
abstractFile = artifact.getSleuthkitCase().getAbstractFileById(artifact.getObjectID());
|
||||
} catch(TskCoreException ex) {
|
||||
} catch (TskCoreException ex) {
|
||||
throw new GeoLocationDataException(String.format("Unable to getAbstractFileByID for artifact: %d", artifact.getArtifactID(), artifact.getArtifactID()), ex);
|
||||
}
|
||||
}
|
||||
|
||||
return abstractFile;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,31 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2019 Basis Technology Corp.
|
||||
* contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.geolocation.datamodel;
|
||||
|
||||
/**
|
||||
*
|
||||
* An exception class for the Geolocation dateModel;
|
||||
*
|
||||
*/
|
||||
public class GeoLocationDataException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default constructor when error message is not available
|
||||
*/
|
||||
public GeoLocationDataException() {
|
||||
super("No error message available.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create exception containing the error message
|
||||
*
|
||||
|
@ -20,36 +20,31 @@ package org.sleuthkit.autopsy.geolocation.datamodel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
|
||||
/**
|
||||
* GeolocationUtilis class for common to be share across in the package
|
||||
* GeolocationUtilis class for common shared between Routes and Waypoints.
|
||||
*
|
||||
*/
|
||||
final class GeolocationUtils {
|
||||
|
||||
/**
|
||||
* This is a list of attributes that are related to a geolocation waypoint
|
||||
* but are for information\artifact properties purpose. They are not needed
|
||||
* for the placement of a point on a map;
|
||||
* This is a list of attributes that are already being handled by the
|
||||
* waypoint classes and will have get functions.
|
||||
*/
|
||||
private static final BlackboardAttribute.ATTRIBUTE_TYPE[] OTHER_GEO_ATTRIBUTES = {
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_LOCATION,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END,
|
||||
private static final BlackboardAttribute.ATTRIBUTE_TYPE[] ALREADY_HANDLED_ATTRIBUTES = {
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_VELOCITY,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_BEARING,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_HPRECISION,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_VPRECISION,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_MAPDATUM,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_SOURCE,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_FLAG,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DEVICE_MAKE,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DEVICE_MODEL
|
||||
};
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_START,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_START,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_END,
|
||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_END,};
|
||||
|
||||
/**
|
||||
* This is a Utility class that should not be constructed.
|
||||
@ -59,7 +54,9 @@ final class GeolocationUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of Waypoint.Property objects for the given artifact.
|
||||
* Get a list of Waypoint.Property objects for the given artifact. This list
|
||||
* will not include attributes that the Waypoint interfact has get functions
|
||||
* for.
|
||||
*
|
||||
* @param artifact Blackboard artifact to get attributes\properties from
|
||||
*
|
||||
@ -67,20 +64,21 @@ final class GeolocationUtils {
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
static List<Waypoint.Property> getOtherGeolocationProperties(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
static List<Waypoint.Property> createGeolocationProperties(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
|
||||
List<Waypoint.Property> list = new ArrayList<>();
|
||||
|
||||
for (BlackboardAttribute.ATTRIBUTE_TYPE type : OTHER_GEO_ATTRIBUTES) {
|
||||
String key = type.getDisplayName();
|
||||
String value = ArtifactUtils.getString(artifact, type);
|
||||
Set<BlackboardAttribute.ATTRIBUTE_TYPE> keys = attributeMap.keySet();
|
||||
|
||||
if (value == null) {
|
||||
value = "";
|
||||
}
|
||||
for (BlackboardAttribute.ATTRIBUTE_TYPE type : ALREADY_HANDLED_ATTRIBUTES) {
|
||||
keys.remove(type);
|
||||
}
|
||||
|
||||
for (BlackboardAttribute.ATTRIBUTE_TYPE type : keys) {
|
||||
String key = type.getDisplayName();
|
||||
String value = attributeMap.get(type).getDisplayString();
|
||||
|
||||
list.add(new Waypoint.Property(key, value));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.geolocation.datamodel;
|
||||
|
||||
import java.util.Map;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
@ -29,21 +30,48 @@ import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
"LastKnownWaypoint_Label=Last Known Location",})
|
||||
final class LastKnownWaypoint extends ArtifactWaypoint {
|
||||
|
||||
/**
|
||||
* Constructs a new waypoint.
|
||||
*
|
||||
* @param artifact BlackboardArtifact from which to construct the waypoint
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
protected LastKnownWaypoint(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
super(artifact, getLabelFromArtifact(artifact));
|
||||
this(artifact, ArtifactUtils.getAttributesFromArtifactAsMap(artifact));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new waypoint with the given artifact and attribute map.
|
||||
*
|
||||
* @param artifact BlackboardArtifact from which to construct the
|
||||
* waypoint
|
||||
* @param attributeMap Map of artifact attributes
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
private LastKnownWaypoint(BlackboardArtifact artifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
|
||||
super(artifact,
|
||||
getLabelFromArtifact(attributeMap),
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME).getValueLong() : null,
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE).getValueDouble() : null,
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE).getValueDouble() : null,
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE).getValueDouble() : null,
|
||||
null, attributeMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the label for a TSK_LAST_KNOWN_LOCATION.
|
||||
*
|
||||
* @param artifact BlackboardArtifact to get label from
|
||||
* @param attributeMap Map of artifact attributes for this waypoint
|
||||
*
|
||||
* @return String value from attribute TSK_NAME or LastKnownWaypoint_Label
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
private static String getLabelFromArtifact(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
String label = ArtifactUtils.getString(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME);
|
||||
private static String getLabelFromArtifact(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
|
||||
BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME);
|
||||
String label = attribute.getDisplayString();
|
||||
|
||||
if (label == null || label.isEmpty()) {
|
||||
label = Bundle.LastKnownWaypoint_Label();
|
||||
|
@ -22,10 +22,12 @@ package org.sleuthkit.autopsy.geolocation.datamodel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
* A Route represents a TSK_GPS_ROUTE artifact which has a start and end point
|
||||
@ -58,9 +60,14 @@ public final class Route {
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
static public List<Route> getRoutes(SleuthkitCase skCase) throws GeoLocationDataException {
|
||||
List<BlackboardArtifact> artifacts = null;
|
||||
try {
|
||||
artifacts = skCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_ROUTE);
|
||||
} catch (TskCoreException ex) {
|
||||
throw new GeoLocationDataException("Unable to get artifacts for type: TSK_GPS_BOOKMARK", ex);
|
||||
}
|
||||
|
||||
static public List<Route> getRoutes(SleuthkitCase skCase) throws GeoLocationDataException {
|
||||
List<BlackboardArtifact> artifacts = ArtifactUtils.getArtifactsForType(skCase, BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_ROUTE);
|
||||
List<Route> routes = new ArrayList<>();
|
||||
for (BlackboardArtifact artifact : artifacts) {
|
||||
Route route = new Route(artifact);
|
||||
@ -76,21 +83,28 @@ public final class Route {
|
||||
*/
|
||||
Route(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
points = new ArrayList<>();
|
||||
Waypoint point = getRouteStartPoint(artifact);
|
||||
|
||||
Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap = ArtifactUtils.getAttributesFromArtifactAsMap(artifact);
|
||||
|
||||
Waypoint point = getRouteStartPoint(attributeMap);
|
||||
|
||||
if (point != null) {
|
||||
points.add(point);
|
||||
}
|
||||
|
||||
point = getRouteEndPoint(artifact);
|
||||
point = getRouteEndPoint(attributeMap);
|
||||
|
||||
if (point != null) {
|
||||
points.add(point);
|
||||
}
|
||||
|
||||
altitude = getRouteAltitude(artifact);
|
||||
timestamp = getRouteTimestamp(artifact);
|
||||
immutablePropertiesList = Collections.unmodifiableList(GeolocationUtils.getOtherGeolocationProperties(artifact));
|
||||
BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE);
|
||||
altitude = attribute != null ? attribute.getValueDouble() : null;
|
||||
|
||||
attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME);
|
||||
timestamp = attribute != null ? attribute.getValueLong() : null;
|
||||
|
||||
immutablePropertiesList = Collections.unmodifiableList(GeolocationUtils.createGeolocationProperties(attributeMap));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,81 +157,41 @@ public final class Route {
|
||||
/**
|
||||
* Get the route start point.
|
||||
*
|
||||
* @param artifact The BlackboardARtifact object from which this route is
|
||||
* created
|
||||
* @param attributeMap Map of artifact attributes for this waypoint
|
||||
*
|
||||
* @return Start RoutePoint or null if valid longitude and latitude are not
|
||||
* found
|
||||
* @return Start RoutePoint
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
* @throws GeoLocationDataException when longitude or latitude is null
|
||||
*/
|
||||
private Waypoint getRouteStartPoint(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
Double latitude;
|
||||
Double longitude;
|
||||
RoutePoint point = null;
|
||||
|
||||
latitude = ArtifactUtils.getDouble(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_START);
|
||||
longitude = ArtifactUtils.getDouble(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_START);
|
||||
private Waypoint getRouteStartPoint(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
|
||||
BlackboardAttribute latitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_START);
|
||||
BlackboardAttribute longitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_START);
|
||||
|
||||
if (latitude != null && longitude != null) {
|
||||
point = new RoutePoint(this, latitude, longitude, Bundle.Route_Start_Label());
|
||||
return new RoutePoint(this, latitude.getValueDouble(), longitude.getValueDouble(), Bundle.Route_Start_Label());
|
||||
} else {
|
||||
throw new GeoLocationDataException("Unable to create route start point, invalid longitude and/or latitude");
|
||||
}
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the route End point.
|
||||
*
|
||||
* @param artifact The BlackboardARtifact object from which this route is
|
||||
* created
|
||||
* @param attributeMap Map of artifact attributes for this waypoint
|
||||
*
|
||||
* @return End RoutePoint or null if valid longitude and latitude are not
|
||||
* found
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
* @throws GeoLocationDataException when longitude or latitude is null
|
||||
*/
|
||||
private Waypoint getRouteEndPoint(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
Double latitude;
|
||||
Double longitude;
|
||||
RoutePoint point = null;
|
||||
|
||||
latitude = ArtifactUtils.getDouble(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_END);
|
||||
longitude = ArtifactUtils.getDouble(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_END);
|
||||
private Waypoint getRouteEndPoint(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
|
||||
BlackboardAttribute latitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_END);
|
||||
BlackboardAttribute longitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_END);
|
||||
|
||||
if (latitude != null && longitude != null) {
|
||||
point = new RoutePoint(this, latitude, longitude, Bundle.Route_End_Label());
|
||||
return new RoutePoint(this, latitude.getValueDouble(), longitude.getValueDouble(), Bundle.Route_End_Label());
|
||||
}else {
|
||||
throw new GeoLocationDataException("Unable to create route end point, invalid longitude and/or latitude");
|
||||
}
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Altitude for this route.
|
||||
*
|
||||
* @param artifact The BlackboardARtifact object from which this route is
|
||||
* created
|
||||
*
|
||||
* @return The Altitude, or null if none was found
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
private Double getRouteAltitude(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
return ArtifactUtils.getDouble(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the timestamp for this route.
|
||||
*
|
||||
* @param artifact The BlackboardARtifact object from which this route is
|
||||
* created
|
||||
*
|
||||
* @return The timestamp attribute, or null if none was found
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
private Long getRouteTimestamp(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
return ArtifactUtils.getLong(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.geolocation.datamodel;
|
||||
|
||||
import java.util.Map;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
@ -31,36 +32,46 @@ final class SearchWaypoint extends ArtifactWaypoint {
|
||||
"SearchWaypoint_DisplayLabel=GPS Search"
|
||||
})
|
||||
|
||||
/**
|
||||
* Construct a GPS Search waypoint.
|
||||
*
|
||||
/**
|
||||
* Construct a waypoint for TSK_GPS_SEARCH artifact.
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
SearchWaypoint(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
super(artifact, getLabelFromArtifact(artifact));
|
||||
this(artifact, ArtifactUtils.getAttributesFromArtifactAsMap(artifact));
|
||||
}
|
||||
|
||||
private SearchWaypoint(BlackboardArtifact artifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
|
||||
super(artifact,
|
||||
getLabelFromArtifact(attributeMap),
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME).getValueLong() : null,
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE).getValueDouble() : null,
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE).getValueDouble() : null,
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE).getValueDouble() : null,
|
||||
null, attributeMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Label for a GPS_SEARCH artifact.
|
||||
*
|
||||
* @param artifact BlackboardArtifact for waypoint
|
||||
* @param attributeMap Map of artifact attributes
|
||||
*
|
||||
* @return String label for the artifacts way point.
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
private static String getLabelFromArtifact(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
String typeLabel = ArtifactUtils.getString(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME);
|
||||
|
||||
if (typeLabel == null || typeLabel.isEmpty()) {
|
||||
typeLabel = ArtifactUtils.getString(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_LOCATION);
|
||||
private static String getLabelFromArtifact(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
|
||||
BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME);
|
||||
if (attribute != null) {
|
||||
return attribute.getDisplayString();
|
||||
}
|
||||
|
||||
if (typeLabel == null || typeLabel.isEmpty()) {
|
||||
typeLabel = Bundle.SearchWaypoint_DisplayLabel();
|
||||
attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_LOCATION);
|
||||
if (attribute != null) {
|
||||
return attribute.getDisplayString();
|
||||
}
|
||||
|
||||
return typeLabel;
|
||||
return Bundle.SearchWaypoint_DisplayLabel();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.geolocation.datamodel;
|
||||
|
||||
import java.util.Map;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
@ -37,7 +38,17 @@ final class TrackpointWaypoint extends ArtifactWaypoint {
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
TrackpointWaypoint(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
super(artifact, getLabelFromArtifact(artifact));
|
||||
this(artifact, ArtifactUtils.getAttributesFromArtifactAsMap(artifact));
|
||||
}
|
||||
|
||||
private TrackpointWaypoint(BlackboardArtifact artifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
|
||||
super(artifact,
|
||||
getLabelFromArtifact(attributeMap),
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME).getValueLong() : null,
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE).getValueDouble() : null,
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE).getValueDouble() : null,
|
||||
attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE) != null ? attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE).getValueDouble() : null,
|
||||
null, attributeMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,23 +61,24 @@ final class TrackpointWaypoint extends ArtifactWaypoint {
|
||||
*
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
private static String getLabelFromArtifact(BlackboardArtifact artifact) throws GeoLocationDataException {
|
||||
private static String getLabelFromArtifact(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
|
||||
|
||||
String typeLabel = ArtifactUtils.getString(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME);
|
||||
|
||||
if (typeLabel == null || typeLabel.isEmpty()) {
|
||||
typeLabel = ArtifactUtils.getString(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME);
|
||||
BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME);
|
||||
if (attribute != null) {
|
||||
return attribute.getDisplayString();
|
||||
}
|
||||
|
||||
if (typeLabel == null || typeLabel.isEmpty()) {
|
||||
typeLabel = ArtifactUtils.getString(artifact, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_FLAG);
|
||||
attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME);
|
||||
if (attribute != null) {
|
||||
return attribute.getDisplayString();
|
||||
}
|
||||
|
||||
if (typeLabel == null || typeLabel.isEmpty()) {
|
||||
typeLabel = Bundle.TrackpointWaypoint_DisplayLabel();
|
||||
attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_FLAG);
|
||||
if (attribute != null) {
|
||||
return attribute.getDisplayString();
|
||||
}
|
||||
|
||||
return typeLabel;
|
||||
return Bundle.TrackpointWaypoint_DisplayLabel();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,15 +20,19 @@ package org.sleuthkit.autopsy.geolocation.datamodel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
* The basic details of a waypoint.
|
||||
*
|
||||
*/
|
||||
public interface Waypoint {
|
||||
static final Logger logger = Logger.getLogger(Waypoint.class.getName());
|
||||
/**
|
||||
* Interface to describe a waypoint. A waypoint is made up of
|
||||
* a longitude, latitude, label, timestamp, type, image and altitude.
|
||||
@ -118,16 +122,21 @@ public interface Waypoint {
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
static List<Waypoint> getTrackpointWaypoints(SleuthkitCase skCase) throws GeoLocationDataException {
|
||||
List<BlackboardArtifact> artifacts = ArtifactUtils.getArtifactsForType(skCase, BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACKPOINT);
|
||||
List<BlackboardArtifact> artifacts = null;
|
||||
try{
|
||||
artifacts = skCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACKPOINT);
|
||||
} catch(TskCoreException ex) {
|
||||
throw new GeoLocationDataException("Unable to get artifacts for type: TSK_GPS_TRACKPOINT", ex);
|
||||
}
|
||||
|
||||
List<Waypoint> points = new ArrayList<>();
|
||||
for (BlackboardArtifact artifact : artifacts) {
|
||||
ArtifactWaypoint point = new TrackpointWaypoint(artifact);
|
||||
// Only add to the list if the point has a valid latitude
|
||||
// and longitude.
|
||||
if (point.getLatitude() != null && point.getLongitude() != null) {
|
||||
try{
|
||||
ArtifactWaypoint point = new TrackpointWaypoint(artifact);
|
||||
points.add(point);
|
||||
}
|
||||
} catch(GeoLocationDataException ex) {
|
||||
logger.log(Level.WARNING, String.format("No longitude or latitude available for TSK_GPS_TRACKPOINT artifactID: %d", artifact.getArtifactID()));
|
||||
}
|
||||
}
|
||||
return points;
|
||||
}
|
||||
@ -142,17 +151,24 @@ public interface Waypoint {
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
static List<Waypoint> getEXIFWaypoints(SleuthkitCase skCase) throws GeoLocationDataException {
|
||||
List<BlackboardArtifact> artifacts = ArtifactUtils.getArtifactsForType(skCase, BlackboardArtifact.ARTIFACT_TYPE.TSK_METADATA_EXIF);
|
||||
List<BlackboardArtifact> artifacts = null;
|
||||
try{
|
||||
artifacts = skCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_METADATA_EXIF);
|
||||
} catch(TskCoreException ex) {
|
||||
throw new GeoLocationDataException("Unable to get artifacts for type: TSK_GPS_LAST_KNOWN_LOCATION", ex);
|
||||
}
|
||||
|
||||
List<Waypoint> points = new ArrayList<>();
|
||||
if (artifacts != null) {
|
||||
for (BlackboardArtifact artifact : artifacts) {
|
||||
ArtifactWaypoint point = new EXIFWaypoint(artifact);
|
||||
// Only add to the list if the point has a valid latitude
|
||||
// and longitude.
|
||||
if (point.getLatitude() != null && point.getLongitude() != null) {
|
||||
try{
|
||||
ArtifactWaypoint point = new EXIFWaypoint(artifact);
|
||||
points.add(point);
|
||||
}
|
||||
} catch(GeoLocationDataException ex) {
|
||||
// I am a little relucant to log this error because I suspect
|
||||
// this will happen more often than not. It is valid for
|
||||
// METADAT_EXIF to not have longitude and latitude
|
||||
}
|
||||
}
|
||||
}
|
||||
return points;
|
||||
@ -168,17 +184,22 @@ public interface Waypoint {
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
static List<Waypoint> getSearchWaypoints(SleuthkitCase skCase) throws GeoLocationDataException {
|
||||
List<BlackboardArtifact> artifacts = ArtifactUtils.getArtifactsForType(skCase, BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_SEARCH);
|
||||
List<BlackboardArtifact> artifacts = null;
|
||||
try{
|
||||
artifacts = skCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_SEARCH);
|
||||
} catch(TskCoreException ex) {
|
||||
throw new GeoLocationDataException("Unable to get artifacts for type: TSK_GPS_SEARCH", ex);
|
||||
}
|
||||
|
||||
List<Waypoint> points = new ArrayList<>();
|
||||
if (artifacts != null) {
|
||||
for (BlackboardArtifact artifact : artifacts) {
|
||||
ArtifactWaypoint point = new SearchWaypoint(artifact);
|
||||
// Only add to the list if the point has a valid latitude
|
||||
// and longitude.
|
||||
if (point.getLatitude() != null && point.getLongitude() != null) {
|
||||
try{
|
||||
ArtifactWaypoint point = new SearchWaypoint(artifact);
|
||||
points.add(point);
|
||||
}
|
||||
} catch(GeoLocationDataException ex) {
|
||||
logger.log(Level.WARNING, String.format("No longitude or latitude available for TSK_GPS_SEARCH artifactID: %d", artifact.getArtifactID()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return points;
|
||||
@ -194,18 +215,22 @@ public interface Waypoint {
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
static List<Waypoint> getLastKnownWaypoints(SleuthkitCase skCase) throws GeoLocationDataException {
|
||||
List<BlackboardArtifact> artifacts = ArtifactUtils.getArtifactsForType(skCase, BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_LAST_KNOWN_LOCATION);
|
||||
List<BlackboardArtifact> artifacts = null;
|
||||
try{
|
||||
artifacts = skCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_LAST_KNOWN_LOCATION);
|
||||
} catch(TskCoreException ex) {
|
||||
throw new GeoLocationDataException("Unable to get artifacts for type: TSK_GPS_LAST_KNOWN_LOCATION", ex);
|
||||
}
|
||||
|
||||
List<Waypoint> points = new ArrayList<>();
|
||||
if (artifacts != null) {
|
||||
|
||||
for (BlackboardArtifact artifact : artifacts) {
|
||||
ArtifactWaypoint point = new LastKnownWaypoint(artifact);
|
||||
// Only add to the list if the point has a valid latitude
|
||||
// and longitude.
|
||||
if (point.getLatitude() != null && point.getLongitude() != null) {
|
||||
for (BlackboardArtifact artifact : artifacts) {
|
||||
try{
|
||||
ArtifactWaypoint point = new LastKnownWaypoint(artifact);
|
||||
points.add(point);
|
||||
}
|
||||
} catch(GeoLocationDataException ex) {
|
||||
logger.log(Level.WARNING, String.format("No longitude or latitude available for TSK_GPS_LAST_KNOWN_LOCATION artifactID: %d", artifact.getArtifactID()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return points;
|
||||
@ -221,17 +246,22 @@ public interface Waypoint {
|
||||
* @throws GeoLocationDataException
|
||||
*/
|
||||
static List<Waypoint> getBookmarkWaypoints(SleuthkitCase skCase) throws GeoLocationDataException {
|
||||
List<BlackboardArtifact> artifacts = ArtifactUtils.getArtifactsForType(skCase, BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_BOOKMARK);
|
||||
List<BlackboardArtifact> artifacts = null;
|
||||
try{
|
||||
artifacts = skCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_BOOKMARK);
|
||||
} catch(TskCoreException ex) {
|
||||
throw new GeoLocationDataException("Unable to get artifacts for type: TSK_GPS_BOOKMARK", ex);
|
||||
}
|
||||
|
||||
List<Waypoint> points = new ArrayList<>();
|
||||
if (artifacts != null) {
|
||||
for (BlackboardArtifact artifact : artifacts) {
|
||||
ArtifactWaypoint point = new ArtifactWaypoint(artifact);
|
||||
// Only add to the list if the point has a valid latitude
|
||||
// and longitude.
|
||||
if (point.getLatitude() != null && point.getLongitude() != null) {
|
||||
try{
|
||||
ArtifactWaypoint point = new ArtifactWaypoint(artifact);
|
||||
points.add(point);
|
||||
}
|
||||
} catch(GeoLocationDataException ex) {
|
||||
logger.log(Level.WARNING, String.format("No longitude or latitude available for TSK_GPS_BOOKMARK artifactID: %d", artifact.getArtifactID()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return points;
|
||||
|
Loading…
x
Reference in New Issue
Block a user