Autopsy  4.5.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
StixArtifactData.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013 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.autopsy.modules.stix;
20 
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.logging.Level;
24 import org.openide.util.NbBundle.Messages;
29 import org.sleuthkit.datamodel.AbstractFile;
30 import org.sleuthkit.datamodel.BlackboardArtifact;
31 import org.sleuthkit.datamodel.BlackboardAttribute;
32 import org.sleuthkit.datamodel.SleuthkitCase;
33 import org.sleuthkit.datamodel.TskCoreException;
34 
38 class StixArtifactData {
39 
40  private AbstractFile file;
41  private final String observableId;
42  private final String objType;
43  private static final Logger logger = Logger.getLogger(StixArtifactData.class.getName());
44 
45  public StixArtifactData(AbstractFile a_file, String a_observableId, String a_objType) {
46  file = a_file;
47  observableId = a_observableId;
48  objType = a_objType;
49  }
50 
51  public StixArtifactData(long a_objId, String a_observableId, String a_objType) {
52  Case case1 = Case.getCurrentCase();
53  SleuthkitCase sleuthkitCase = case1.getSleuthkitCase();
54  try {
55  file = sleuthkitCase.getAbstractFileById(a_objId);
56  } catch (TskCoreException ex) {
57  file = null;
58  }
59  observableId = a_observableId;
60  objType = a_objType;
61  }
62 
63  @Messages({"StixArtifactData.indexError.message=Failed to index STIX interesting file hit artifact for keyword search."})
64  public void createArtifact(String a_title) throws TskCoreException {
65  Blackboard blackboard = Case.getCurrentCase().getServices().getBlackboard();
66 
67  String setName;
68  if (a_title != null) {
69  setName = "STIX Indicator - " + a_title; //NON-NLS
70  } else {
71  setName = "STIX Indicator - (no title)"; //NON-NLS
72  }
73 
74  BlackboardArtifact bba = file.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT);
75  Collection<BlackboardAttribute> attributes = new ArrayList<>();
76  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME, "Stix", setName)); //NON-NLS
77  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TITLE, "Stix", observableId)); //NON-NLS
78  attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY, "Stix", objType)); //NON-NLS
79 
80  bba.addAttributes(attributes);
81  try {
82  // index the artifact for keyword search
83  blackboard.indexArtifact(bba);
84  } catch (Blackboard.BlackboardException ex) {
85  logger.log(Level.SEVERE, "Unable to index blackboard artifact " + bba.getArtifactID(), ex); //NON-NLS
86  MessageNotifyUtil.Notify.error(Bundle.StixArtifactData_indexError_message(), bba.getDisplayName());
87  }
88  }
89 
90  public void print() {
91  System.out.println(" " + observableId + " " + file.getName());
92  }
93 }

Copyright © 2012-2016 Basis Technology. Generated on: Tue Feb 20 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.