Sleuth Kit Java Bindings (JNI)  4.11.0
Java bindings for using The Sleuth Kit
GeoArtifactsHelper.java
Go to the documentation of this file.
1 /*
2  * Sleuth Kit Data Model
3  *
4  * Copyright 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.datamodel.blackboardutils;
20 
21 import java.util.ArrayList;
22 import java.util.List;
34 
39 public final class GeoArtifactsHelper extends ArtifactHelperBase {
40 
44 
48 
49  private final String programName;
50 
65  public GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String programName, Content srcContent) {
66  super(caseDb, moduleName, srcContent);
67  this.programName = programName;
68  }
69 
92  public BlackboardArtifact addTrack(String trackName, GeoTrackPoints trackPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException {
93  if (trackPoints == null || trackPoints.isEmpty()) {
94  throw new IllegalArgumentException(String.format("addTrack was passed a null or empty list of track points"));
95  }
96 
97  List<BlackboardAttribute> attributes = new ArrayList<>();
98 
99  if (trackName != null) {
100  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), trackName));
101  }
102 
103  // acquire necessary attribute. If 'toAttribute' call throws an exception, an artifact will not be created for this instance.
104  attributes.add(BlackboardJsonAttrUtil.toAttribute(TRACKPOINTS_ATTR_TYPE, getModuleName(), trackPoints));
105 
106  if (programName != null) {
107  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName));
108  }
109 
110  if (moreAttributes != null) {
111  attributes.addAll(moreAttributes);
112  }
113 
114  Content content = getContent();
115  BlackboardArtifact artifact = content.newDataArtifact(GPS_TRACK_TYPE, attributes);
116 
117  getSleuthkitCase().getBlackboard().postArtifact(artifact, getModuleName());
118 
119  return artifact;
120  }
121 
147  public BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypoints wayPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException {
148  if (wayPoints == null || wayPoints.isEmpty()) {
149  throw new IllegalArgumentException(String.format("addRoute was passed a null or empty list of waypoints"));
150  }
151 
152  List<BlackboardAttribute> attributes = new ArrayList<>();
153 
154  attributes.add(BlackboardJsonAttrUtil.toAttribute(WAYPOINTS_ATTR_TYPE, getModuleName(), wayPoints));
155 
156  if (routeName != null) {
157  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), routeName));
158  }
159 
160  if (creationTime != null) {
161  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME, getModuleName(), creationTime));
162  }
163 
164  if (programName != null) {
165  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName));
166  }
167 
168  if (moreAttributes != null) {
169  attributes.addAll(moreAttributes);
170  }
171 
172  Content content = getContent();
173  BlackboardArtifact artifact = content.newDataArtifact(GPS_ROUTE_TYPE, attributes);
174 
175  getSleuthkitCase().getBlackboard().postArtifact(artifact, getModuleName());
176 
177  return artifact;
178  }
179 
200  public BlackboardArtifact addArea(String areaName, GeoAreaPoints areaPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException {
201  if (areaPoints == null || areaPoints.isEmpty()) {
202  throw new IllegalArgumentException(String.format("addArea was passed a null or empty list of points"));
203  }
204 
205  List<BlackboardAttribute> attributes = new ArrayList<>();
206  attributes.add(BlackboardJsonAttrUtil.toAttribute(AREAPOINTS_ATTR_TYPE, getModuleName(), areaPoints));
207 
208  if (areaName != null) {
209  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), areaName));
210  }
211 
212  if (programName != null) {
213  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName));
214  }
215 
216  if (moreAttributes != null) {
217  attributes.addAll(moreAttributes);
218  }
219 
220  Content content = getContent();
221  BlackboardArtifact artifact = content.newDataArtifact(GPS_AREA_TYPE, attributes);
222 
223  getSleuthkitCase().getBlackboard().postArtifact(artifact, getModuleName());
224 
225  return artifact;
226  }
227 
228 }
static< T > BlackboardAttribute toAttribute(BlackboardAttribute.Type attrType, String moduleName, T attrValue)
DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, Collection< BlackboardAttribute > attributesList)
BlackboardArtifact addArea(String areaName, GeoAreaPoints areaPoints, List< BlackboardAttribute > moreAttributes)
BlackboardArtifact addTrack(String trackName, GeoTrackPoints trackPoints, List< BlackboardAttribute > moreAttributes)
GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String programName, Content srcContent)
BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypoints wayPoints, List< BlackboardAttribute > moreAttributes)

Copyright © 2011-2021 Brian Carrier. (carrier -at- sleuthkit -dot- org)
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.