20 package org.sleuthkit.autopsy.geolocation.datamodel;
22 import java.sql.ResultSet;
23 import java.sql.SQLException;
24 import java.util.ArrayList;
25 import java.util.List;
26 import java.util.logging.Level;
44 final static String GEO_ARTIFACT_QUERY
45 =
"SELECT artifact_id, artifact_type_id "
46 +
"FROM blackboard_attributes "
47 +
"WHERE attribute_type_id IN (%d, %d) ";
50 final static String GEO_ARTIFACT_QUERY_ID_ONLY
51 =
"SELECT artifact_id "
52 +
"FROM blackboard_attributes "
53 +
"WHERE attribute_type_id IN (%d, %d) ";
56 final static String GEO_ARTIFACT_WITH_DATA_SOURCES_QUERY
57 =
"SELECT blackboard_attributes.artifact_id "
58 +
"FROM blackboard_attributes, blackboard_artifacts "
59 +
"WHERE blackboard_attributes.artifact_id = blackboard_artifacts.artifact_id "
60 +
"AND blackboard_attributes.attribute_type_id IN(%d, %d) "
61 +
"AND data_source_obj_id IN (%s)";
64 final static String MOST_RECENT_TIME
65 =
"SELECT MAX(value_int64) - (%d * 86400)"
66 +
"FROM blackboard_attributes "
67 +
"WHERE attribute_type_id IN(%d, %d) "
74 final static String SELECT_WO_TIMESTAMP
75 =
"SELECT DISTINCT artifact_id, artifact_type_id "
76 +
"FROM blackboard_attributes "
77 +
"WHERE artifact_id NOT IN (%s) "
78 +
"AND artifact_id IN (%s)";
90 void process(List<Waypoint> wwaypoints);
114 List<Waypoint> points =
new ArrayList<>();
132 public static List<Route>
getRoutes(List<Waypoint> waypoints) {
133 List<Route> routeList =
new ArrayList<>();
136 if (route != null && !routeList.contains(route)) {
137 routeList.add(route);
154 List<BlackboardArtifact> artifacts = null;
156 artifacts = skCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACKPOINT);
157 }
catch (TskCoreException ex) {
161 List<Waypoint> points =
new ArrayList<>();
162 for (BlackboardArtifact artifact : artifacts) {
164 Waypoint point =
new TrackpointWaypoint(artifact);
167 logger.log(Level.WARNING, String.format(
"No longitude or latitude available for TSK_GPS_TRACKPOINT artifactID: %d", artifact.getArtifactID()));
181 List<Waypoint> specificPoints =
new ArrayList<>();
184 if (point instanceof TrackpointWaypoint) {
185 specificPoints.add(point);
189 return specificPoints;
202 List<BlackboardArtifact> artifacts = null;
204 artifacts = skCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_METADATA_EXIF);
205 }
catch (TskCoreException ex) {
209 List<Waypoint> points =
new ArrayList<>();
210 if (artifacts != null) {
211 for (BlackboardArtifact artifact : artifacts) {
213 Waypoint point =
new EXIFWaypoint(artifact);
233 List<Waypoint> specificPoints =
new ArrayList<>();
236 if (point instanceof EXIFWaypoint) {
237 specificPoints.add(point);
241 return specificPoints;
254 List<BlackboardArtifact> artifacts = null;
256 artifacts = skCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_SEARCH);
257 }
catch (TskCoreException ex) {
261 List<Waypoint> points =
new ArrayList<>();
262 if (artifacts != null) {
263 for (BlackboardArtifact artifact : artifacts) {
265 Waypoint point =
new SearchWaypoint(artifact);
268 logger.log(Level.WARNING, String.format(
"No longitude or latitude available for TSK_GPS_SEARCH artifactID: %d", artifact.getArtifactID()));
283 List<Waypoint> specificPoints =
new ArrayList<>();
286 if (point instanceof SearchWaypoint) {
287 specificPoints.add(point);
291 return specificPoints;
304 List<BlackboardArtifact> artifacts = null;
306 artifacts = skCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_LAST_KNOWN_LOCATION);
307 }
catch (TskCoreException ex) {
311 List<Waypoint> points =
new ArrayList<>();
312 if (artifacts != null) {
313 for (BlackboardArtifact artifact : artifacts) {
315 Waypoint point =
new LastKnownWaypoint(artifact);
318 logger.log(Level.WARNING, String.format(
"No longitude or latitude available for TSK_GPS_LAST_KNOWN_LOCATION artifactID: %d", artifact.getArtifactID()));
334 List<Waypoint> specificPoints =
new ArrayList<>();
337 if (point instanceof LastKnownWaypoint) {
338 specificPoints.add(point);
342 return specificPoints;
355 List<BlackboardArtifact> artifacts = null;
357 artifacts = skCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_BOOKMARK);
358 }
catch (TskCoreException ex) {
362 List<Waypoint> points =
new ArrayList<>();
363 if (artifacts != null) {
364 for (BlackboardArtifact artifact : artifacts) {
366 Waypoint point =
new BookmarkWaypoint(artifact);
369 logger.log(Level.WARNING, String.format(
"No longitude or latitude available for TSK_GPS_BOOKMARK artifactID: %d", artifact.getArtifactID()), ex);
385 List<Waypoint> specificPoints =
new ArrayList<>();
388 if (point instanceof BookmarkWaypoint) {
389 specificPoints.add(point);
393 return specificPoints;
427 String query =
buildQuery(dataSources, showAll, cntDaysFromRecent, noTimeStamp);
429 logger.log(Level.INFO, query);
434 if (query.startsWith(
"SELECT")) {
435 query = query.replaceFirst(
"SELECT",
"");
438 skCase.getCaseDbAccessManager().select(query,
new CaseDbAccessManager.CaseDbAccessQueryCallback() {
440 public void process(ResultSet rs) {
441 List<Waypoint> waypoints =
new ArrayList<>();
444 int artifact_type_id = rs.getInt(
"artifact_type_id");
445 long artifact_id = rs.getLong(
"artifact_id");
447 BlackboardArtifact.ARTIFACT_TYPE type = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact_type_id);
452 queryCallBack.process(waypoints);
454 logger.log(Level.WARNING,
"Failed to filter waypoint.", ex);
459 }
catch (TskCoreException ex) {
460 logger.log(Level.WARNING,
"Failed to filter waypoint.", ex);
485 return String.format(SELECT_WO_TIMESTAMP,
486 String.format(GEO_ARTIFACT_QUERY_ID_ONLY,
487 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID(),
488 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED.getTypeID()),
514 static private String
buildQuery(List<DataSource> dataSources,
boolean showAll,
int cntDaysFromRecent,
boolean noTimeStamp) {
515 String mostRecentQuery =
"";
517 if (!showAll && cntDaysFromRecent > 0) {
525 mostRecentQuery = String.format(
"AND value_int64 > (%s)",
526 String.format(MOST_RECENT_TIME,
528 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID(),
529 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED.getTypeID(),
538 String query = String.format(GEO_ARTIFACT_QUERY,
539 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID(),
540 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED.getTypeID());
544 query += mostRecentQuery;
546 if (showAll || noTimeStamp) {
567 if (dataSources == null || dataSources.isEmpty()) {
572 return String.format(GEO_ARTIFACT_QUERY,
573 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE.getTypeID(),
574 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_START.getTypeID());
577 String dataSourceList =
"";
578 for (DataSource source : dataSources) {
579 dataSourceList += Long.toString(source.getId()) +
",";
582 if (!dataSourceList.isEmpty()) {
584 dataSourceList = dataSourceList.substring(0, dataSourceList.length() - 1);
587 return String.format(GEO_ARTIFACT_WITH_DATA_SOURCES_QUERY,
588 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE.getTypeID(),
589 BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_START.getTypeID(),
604 List<Waypoint> waypoints =
new ArrayList<>();
606 case TSK_METADATA_EXIF:
607 waypoints.add(
new EXIFWaypoint(artifact));
609 case TSK_GPS_BOOKMARK:
610 waypoints.add(
new BookmarkWaypoint(artifact));
612 case TSK_GPS_TRACKPOINT:
613 waypoints.add(
new TrackpointWaypoint(artifact));
616 waypoints.add(
new SearchWaypoint(artifact));
622 case TSK_GPS_LAST_KNOWN_LOCATION:
623 waypoints.add(
new LastKnownWaypoint(artifact));
626 waypoints.add(
new CustomArtifactWaypoint(artifact));
static List< Waypoint > getLastKnownWaypoints(List< Waypoint > waypoints)
static String buildQuery(List< DataSource > dataSources, boolean showAll, int cntDaysFromRecent, boolean noTimeStamp)
static final Logger logger
static List< Waypoint > getBookmarkWaypoints(SleuthkitCase skCase)
void process(List< Waypoint > wwaypoints)
static List< Waypoint > getBookmarkWaypoints(List< Waypoint > waypoints)
static void getAllWaypoints(SleuthkitCase skCase, List< DataSource > dataSources, boolean showAll, int cntDaysFromRecent, boolean noTimeStamp, WaypointFilterQueryCallBack queryCallBack)
List< Waypoint > getRoute()
static List< Waypoint > getSearchWaypoints(SleuthkitCase skCase)
static List< Waypoint > getSearchWaypoints(List< Waypoint > waypoints)
static List< Waypoint > getTrackpointWaypoints(SleuthkitCase skCase)
static List< Route > getRoutes(List< Waypoint > waypoints)
static List< Waypoint > getAllWaypoints(SleuthkitCase skCase)
static String getWaypointListQuery(List< DataSource > dataSources)
static List< Waypoint > getWaypointForArtifact(BlackboardArtifact artifact, BlackboardArtifact.ARTIFACT_TYPE type)
static List< Waypoint > getEXIFWaypoints(List< Waypoint > waypoints)
static List< Waypoint > getTrackpointWaypoints(List< Waypoint > waypoints)
static String buildQueryForWaypointsWOTimeStamps(List< DataSource > dataSources)
synchronized static Logger getLogger(String name)
static List< Waypoint > getLastKnownWaypoints(SleuthkitCase skCase)
static List< Waypoint > getEXIFWaypoints(SleuthkitCase skCase)