Sleuth Kit Java Bindings (JNI)  4.4.1
Java bindings for using The Sleuth Kit
BlackboardArtifact.java
Go to the documentation of this file.
1 /*
2  * Sleuth Kit Data Model
3  *
4  * Copyright 2011-2017 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;
20 
21 import java.io.Serializable;
22 import java.io.UnsupportedEncodingException;
23 import java.text.MessageFormat;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.HashMap;
27 import java.util.List;
28 import java.util.Map;
29 import java.util.Objects;
30 import java.util.ResourceBundle;
31 import java.util.HashSet;
32 import java.util.Set;
36 
46 public class BlackboardArtifact implements Content {
47 
48  private static final ResourceBundle bundle = ResourceBundle.getBundle("org.sleuthkit.datamodel.Bundle");
49  private final long artifactId;
50  private final long sourceObjId; // refers to objID of parent/source object
51  private final long artifactObjId; // objId of the artifact in tsk_objects. TBD: replace artifactID with this
52  private final int artifactTypeId;
53  private final String artifactTypeName;
54  private final String displayName;
55  private final ReviewStatus reviewStatus;
57  private final List<BlackboardAttribute> attrsCache = new ArrayList<BlackboardAttribute>();
58  private boolean loadedCacheFromDb = false;
59  private Content parent;
60  private String uniquePath;
61 
62  private byte[] contentBytes = null;
63 
64  private volatile boolean checkedHasChildren;
65  private volatile boolean hasChildren;
66  private volatile int childrenCount;
67 
86  BlackboardArtifact(SleuthkitCase sleuthkitCase, long artifactID, long sourceObjId, long artifactObjId, int artifactTypeID, String artifactTypeName, String displayName, ReviewStatus reviewStatus) {
87 
88  this.sleuthkitCase = sleuthkitCase;
89  this.artifactId = artifactID;
90  this.sourceObjId = sourceObjId;
91  this.artifactObjId = artifactObjId;
92  this.artifactTypeId = artifactTypeID;
93  this.artifactTypeName = artifactTypeName;
94  this.displayName = displayName;
95  this.reviewStatus = reviewStatus;
96 
97  this.checkedHasChildren = false;
98  this.hasChildren = false;
99  this.childrenCount = -1;
100 
101  }
102 
121  BlackboardArtifact(SleuthkitCase sleuthkitCase, long artifactID, long sourceObjId, long artifactObjID, int artifactTypeID, String artifactTypeName, String displayName, ReviewStatus reviewStatus, boolean isNew) {
122  this(sleuthkitCase, artifactID, sourceObjId, artifactObjID, artifactTypeID, artifactTypeName, displayName, reviewStatus);
123  if (isNew) {
124  /*
125  * If this object represents a newly created artifact, then its
126  * collection of attributes has already been populated and there is
127  * no need to fetch them form the case database.
128  */
129  this.loadedCacheFromDb = true;
130  }
131  }
132 
140  return sleuthkitCase;
141  }
142 
148  public long getArtifactID() {
149  return this.artifactId;
150  }
151 
158  public long getObjectID() {
159  return this.sourceObjId;
160  }
161 
167  public int getArtifactTypeID() {
168  return this.artifactTypeId;
169  }
170 
176  public String getArtifactTypeName() {
177  return this.artifactTypeName;
178  }
179 
185  public String getDisplayName() {
186  return this.displayName;
187  }
188 
196  public String getShortDescription() throws TskCoreException {
197  BlackboardAttribute attr = null;
198  StringBuilder shortDescription = new StringBuilder("");
199  switch (ARTIFACT_TYPE.fromID(artifactTypeId)) {
200  case TSK_WEB_BOOKMARK: //web_bookmark, web_cookie, web_download, and web_history are the same attribute for now
201  case TSK_WEB_COOKIE:
202  case TSK_WEB_DOWNLOAD:
203  case TSK_WEB_HISTORY:
205  break;
206  case TSK_KEYWORD_HIT:
208  break;
209  case TSK_DEVICE_ATTACHED:
211  break;
212  case TSK_CONTACT: //contact, message, and calllog are the same attributes for now
213  case TSK_MESSAGE:
214  case TSK_CALLLOG:
215  //get the first of these attributes which exists and is non null
216  final ATTRIBUTE_TYPE[] typesThatCanHaveName = {ATTRIBUTE_TYPE.TSK_NAME,
227  ATTRIBUTE_TYPE.TSK_EMAIL_OFFICE}; //in the order we want to use them
228  for (ATTRIBUTE_TYPE t : typesThatCanHaveName) {
229  attr = getAttribute(new BlackboardAttribute.Type(t));
230  if (attr != null && !attr.getDisplayString().isEmpty()) {
231  break;
232  }
233  }
234  break;
235  default:
236  break;
237  }
238  if (attr != null) {
239  shortDescription.append(attr.getAttributeType().getDisplayName()).append(": ").append(attr.getDisplayString());
240  } else {
241  shortDescription.append(getDisplayName());
242  }
243  //get the first of these date attributes which exists and is non null
244  final ATTRIBUTE_TYPE[] typesThatCanHaveDate = {ATTRIBUTE_TYPE.TSK_DATETIME,
251  ATTRIBUTE_TYPE.TSK_DATETIME_END}; //in the order we want to use them
252  BlackboardAttribute date;
253  for (ATTRIBUTE_TYPE t : typesThatCanHaveDate) {
254  date = getAttribute(new BlackboardAttribute.Type(t));
255  if (date != null && !date.getDisplayString().isEmpty()) {
256  shortDescription.append(" ");
257  shortDescription.append(MessageFormat.format(bundle.getString("BlackboardArtifact.shortDescriptionDate.text"), date.getDisplayString())); //NON-NLS
258  break;
259  }
260  }
261  return shortDescription.toString();
262  }
263 
271  return reviewStatus;
272  }
273 
285  public void addAttribute(BlackboardAttribute attribute) throws TskCoreException {
286  attribute.setArtifactId(artifactId);
287  attribute.setCaseDatabase(getSleuthkitCase());
288  getSleuthkitCase().addBlackboardAttribute(attribute, this.artifactTypeId);
289  attrsCache.add(attribute);
290  }
291 
300  public List<BlackboardAttribute> getAttributes() throws TskCoreException {
301  ArrayList<BlackboardAttribute> attributes;
302  if (false == loadedCacheFromDb) {
303  attributes = getSleuthkitCase().getBlackboardAttributes(this);
304  attrsCache.clear();
305  attrsCache.addAll(attributes);
306  loadedCacheFromDb = true;
307  } else {
308  attributes = new ArrayList<BlackboardAttribute>(attrsCache);
309  }
310  return attributes;
311  }
312 
328  List<BlackboardAttribute> attributes = this.getAttributes();
329  for (BlackboardAttribute attribute : attributes) {
330  if (attribute.getAttributeType().equals(attributeType)) {
331  return attribute;
332  }
333  }
334  return null;
335  }
336 
346  public void addAttributes(Collection<BlackboardAttribute> attributes) throws TskCoreException {
347  if (attributes.isEmpty()) {
348  return;
349  }
350  for (BlackboardAttribute attribute : attributes) {
351  attribute.setArtifactId(artifactId);
352  attribute.setCaseDatabase(getSleuthkitCase());
353  }
354  getSleuthkitCase().addBlackboardAttributes(attributes, artifactTypeId);
355  attrsCache.addAll(attributes);
356  }
357 
364  @Override
365  public synchronized String getUniquePath() throws TskCoreException {
366 
367  // Return the path of the parrent file
368  if (uniquePath == null) {
369  uniquePath = "";
370  Content myParent = getParent();
371  if (myParent != null) {
372  uniquePath = myParent.getUniquePath();
373  }
374  }
375  return uniquePath;
376  }
377 
378  @Override
379  public synchronized Content getParent() throws TskCoreException {
380  if (parent == null) {
381  ObjectInfo parentInfo;
382  try {
383  parentInfo = getSleuthkitCase().getParentInfo(this);
384  } catch (TskCoreException ex) {
385  // there is not parent; not an error if we've got a data source
386  return null;
387  }
388  parent = getSleuthkitCase().getContentById(parentInfo.getId());
389  }
390  return parent;
391  }
392 
400  @Override
401  public ArrayList<BlackboardArtifact> getAllArtifacts() throws TskCoreException {
402  // Currently we don't have any artifacts derived from an artifact.
403  return new ArrayList<BlackboardArtifact>();
404  }
405 
416  @Override
417  public ArrayList<BlackboardArtifact> getArtifacts(String artifactTypeName) throws TskCoreException {
418  // Currently we don't have any artifacts derived from an artifact.
419  return new ArrayList<BlackboardArtifact>();
420  }
421 
432  @Override
433  public ArrayList<BlackboardArtifact> getArtifacts(int artifactTypeID) throws TskCoreException {
434  // Currently we don't have any artifacts derived from an artifact.
435  return new ArrayList<BlackboardArtifact>();
436  }
437 
447  @Override
448  public ArrayList<BlackboardArtifact> getArtifacts(BlackboardArtifact.ARTIFACT_TYPE type) throws TskCoreException {
449  // Currently we don't have any artifacts derived from an artifact.
450  return new ArrayList<BlackboardArtifact>();
451  }
452 
460  @Override
461  public long getAllArtifactsCount() throws TskCoreException {
462  // Currently we don't have any artifacts derived from an artifact.
463  return 0;
464  }
465 
476  @Override
477  public long getArtifactsCount(String artifactTypeName) throws TskCoreException {
478  // Currently we don't have any artifacts derived from an artifact.
479  return 0;
480  }
481 
492  @Override
493  public long getArtifactsCount(int artifactTypeID) throws TskCoreException {
494  // Currently we don't have any artifacts derived from an artifact.
495  return 0;
496  }
497 
508  @Override
510  // Currently we don't have any artifacts derived from an artifact.
511  return 0;
512  }
513 
522  @Override
524  // Currently we don't have any artifacts derived from an artifact.
525  return null;
526  }
527 
541  @Override
543  // Currently we don't have any artifacts derived from an artifact.
544  if (create) {
545  throw new TskCoreException("Artifacts of artifacts are not supported.");
546  }
547 
548  return null;
549  }
550 
561  @Override
562  public ArrayList<BlackboardAttribute> getGenInfoAttributes(BlackboardAttribute.ATTRIBUTE_TYPE attr_type) throws TskCoreException {
563  // Currently we don't have any artifacts derived from an artifact.
564  return new ArrayList<BlackboardAttribute>();
565  }
566 
574  @Override
575  public Set<String> getHashSetNames() throws TskCoreException {
576  // Currently we don't have any artifacts derived from an artifact.
577  return new HashSet<String>();
578  }
579 
591  @Override
592  public BlackboardArtifact newArtifact(int artifactTypeID) throws TskCoreException {
593  throw new TskCoreException("Cannot create artifact of an artifact. Not supported.");
594  }
595 
606  @Override
608  throw new TskCoreException("Cannot create artifact of an artifact. Not supported.");
609  }
610 
619  @Override
620  public <T> T accept(ContentVisitor<T> v) {
621  return v.visit(this);
622  }
623 
631  @Override
632  public boolean equals(Object object) {
633  if (object == null) {
634  return false;
635  }
636  if (getClass() != object.getClass()) {
637  return false;
638  }
639  final BlackboardArtifact other = (BlackboardArtifact) object;
640  return artifactId == other.getArtifactID();
641  }
642 
648  @Override
649  public int hashCode() {
650  int hash = 7;
651  hash = 41 * hash + (int) (this.artifactId ^ (this.artifactId >>> 32));
652  return hash;
653  }
654 
660  @Override
661  public String toString() {
662  return "BlackboardArtifact{" + "artifactID=" + artifactId + ", objID=" + getObjectID() + ", artifactObjID=" + artifactObjId + ", artifactTypeID=" + artifactTypeId + ", artifactTypeName=" + artifactTypeName + ", displayName=" + displayName + ", Case=" + getSleuthkitCase() + '}'; //NON-NLS
663  }
664 
675  @Override
676  public <T> T accept(SleuthkitItemVisitor<T> visitor) {
677  return visitor.visit(this);
678  }
679 
686  @Override
687  public long getSize() {
688 
689  if (contentBytes == null) {
690  try {
692  } catch (TskCoreException ex) {
693  return 0;
694  }
695  }
696 
697  return contentBytes.length;
698  }
699 
703  @Override
704  public void close() {
705  contentBytes = null;
706  }
707 
721  @Override
722  public final int read(byte[] buf, long offset, long len) throws TskCoreException {
723 
724  if (contentBytes == null) {
726  }
727 
728  if (0 == contentBytes.length) {
729  return 0;
730  }
731 
732  // Copy bytes
733  long readLen = Math.min(contentBytes.length - offset, len);
734  System.arraycopy(contentBytes, 0, buf, 0, (int) readLen);
735 
736  return (int) readLen;
737  }
738 
739  @Override
740  public String getName() {
741  return this.displayName + getArtifactID();
742  }
743 
744  @Override
746  Content myParent = getParent();
747  if (myParent == null) {
748  return null;
749  }
750 
751  return myParent.getDataSource();
752  }
753 
760  private void loadArtifactContent() throws TskCoreException {
761  StringBuilder artifactContents = new StringBuilder();
762 
763  Content dataSource = null;
764  try {
765  dataSource = getDataSource();
766  } catch (TskCoreException ex) {
767  throw new TskCoreException("Unable to get datasource for artifact: " + this.toString(), ex);
768  }
769  if (dataSource == null) {
770  throw new TskCoreException("Datasource was null for artifact: " + this.toString());
771  }
772 
773  try {
774  for (BlackboardAttribute attribute : getAttributes()) {
775  artifactContents.append(attribute.getAttributeType().getDisplayName());
776  artifactContents.append(" : ");
777  artifactContents.append(attribute.getDisplayString());
778  artifactContents.append(System.lineSeparator());
779  }
780  } catch (TskCoreException ex) {
781  throw new TskCoreException("Unable to get attributes for artifact: " + this.toString(), ex);
782  }
783 
784  try {
785  contentBytes = artifactContents.toString().getBytes("UTF-8");
786  } catch (UnsupportedEncodingException ex) {
787  throw new TskCoreException("Failed to convert artifact string to bytes for artifact: " + this.toString(), ex);
788  }
789 
790  }
791 
795  public static final class Type implements Serializable {
796 
797  private static final long serialVersionUID = 1L;
798  private final String typeName;
799  private final int typeID;
800  private final String displayName;
801 
809  public Type(int typeID, String typeName, String displayName) {
810  this.typeID = typeID;
811  this.typeName = typeName;
812  this.displayName = displayName;
813  }
814 
820  public Type(ARTIFACT_TYPE type) {
821  this(type.getTypeID(), type.getLabel(), type.getDisplayName());
822  }
823 
829  public String getTypeName() {
830  return this.typeName;
831  }
832 
838  public int getTypeID() {
839  return this.typeID;
840  }
841 
847  public String getDisplayName() {
848  return this.displayName;
849  }
850 
858  @Override
859  public boolean equals(Object that) {
860  if (this == that) {
861  return true;
862  } else if (!(that instanceof Type)) {
863  return false;
864  } else {
865  return ((Type) that).sameType(this);
866  }
867  }
868 
876  private boolean sameType(Type that) {
877  return this.typeName.equals(that.getTypeName())
878  && this.displayName.equals(that.getDisplayName())
879  && this.typeID == that.getTypeID();
880  }
881 
887  @Override
888  public int hashCode() {
889  int hash = 11;
890  hash = 83 * hash + Objects.hashCode(this.typeID);
891  hash = 83 * hash + Objects.hashCode(this.displayName);
892  hash = 83 * hash + Objects.hashCode(this.typeName);
893  return hash;
894  }
895  }
896 
902  public enum ARTIFACT_TYPE implements SleuthkitVisitableItem {
903 
907  TSK_GEN_INFO(1, "TSK_GEN_INFO", //NON-NLS
908  bundle.getString("BlackboardArtifact.tskGenInfo.text")),
912  TSK_WEB_BOOKMARK(2, "TSK_WEB_BOOKMARK", //NON-NLS
913  bundle.getString("BlackboardArtifact.tskWebBookmark.text")),
917  TSK_WEB_COOKIE(3, "TSK_WEB_COOKIE",
918  bundle.getString("BlackboardArtifact.tskWebCookie.text")), //NON-NLS
922  TSK_WEB_HISTORY(4, "TSK_WEB_HISTORY", //NON-NLS
923  bundle.getString("BlackboardArtifact.tskWebHistory.text")),
927  TSK_WEB_DOWNLOAD(5, "TSK_WEB_DOWNLOAD", //NON-NLS
928  bundle.getString("BlackboardArtifact.tskWebDownload.text")),
932  TSK_RECENT_OBJECT(6, "TSK_RECENT_OBJ", //NON-NLS
933  bundle.getString("BlackboardArtifact.tsk.recentObject.text")),
937  TSK_GPS_TRACKPOINT(7, "TSK_GPS_TRACKPOINT", //NON-NLS
938  bundle.getString("BlackboardArtifact.tskGpsTrackpoint.text")),
942  TSK_INSTALLED_PROG(8, "TSK_INSTALLED_PROG", //NON-NLS
943  bundle.getString("BlackboardArtifact.tskInstalledProg.text")),
947  TSK_KEYWORD_HIT(9, "TSK_KEYWORD_HIT",
948  bundle.getString("BlackboardArtifact.tskKeywordHits.text")),
952  TSK_HASHSET_HIT(10, "TSK_HASHSET_HIT", //NON-NLS
953  bundle.getString("BlackboardArtifact.tskHashsetHit.text")),
957  TSK_DEVICE_ATTACHED(11, "TSK_DEVICE_ATTACHED", //NON-NLS
958  bundle.getString("BlackboardArtifact.tskDeviceAttached.text")),
963  TSK_INTERESTING_FILE_HIT(12, "TSK_INTERESTING_FILE_HIT", //NON-NLS
964  bundle.getString("BlackboardArtifact.tskInterestingFileHit.text")),
965 
968  TSK_EMAIL_MSG(13, "TSK_EMAIL_MSG", //NON-NLS
969  bundle.getString("BlackboardArtifact.tskEmailMsg.text")),
973  TSK_EXTRACTED_TEXT(14, "TSK_EXTRACTED_TEXT", //NON-NLS
974  bundle.getString("BlackboardArtifact.tskExtractedText.text")),
978  TSK_WEB_SEARCH_QUERY(15, "TSK_WEB_SEARCH_QUERY", //NON-NLS
979  bundle.getString("BlackboardArtifact.tskWebSearchQuery.text")),
983  TSK_METADATA_EXIF(16, "TSK_METADATA_EXIF", //NON-NLS
984  bundle.getString("BlackboardArtifact.tskMetadataExif.text")),
990  @Deprecated
991  TSK_TAG_FILE(17, "TSK_TAG_FILE", //NON-NLS
992  bundle.getString("BlackboardArtifact.tagFile.text")),
998  @Deprecated
999  TSK_TAG_ARTIFACT(18, "TSK_TAG_ARTIFACT", //NON-NLS
1000  bundle.getString("BlackboardArtifact.tskTagArtifact.text")),
1004  TSK_OS_INFO(19, "TSK_OS_INFO", //NON-NLS
1005  bundle.getString("BlackboardArtifact.tskOsInfo.text")),
1009  TSK_OS_ACCOUNT(20, "TSK_OS_ACCOUNT", //NON-NLS
1010  bundle.getString("BlackboardArtifact.tskOsAccount.text")),
1014  TSK_SERVICE_ACCOUNT(21, "TSK_SERVICE_ACCOUNT", //NON-NLS
1015  bundle.getString("BlackboardArtifact.tskServiceAccount.text")),
1021  @Deprecated
1022  TSK_TOOL_OUTPUT(22, "TSK_TOOL_OUTPUT", //NON-NLS
1023  bundle.getString("BlackboardArtifact.tskToolOutput.text")),
1028  TSK_CONTACT(23, "TSK_CONTACT", //NON-NLS
1029  bundle.getString("BlackboardArtifact.tskContact.text")),
1034  TSK_MESSAGE(24, "TSK_MESSAGE", //NON-NLS
1035  bundle.getString("BlackboardArtifact.tskMessage.text")),
1039  TSK_CALLLOG(25, "TSK_CALLLOG", //NON-NLS
1040  bundle.getString("BlackboardArtifact.tskCalllog.text")),
1044  TSK_CALENDAR_ENTRY(26, "TSK_CALENDAR_ENTRY", //NON-NLS
1045  bundle.getString("BlackboardArtifact.tskCalendarEntry.text")),
1049  TSK_SPEED_DIAL_ENTRY(27, "TSK_SPEED_DIAL_ENTRY", //NON-NLS
1050  bundle.getString("BlackboardArtifact.tskSpeedDialEntry.text")),
1054  TSK_BLUETOOTH_PAIRING(28, "TSK_BLUETOOTH_PAIRING", //NON-NLS
1055  bundle.getString("BlackboardArtifact.tskBluetoothPairing.text")),
1059  TSK_GPS_BOOKMARK(29, "TSK_GPS_BOOKMARK", //NON-NLS
1060  bundle.getString("BlackboardArtifact.tskGpsBookmark.text")),
1064  TSK_GPS_LAST_KNOWN_LOCATION(30, "TSK_GPS_LAST_KNOWN_LOCATION", //NON-NLS
1065  bundle.getString("BlackboardArtifact.tskGpsLastKnownLocation.text")),
1069  TSK_GPS_SEARCH(31, "TSK_GPS_SEARCH", //NON-NLS
1070  bundle.getString("BlackboardArtifact.tskGpsSearch.text")),
1074  TSK_PROG_RUN(32, "TSK_PROG_RUN", //NON-NLS
1075  bundle.getString("BlackboardArtifact.tskProgRun.text")),
1079  TSK_ENCRYPTION_DETECTED(33, "TSK_ENCRYPTION_DETECTED", //NON-NLS
1080  bundle.getString("BlackboardArtifact.tskEncryptionDetected.text")),
1084  TSK_EXT_MISMATCH_DETECTED(34, "TSK_EXT_MISMATCH_DETECTED", //NON-NLS
1085  bundle.getString("BlackboardArtifact.tskExtMismatchDetected.text")),
1090  TSK_INTERESTING_ARTIFACT_HIT(35, "TSK_INTERESTING_ARTIFACT_HIT", //NON-NLS
1091  bundle.getString("BlackboardArtifact.tskInterestingArtifactHit.text")),
1095  TSK_GPS_ROUTE(36, "TSK_GPS_ROUTE", //NON-NLS
1096  bundle.getString("BlackboardArtifact.tskGpsRoute.text")),
1100  TSK_REMOTE_DRIVE(37, "TSK_REMOTE_DRIVE", //NON-NLS
1101  bundle.getString("BlackboardArtifact.tskRemoteDrive.text")),
1105  TSK_FACE_DETECTED(38, "TSK_FACE_DETECTED", //NON-NLS
1106  bundle.getString("BlackboardArtifact.tskFaceDetected.text")),
1110  TSK_ACCOUNT(39, "TSK_ACCOUNT", //NON-NLS
1111  bundle.getString("BlackboardArtifact.tskAccount.text"));
1112 
1113  private final String label;
1114  private final int typeId;
1115  private final String displayName;
1116 
1124  private ARTIFACT_TYPE(int typeId, String label, String displayName) {
1125  this.typeId = typeId;
1126  this.label = label;
1127  this.displayName = displayName;
1128  }
1129 
1135  public int getTypeID() {
1136  return this.typeId;
1137  }
1138 
1144  public String getLabel() {
1145  return this.label;
1146  }
1147 
1156  static public ARTIFACT_TYPE fromLabel(String label) {
1157  for (ARTIFACT_TYPE value : ARTIFACT_TYPE.values()) {
1158  if (value.getLabel().equals(label)) {
1159  return value;
1160  }
1161  }
1162  throw new IllegalArgumentException("No ARTIFACT_TYPE matching type: " + label);
1163  }
1164 
1173  static public ARTIFACT_TYPE fromID(int id) {
1174  for (ARTIFACT_TYPE value : ARTIFACT_TYPE.values()) {
1175  if (value.getTypeID() == id) {
1176  return value;
1177  }
1178  }
1179  throw new IllegalArgumentException("No ARTIFACT_TYPE matching type: " + id);
1180  }
1181 
1187  public String getDisplayName() {
1188  return displayName;
1189  }
1190 
1202  @Override
1203  public <T> T accept(SleuthkitItemVisitor<T> visitor) {
1204  return visitor.visit(this);
1205  }
1206 
1207  }
1208 
1212  public enum ReviewStatus {
1213 
1214  APPROVED(1, "APPROVED", "ReviewStatus.Approved"), //approved by human user
1215  REJECTED(2, "REJECTED", "ReviewStatus.Rejected"), //rejected by humna user
1216  UNDECIDED(3, "UNDECIDED", "ReviewStatus.Undecided"); // not yet reviewed by human user
1217 
1218  private final Integer id;
1219  private final String name;
1220  private final String displayName;
1221  private final static Map<Integer, ReviewStatus> idToStatus = new HashMap<Integer, ReviewStatus>();
1222 
1223  static {
1224  for (ReviewStatus status : values()) {
1225  idToStatus.put(status.getID(), status);
1226  }
1227  }
1228 
1237  private ReviewStatus(Integer id, String name, String displayNameKey) {
1238  this.id = id;
1239  this.name = name;
1240  this.displayName = ResourceBundle.getBundle("org.sleuthkit.datamodel.Bundle").getString(displayNameKey);
1241  }
1242 
1250  public static ReviewStatus withID(int id) {
1251  return idToStatus.get(id);
1252  }
1253 
1259  public Integer getID() {
1260  return id;
1261  }
1262 
1268  String getName() {
1269  return name;
1270  }
1271 
1277  public String getDisplayName() {
1278  return displayName;
1279  }
1280  }
1281 
1302  @Deprecated
1303  protected BlackboardArtifact(SleuthkitCase sleuthkitCase, long artifactID, long objID, long artifactObjID, int artifactTypeID, String artifactTypeName, String displayName) {
1304  this(sleuthkitCase, artifactID, objID, artifactObjID, artifactTypeID, artifactTypeName, displayName, ReviewStatus.UNDECIDED);
1305  }
1306 
1321  @Deprecated
1322  public List<BlackboardAttribute> getAttributes(final BlackboardAttribute.ATTRIBUTE_TYPE attributeType) throws TskCoreException {
1323  if (loadedCacheFromDb == false) {
1324  List<BlackboardAttribute> attrs = getSleuthkitCase().getBlackboardAttributes(this);
1325  attrsCache.clear();
1326  attrsCache.addAll(attrs);
1327  loadedCacheFromDb = true;
1328  }
1329  ArrayList<BlackboardAttribute> filteredAttributes = new ArrayList<BlackboardAttribute>();
1330  for (BlackboardAttribute attr : attrsCache) {
1331  if (attr.getAttributeType().getTypeID() == attributeType.getTypeID()) {
1332  filteredAttributes.add(attr);
1333  }
1334  }
1335  return filteredAttributes;
1336  }
1337 
1338  @Override
1339  public long getId() {
1340  return this.artifactObjId;
1341  }
1342 
1351  @Override
1352  public List<Long> getChildrenIds() throws TskCoreException {
1353  List<Long> childrenIDs = new ArrayList<Long>();
1354  childrenIDs.addAll(getSleuthkitCase().getAbstractFileChildrenIds(this));
1355  childrenIDs.addAll(getSleuthkitCase().getBlackboardArtifactChildrenIds(this));
1356 
1357  return childrenIDs;
1358  }
1359 
1360  @Override
1361  public int getChildrenCount() throws TskCoreException {
1362  if (childrenCount != -1) {
1363  return childrenCount;
1364  }
1365 
1366  childrenCount = this.getSleuthkitCase().getContentChildrenCount(this);
1367 
1368  hasChildren = childrenCount > 0;
1369  checkedHasChildren = true;
1370 
1371  return childrenCount;
1372  }
1373 
1374  @Override
1375  public boolean hasChildren() throws TskCoreException {
1376  if (checkedHasChildren == true) {
1377  return hasChildren;
1378  }
1379 
1380  childrenCount = this.getSleuthkitCase().getContentChildrenCount(this);
1381 
1382  hasChildren = childrenCount > 0;
1383  checkedHasChildren = true;
1384 
1385  return hasChildren;
1386  }
1387 
1396  @Override
1397  public List<Content> getChildren() throws TskCoreException {
1398  List<Content> children = new ArrayList<Content>();
1399  children.addAll(getSleuthkitCase().getAbstractFileChildren(this));
1400  children.addAll(getSleuthkitCase().getBlackboardArtifactChildren(this));
1401 
1402  return children;
1403  }
1404 }
ArrayList< BlackboardArtifact > getArtifacts(int artifactTypeID)
ArrayList< BlackboardAttribute > getBlackboardAttributes(final BlackboardArtifact artifact)
void addBlackboardAttributes(Collection< BlackboardAttribute > attributes, int artifactTypeId)
Type(int typeID, String typeName, String displayName)
void addAttributes(Collection< BlackboardAttribute > attributes)
void addBlackboardAttribute(BlackboardAttribute attr, int artifactTypeId)
List< BlackboardAttribute > getAttributes(final BlackboardAttribute.ATTRIBUTE_TYPE attributeType)
final int read(byte[] buf, long offset, long len)
void addAttribute(BlackboardAttribute attribute)
BlackboardArtifact(SleuthkitCase sleuthkitCase, long artifactID, long objID, long artifactObjID, int artifactTypeID, String artifactTypeName, String displayName)
ArrayList< BlackboardArtifact > getArtifacts(BlackboardArtifact.ARTIFACT_TYPE type)
public< T > T accept(SleuthkitItemVisitor< T > visitor)
BlackboardArtifact newArtifact(int artifactTypeID)
BlackboardAttribute getAttribute(BlackboardAttribute.Type attributeType)
ReviewStatus(Integer id, String name, String displayNameKey)
long getArtifactsCount(String artifactTypeName)
BlackboardArtifact getGenInfoArtifact(boolean create)
ARTIFACT_TYPE(int typeId, String label, String displayName)
ArrayList< BlackboardArtifact > getArtifacts(String artifactTypeName)
final List< BlackboardAttribute > attrsCache
ArrayList< BlackboardArtifact > getAllArtifacts()
long getArtifactsCount(BlackboardArtifact.ARTIFACT_TYPE type)
ArrayList< BlackboardAttribute > getGenInfoAttributes(BlackboardAttribute.ATTRIBUTE_TYPE attr_type)
BlackboardArtifact newArtifact(BlackboardArtifact.ARTIFACT_TYPE type)

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