Sleuth Kit Java Bindings (JNI)  4.12.1
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-2021 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;
23 import java.util.Optional;
34 
38 public final class GeoArtifactsHelper extends ArtifactHelperBase {
39 
43 
47 
48  private final String programName;
49 
65  public GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String programName, Content srcContent, Long ingestJobId) {
66  super(caseDb, moduleName, srcContent, ingestJobId);
67  this.programName = programName;
68  }
69 
87  @Deprecated
88  public GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String programName, Content srcContent) {
89  this(caseDb, moduleName, programName, srcContent, null);
90  }
91 
114  public BlackboardArtifact addTrack(String trackName, GeoTrackPoints trackPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException {
115  if (trackPoints == null || trackPoints.isEmpty()) {
116  throw new IllegalArgumentException(String.format("addTrack was passed a null or empty list of track points"));
117  }
118 
119  List<BlackboardAttribute> attributes = new ArrayList<>();
120 
121  if (trackName != null) {
122  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), trackName));
123  }
124 
125  // acquire necessary attribute. If 'toAttribute' call throws an exception, an artifact will not be created for this instance.
126  attributes.add(BlackboardJsonAttrUtil.toAttribute(TRACKPOINTS_ATTR_TYPE, getModuleName(), trackPoints));
127 
128  if (programName != null) {
129  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName));
130  }
131 
132  if (moreAttributes != null) {
133  attributes.addAll(moreAttributes);
134  }
135 
136  Content content = getContent();
137  BlackboardArtifact artifact = content.newDataArtifact(GPS_TRACK_TYPE, attributes);
138 
139  Optional<Long> ingestJobId = getIngestJobId();
140  getSleuthkitCase().getBlackboard().postArtifact(artifact, getModuleName(), ingestJobId.orElse(null));
141 
142  return artifact;
143  }
144 
170  public BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypoints wayPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException {
171  if (wayPoints == null || wayPoints.isEmpty()) {
172  throw new IllegalArgumentException(String.format("addRoute was passed a null or empty list of waypoints"));
173  }
174 
175  List<BlackboardAttribute> attributes = new ArrayList<>();
176 
177  attributes.add(BlackboardJsonAttrUtil.toAttribute(WAYPOINTS_ATTR_TYPE, getModuleName(), wayPoints));
178 
179  if (routeName != null) {
180  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), routeName));
181  }
182 
183  if (creationTime != null) {
184  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME, getModuleName(), creationTime));
185  }
186 
187  if (programName != null) {
188  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName));
189  }
190 
191  if (moreAttributes != null) {
192  attributes.addAll(moreAttributes);
193  }
194 
195  Content content = getContent();
196  BlackboardArtifact artifact = content.newDataArtifact(GPS_ROUTE_TYPE, attributes);
197 
198  Optional<Long> ingestJobId = getIngestJobId();
199  getSleuthkitCase().getBlackboard().postArtifact(artifact, getModuleName(), ingestJobId.orElse(null));
200 
201  return artifact;
202  }
203 
224  public BlackboardArtifact addArea(String areaName, GeoAreaPoints areaPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException {
225  if (areaPoints == null || areaPoints.isEmpty()) {
226  throw new IllegalArgumentException(String.format("addArea was passed a null or empty list of points"));
227  }
228 
229  List<BlackboardAttribute> attributes = new ArrayList<>();
230  attributes.add(BlackboardJsonAttrUtil.toAttribute(AREAPOINTS_ATTR_TYPE, getModuleName(), areaPoints));
231 
232  if (areaName != null) {
233  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), areaName));
234  }
235 
236  if (programName != null) {
237  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName));
238  }
239 
240  if (moreAttributes != null) {
241  attributes.addAll(moreAttributes);
242  }
243 
244  Content content = getContent();
245  BlackboardArtifact artifact = content.newDataArtifact(GPS_AREA_TYPE, attributes);
246 
247  Optional<Long> ingestJobId = getIngestJobId();
248  getSleuthkitCase().getBlackboard().postArtifact(artifact, getModuleName(), ingestJobId.orElse(null));
249 
250  return artifact;
251  }
252 
253 }
static< T > BlackboardAttribute toAttribute(BlackboardAttribute.Type attrType, String moduleName, T attrValue)
GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String programName, Content srcContent, Long ingestJobId)
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.