Autopsy  4.11.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
CorrelationDataSource.java
Go to the documentation of this file.
1 /*
2  * Central Repository
3  *
4  * Copyright 2015-2019 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.centralrepository.datamodel;
20 
21 import java.io.Serializable;
24 import org.sleuthkit.datamodel.Content;
25 import org.sleuthkit.datamodel.Image;
26 import org.sleuthkit.datamodel.TskCoreException;
27 import org.sleuthkit.datamodel.TskDataException;
28 
34 public class CorrelationDataSource implements Serializable {
35 
36  private static final long serialVersionUID = 1L;
37 
38  private final int caseID; //the value in the id column of the case table in the central repo
39  private final int dataSourceID; //< Id in the central repo
40  private final Long dataSourceObjectID; //< Id for data source in the caseDB
41  private final String deviceID; //< Unique to its associated case (not necessarily globally unique)
42  private final String name;
43  private String md5Hash;
44  private String sha1Hash;
45  private String sha256Hash;
46 
60  public CorrelationDataSource(CorrelationCase correlationCase,
61  String deviceId,
62  String name,
63  Long dataSourceObjectId,
64  String md5Hash,
65  String sha1Hash,
66  String sha256Hash) {
67  this(correlationCase.getID(), -1, deviceId, name, dataSourceObjectId, md5Hash, sha1Hash, sha256Hash);
68  }
69 
82  CorrelationDataSource(int caseId,
83  int dataSourceId,
84  String deviceId,
85  String name,
86  Long dataSourceObjectId,
87  String md5Hash,
88  String sha1Hash,
89  String sha256Hash) {
90  this.caseID = caseId;
91  this.dataSourceID = dataSourceId;
92  this.deviceID = deviceId;
93  this.name = name;
94  this.dataSourceObjectID = dataSourceObjectId;
95  this.md5Hash = md5Hash;
96  this.sha1Hash = sha1Hash;
97  this.sha256Hash = sha256Hash;
98  }
99 
113  public static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource) throws EamDbException {
114  Case curCase;
115  try {
116  curCase = Case.getCurrentCaseThrows();
117  } catch (NoCurrentCaseException ex) {
118  throw new EamDbException("Autopsy case is closed");
119  }
120 
121  CorrelationDataSource correlationDataSource = null;
122  boolean useCR = EamDb.isEnabled();
123  if (useCR) {
124  correlationDataSource = EamDb.getInstance().getDataSource(correlationCase, dataSource.getId());
125  }
126 
127  if (correlationDataSource == null) {
128  String deviceId;
129  String md5 = null;
130  String sha1 = null;
131  String sha256 = null;
132  try {
133  deviceId = curCase.getSleuthkitCase().getDataSource(dataSource.getId()).getDeviceId();
134 
135  if (dataSource instanceof Image) {
136  Image image = (Image) dataSource;
137  md5 = image.getMd5();
138  sha1 = image.getSha1();
139  sha256 = image.getSha256();
140  }
141  } catch (TskDataException | TskCoreException ex) {
142  throw new EamDbException("Error getting data source info: " + ex.getMessage());
143  }
144 
145  correlationDataSource = new CorrelationDataSource(correlationCase, deviceId, dataSource.getName(), dataSource.getId(), md5, sha1, sha256);
146  if (useCR) {
147  //add the correlation data source to the central repository and fill in the Central repository data source id in the object
148  correlationDataSource = EamDb.getInstance().newDataSource(correlationDataSource);
149  }
150  }
151  return correlationDataSource;
152  }
153 
154  @Override
155  public String toString() {
156  StringBuilder str = new StringBuilder();
157  str.append("(");
158  str.append("ID=").append(Integer.toString(getID()));
159  str.append(",caseID=").append(Integer.toString(getCaseID()));
160  str.append(",deviceID=").append(getDeviceID());
161  str.append(",name=").append(getName());
162  str.append(")");
163  return str.toString();
164  }
165 
171  public int getID() {
172  return dataSourceID;
173  }
174 
180  public String getDeviceID() {
181  return deviceID;
182  }
183 
189  public int getCaseID() {
190  return caseID;
191  }
192 
198  public Long getDataSourceObjectID() {
199  return dataSourceObjectID;
200  }
201 
205  public String getName() {
206  return name;
207  }
208 
212  public String getMd5() {
213  return (md5Hash == null ? "" : md5Hash);
214  }
215 
224  public void setMd5(String md5Hash) throws EamDbException {
225  this.md5Hash = md5Hash;
226 
227  if (dataSourceObjectID != -1) {
229  }
230  }
231 
235  public String getSha1() {
236  return (sha1Hash == null ? "" : sha1Hash);
237  }
238 
245  public void setSha1(String sha1Hash) throws EamDbException {
246  this.sha1Hash = sha1Hash;
247 
248  if (dataSourceObjectID != -1) {
250  }
251  }
252 
256  public String getSha256() {
257  return (sha256Hash == null ? "" : sha256Hash);
258  }
259 
266  public void setSha256(String sha256Hash) throws EamDbException {
267  this.sha256Hash = sha256Hash;
268 
269  if (dataSourceObjectID != -1) {
271  }
272  }
273 }
CorrelationDataSource newDataSource(CorrelationDataSource eamDataSource)
void updateDataSourceSha1Hash(CorrelationDataSource eamDataSource)
static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource)
void updateDataSourceSha256Hash(CorrelationDataSource eamDataSource)
CorrelationDataSource(CorrelationCase correlationCase, String deviceId, String name, Long dataSourceObjectId, String md5Hash, String sha1Hash, String sha256Hash)
CorrelationDataSource getDataSource(CorrelationCase correlationCase, Long caseDbDataSourceId)
void updateDataSourceMd5Hash(CorrelationDataSource eamDataSource)

Copyright © 2012-2018 Basis Technology. Generated on: Fri Jun 21 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.