Autopsy  4.1
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.logging.Level;
22 import org.openide.util.NbBundle.Messages;
27 import org.sleuthkit.datamodel.AbstractFile;
28 import org.sleuthkit.datamodel.BlackboardArtifact;
29 import org.sleuthkit.datamodel.BlackboardAttribute;
30 import org.sleuthkit.datamodel.SleuthkitCase;
31 import org.sleuthkit.datamodel.TskCoreException;
32 
36 class StixArtifactData {
37 
38  private AbstractFile file;
39  private final String observableId;
40  private final String objType;
41  private static final Logger logger = Logger.getLogger(StixArtifactData.class.getName());
42 
43  public StixArtifactData(AbstractFile a_file, String a_observableId, String a_objType) {
44  file = a_file;
45  observableId = a_observableId;
46  objType = a_objType;
47  }
48 
49  public StixArtifactData(long a_objId, String a_observableId, String a_objType) {
50  Case case1 = Case.getCurrentCase();
51  SleuthkitCase sleuthkitCase = case1.getSleuthkitCase();
52  try {
53  file = sleuthkitCase.getAbstractFileById(a_objId);
54  } catch (TskCoreException ex) {
55  file = null;
56  }
57  observableId = a_observableId;
58  objType = a_objType;
59  }
60 
61  @Messages({"StixArtifactData.indexError.message=Failed to index STIX interesting file hit artifact for keyword search."})
62  public void createArtifact(String a_title) throws TskCoreException {
63  Blackboard blackboard = Case.getCurrentCase().getServices().getBlackboard();
64 
65  String setName;
66  if (a_title != null) {
67  setName = "STIX Indicator - " + a_title; //NON-NLS
68  } else {
69  setName = "STIX Indicator - (no title)"; //NON-NLS
70  }
71 
72  BlackboardArtifact bba = file.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT);
73  bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME, "Stix", setName)); //NON-NLS
74  bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TITLE, "Stix", observableId)); //NON-NLS
75  bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY, "Stix", objType)); //NON-NLS
76 
77  try {
78  // index the artifact for keyword search
79  blackboard.indexArtifact(bba);
80  } catch (Blackboard.BlackboardException ex) {
81  logger.log(Level.SEVERE, "Unable to index blackboard artifact " + bba.getArtifactID(), ex); //NON-NLS
82  MessageNotifyUtil.Notify.error(Bundle.StixArtifactData_indexError_message(), bba.getDisplayName());
83  }
84  }
85 
86  public void print() {
87  System.out.println(" " + observableId + " " + file.getName());
88  }
89 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon Jan 2 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.