19 package org.sleuthkit.autopsy.test;
21 import java.util.ArrayList;
22 import java.util.List;
23 import javax.xml.bind.DatatypeConverter;
35 final class CustomArtifactType {
37 private static final String MODULE_NAME = CustomArtifactsCreatorIngestModuleFactory.getModuleName();
38 private static final String ADDITIONAL_MODULE_NAME =
"Another Module";
39 private static final String ARTIFACT_TYPE_NAME =
"CUSTOM_ARTIFACT";
40 private static final String ARTIFACT_DISPLAY_NAME =
"Custom Artifact";
41 private static final String INT_ATTR_TYPE_NAME =
"CUSTOM_INT_ATTRIBUTE";
42 private static final String INT_ATTR_DISPLAY_NAME =
"Custom Integer";
43 private static final String DOUBLE_ATTR_TYPE_NAME =
"CUSTOM_DOUBLE_ATTRIBUTE";
44 private static final String DOUBLE_ATTR_DISPLAY_NAME =
"Custom Double";
45 private static final String LONG_ATTR_TYPE_NAME =
"CUSTOM_LONG_ATTRIBUTE";
46 private static final String LONG_ATTR_DISPLAY_NAME =
"Custom Long";
47 private static final String DATETIME_ATTR_TYPE_NAME =
"CUSTOM_DATETIME_ATTRIBUTE";
48 private static final String DATETIME_ATTR_DISPLAY_NAME =
"Custom Datetime";
49 private static final String BYTES_ATTR_TYPE_NAME =
"CUSTOM_BYTES_ATTRIBUTE";
50 private static final String BYTES_ATTR_DISPLAY_NAME =
"Custom Bytes";
51 private static final String STRING_ATTR_TYPE_NAME =
"CUSTOM_STRING_ATTRIBUTE";
52 private static final String STRING_ATTR_DISPLAY_NAME =
"Custom String";
53 private static BlackboardArtifact.Type artifactType;
54 private static BlackboardAttribute.Type intAttrType;
55 private static BlackboardAttribute.Type doubleAttrType;
56 private static BlackboardAttribute.Type longAttributeType;
57 private static BlackboardAttribute.Type dateTimeAttrType;
58 private static BlackboardAttribute.Type bytesAttrType;
59 private static BlackboardAttribute.Type stringAttrType;
67 static void addToCaseDatabase() throws Blackboard.BlackboardException, NoCurrentCaseException {
68 Blackboard blackboard = Case.getCurrentCaseThrows().getServices().getBlackboard();
69 artifactType = blackboard.getOrAddArtifactType(ARTIFACT_TYPE_NAME, ARTIFACT_DISPLAY_NAME);
70 intAttrType = blackboard.getOrAddAttributeType(INT_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.INTEGER, INT_ATTR_DISPLAY_NAME);
71 doubleAttrType = blackboard.getOrAddAttributeType(DOUBLE_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DOUBLE, DOUBLE_ATTR_DISPLAY_NAME);
72 longAttributeType = blackboard.getOrAddAttributeType(LONG_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.LONG, LONG_ATTR_DISPLAY_NAME);
73 dateTimeAttrType = blackboard.getOrAddAttributeType(DATETIME_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME, DATETIME_ATTR_DISPLAY_NAME);
74 bytesAttrType = blackboard.getOrAddAttributeType(BYTES_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.BYTE, BYTES_ATTR_DISPLAY_NAME);
75 stringAttrType = blackboard.getOrAddAttributeType(STRING_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.STRING, STRING_ATTR_DISPLAY_NAME);
87 static BlackboardArtifact createInstance(Content source)
throws TskCoreException {
88 BlackboardArtifact artifact = source.newArtifact(artifactType.getTypeID());
89 List<BlackboardAttribute> attributes =
new ArrayList<>();
90 attributes.add(
new BlackboardAttribute(intAttrType, MODULE_NAME, 0));
91 attributes.add(
new BlackboardAttribute(doubleAttrType, MODULE_NAME, 0.0));
92 attributes.add(
new BlackboardAttribute(longAttributeType, MODULE_NAME, 0L));
93 attributes.add(
new BlackboardAttribute(dateTimeAttrType, MODULE_NAME, 60L));
94 attributes.add(
new BlackboardAttribute(bytesAttrType, MODULE_NAME, DatatypeConverter.parseHexBinary(
"ABCD")));
95 attributes.add(
new BlackboardAttribute(stringAttrType, MODULE_NAME,
"Zero"));
96 artifact.addAttributes(attributes);
102 for (BlackboardAttribute attr : attributes) {
103 attr.addSource(ADDITIONAL_MODULE_NAME);
104 attr.addSource(ADDITIONAL_MODULE_NAME);
113 private CustomArtifactType() {