Autopsy  4.17.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 CentralRepoException {
114  Case curCase;
115  try {
116  curCase = Case.getCurrentCaseThrows();
117  } catch (NoCurrentCaseException ex) {
118  throw new CentralRepoException("Autopsy case is closed");
119  }
120 
121  CorrelationDataSource correlationDataSource = null;
122  boolean useCR = CentralRepository.isEnabled();
123  if (useCR) {
124  correlationDataSource = CentralRepository.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 CentralRepoException("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 = CentralRepository.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 
223  public void setMd5(String md5Hash) throws CentralRepoException {
224  this.md5Hash = md5Hash;
225 
226  if (dataSourceObjectID != -1) {
228  }
229  }
230 
234  public String getSha1() {
235  return (sha1Hash == null ? "" : sha1Hash);
236  }
237 
244  public void setSha1(String sha1Hash) throws CentralRepoException {
245  this.sha1Hash = sha1Hash;
246 
247  if (dataSourceObjectID != -1) {
249  }
250  }
251 
255  public String getSha256() {
256  return (sha256Hash == null ? "" : sha256Hash);
257  }
258 
265  public void setSha256(String sha256Hash) throws CentralRepoException {
266  this.sha256Hash = sha256Hash;
267 
268  if (dataSourceObjectID != -1) {
270  }
271  }
272 }
static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource)
CorrelationDataSource(CorrelationCase correlationCase, String deviceId, String name, Long dataSourceObjectId, String md5Hash, String sha1Hash, String sha256Hash)
void updateDataSourceSha1Hash(CorrelationDataSource eamDataSource)
void updateDataSourceMd5Hash(CorrelationDataSource eamDataSource)
CorrelationDataSource newDataSource(CorrelationDataSource eamDataSource)
CorrelationDataSource getDataSource(CorrelationCase correlationCase, Long caseDbDataSourceId)
void updateDataSourceSha256Hash(CorrelationDataSource eamDataSource)

Copyright © 2012-2021 Basis Technology. Generated on: Tue Jan 19 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.