19 package org.sleuthkit.autopsy.modules.stix;
 
   21 import java.util.ArrayList;
 
   22 import java.util.Collection;
 
   23 import java.util.logging.Level;
 
   24 import org.openide.util.NbBundle.Messages;
 
   39 class StixArtifactData {
 
   41     private AbstractFile file;
 
   42     private final String observableId;
 
   43     private final String objType;
 
   44     private static final Logger logger = Logger.getLogger(StixArtifactData.class.getName());
 
   46     public StixArtifactData(AbstractFile a_file, String a_observableId, String a_objType) {
 
   48         observableId = a_observableId;
 
   52     public StixArtifactData(
long a_objId, String a_observableId, String a_objType) {
 
   54             Case case1 = Case.getCurrentCaseThrows();
 
   55             SleuthkitCase sleuthkitCase = case1.getSleuthkitCase();
 
   56             file = sleuthkitCase.getAbstractFileById(a_objId);
 
   57         } 
catch (TskCoreException | NoCurrentCaseException ex) {
 
   60         observableId = a_observableId;
 
   64     @Messages({
"StixArtifactData.indexError.message=Failed to index STIX interesting file hit artifact for keyword search.",
 
   65             "StixArtifactData.noOpenCase.errMsg=No open case available."})
 
   66     public void createArtifact(String a_title) 
throws TskCoreException {
 
   69             currentCase = Case.getCurrentCaseThrows();
 
   70         } 
catch (NoCurrentCaseException ex) {
 
   71             logger.log(Level.SEVERE, 
"Exception while getting open case.", ex); 
 
   72             MessageNotifyUtil.Notify.error(Bundle.StixArtifactData_noOpenCase_errMsg(), ex.getLocalizedMessage());
 
   77         if (a_title != null) {
 
   78             setName = 
"STIX Indicator - " + a_title; 
 
   80             setName = 
"STIX Indicator - (no title)"; 
 
   83         Collection<BlackboardAttribute> attributes = 
new ArrayList<>();
 
   84         attributes.add(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME, 
"Stix", setName)); 
 
   85         attributes.add(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TITLE, 
"Stix", observableId)); 
 
   86         attributes.add(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY, 
"Stix", objType)); 
 
   88         org.
sleuthkit.datamodel.Blackboard tskBlackboard = currentCase.getSleuthkitCase().getBlackboard();
 
   90         if (!tskBlackboard.artifactExists(file, BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT, attributes)) {
 
   91             BlackboardArtifact bba = file.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT);
 
   92             bba.addAttributes(attributes);
 
   96                 Blackboard blackboard = currentCase.getServices().getBlackboard();
 
   97                 blackboard.indexArtifact(bba);
 
   98             } 
catch (Blackboard.BlackboardException ex) {
 
   99                 logger.log(Level.SEVERE, 
"Unable to index blackboard artifact " + bba.getArtifactID(), ex); 
 
  100                 MessageNotifyUtil.Notify.error(Bundle.StixArtifactData_indexError_message(), bba.getDisplayName());
 
  105     public void print() {
 
  106         System.out.println(
"  " + observableId + 
" " + file.getName());