Autopsy  4.19.3
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-2021 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 
115  public static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource) throws CentralRepoException {
116  if (!CentralRepository.isEnabled()) {
117  throw new CentralRepoException(String.format("Central repository is not enabled, cannot create central repository data source for '%s'", dataSource));
118  }
119 
120  Case curCase;
121  try {
122  curCase = Case.getCurrentCaseThrows();
123  } catch (NoCurrentCaseException ex) {
124  throw new CentralRepoException("Error getting current case", ex);
125  }
126 
127  CorrelationDataSource correlationDataSource = CentralRepository.getInstance().getDataSource(correlationCase, dataSource.getId());
128  if (correlationDataSource == null) {
129  String deviceId;
130  String md5 = null;
131  String sha1 = null;
132  String sha256 = null;
133  try {
134  deviceId = curCase.getSleuthkitCase().getDataSource(dataSource.getId()).getDeviceId();
135 
136  if (dataSource instanceof Image) {
137  Image image = (Image) dataSource;
138  md5 = image.getMd5();
139  sha1 = image.getSha1();
140  sha256 = image.getSha256();
141  }
142  } catch (TskDataException | TskCoreException ex) {
143  throw new CentralRepoException("Error getting data source info from case database", ex);
144  }
145  correlationDataSource = new CorrelationDataSource(correlationCase, deviceId, dataSource.getName(), dataSource.getId(), md5, sha1, sha256);
146  correlationDataSource = CentralRepository.getInstance().newDataSource(correlationDataSource);
147  }
148 
149  return correlationDataSource;
150  }
151 
152  @Override
153  public String toString() {
154  StringBuilder str = new StringBuilder();
155  str.append("(");
156  str.append("ID=").append(Integer.toString(getID()));
157  str.append(",caseID=").append(Integer.toString(getCaseID()));
158  str.append(",deviceID=").append(getDeviceID());
159  str.append(",name=").append(getName());
160  str.append(")");
161  return str.toString();
162  }
163 
169  public int getID() {
170  return dataSourceID;
171  }
172 
178  public String getDeviceID() {
179  return deviceID;
180  }
181 
187  public int getCaseID() {
188  return caseID;
189  }
190 
196  public Long getDataSourceObjectID() {
197  return dataSourceObjectID;
198  }
199 
203  public String getName() {
204  return name;
205  }
206 
210  public String getMd5() {
211  return (md5Hash == null ? "" : md5Hash);
212  }
213 
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-2022 Basis Technology. Generated on: Sun Sep 25 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.