Sleuth Kit Java Bindings (JNI)  4.10.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 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;
33 
38 public final class GeoArtifactsHelper extends ArtifactHelperBase {
39 
43  private final String programName;
44 
59  public GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String programName, Content srcContent) {
60  super(caseDb, moduleName, srcContent);
61  this.programName = programName;
62  }
63 
86  public BlackboardArtifact addTrack(String trackName, GeoTrackPoints trackPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException {
87  if (trackPoints == null || trackPoints.isEmpty()) {
88  throw new IllegalArgumentException(String.format("addTrack was passed a null or empty list of track points"));
89  }
90 
91  List<BlackboardAttribute> attributes = new ArrayList<>();
92 
93  if (trackName != null) {
94  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), trackName));
95  }
96 
97  // acquire necessary attribute. If 'toAttribute' call throws an exception, an artifact will not be created for this instance.
98  attributes.add(BlackboardJsonAttrUtil.toAttribute(TRACKPOINTS_ATTR_TYPE, getModuleName(), trackPoints));
99 
100  if (programName != null) {
101  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName));
102  }
103 
104  if (moreAttributes != null) {
105  attributes.addAll(moreAttributes);
106  }
107 
109  artifact.addAttributes(attributes);
110 
111  getSleuthkitCase().getBlackboard().postArtifact(artifact, getModuleName());
112 
113  return artifact;
114  }
115 
141  public BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypoints wayPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException {
142  if (wayPoints == null || wayPoints.isEmpty()) {
143  throw new IllegalArgumentException(String.format("addRoute was passed a null or empty list of waypoints"));
144  }
145 
147  List<BlackboardAttribute> attributes = new ArrayList<>();
148 
149  attributes.add(BlackboardJsonAttrUtil.toAttribute(WAYPOINTS_ATTR_TYPE, getModuleName(), wayPoints));
150 
151  if (routeName != null) {
152  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), routeName));
153  }
154 
155  if (creationTime != null) {
156  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME, getModuleName(), creationTime));
157  }
158 
159  if (programName != null) {
160  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName));
161  }
162 
163  if (moreAttributes != null) {
164  attributes.addAll(moreAttributes);
165  }
166 
167  artifact.addAttributes(attributes);
168 
169  getSleuthkitCase().getBlackboard().postArtifact(artifact, getModuleName());
170 
171  return artifact;
172  }
193  public BlackboardArtifact addArea(String areaName, GeoAreaPoints areaPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException {
194  if (areaPoints == null || areaPoints.isEmpty()) {
195  throw new IllegalArgumentException(String.format("addArea was passed a null or empty list of points"));
196  }
197 
199  List<BlackboardAttribute> attributes = new ArrayList<>();
200  attributes.add(BlackboardJsonAttrUtil.toAttribute(AREAPOINTS_ATTR_TYPE, getModuleName(), areaPoints));
201 
202  if (areaName != null) {
203  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), areaName));
204  }
205 
206  if (programName != null) {
207  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName));
208  }
209 
210  if (moreAttributes != null) {
211  attributes.addAll(moreAttributes);
212  }
213 
214  artifact.addAttributes(attributes);
215 
216  getSleuthkitCase().getBlackboard().postArtifact(artifact, getModuleName());
217 
218  return artifact;
219  }
220 
221 }
static< T > BlackboardAttribute toAttribute(BlackboardAttribute.Type attrType, String moduleName, T attrValue)
void addAttributes(Collection< BlackboardAttribute > attributes)
BlackboardArtifact addArea(String areaName, GeoAreaPoints areaPoints, List< BlackboardAttribute > moreAttributes)
BlackboardArtifact addTrack(String trackName, GeoTrackPoints trackPoints, List< BlackboardAttribute > moreAttributes)
BlackboardArtifact newArtifact(int artifactTypeID)
GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String programName, Content srcContent)
BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypoints wayPoints, List< BlackboardAttribute > moreAttributes)

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