Autopsy  4.9.1
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-2018 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.TskCoreException;
26 import org.sleuthkit.datamodel.TskDataException;
27 
33 public class CorrelationDataSource implements Serializable {
34 
35  private static final long serialVersionUID = 1L;
36 
37  private final int caseID; //the value in the id column of the case table in the central repo
38  private final int dataSourceID; //< Id in the central repo
39  private final Long dataSourceObjectID; //< Id for data source in the caseDB
40  private final String deviceID; //< Unique to its associated case (not necessarily globally unique)
41  private final String name;
42 
54  public CorrelationDataSource(CorrelationCase correlationCase, String deviceId, String name, long dataSourceObjectId) {
55  this(correlationCase.getID(), -1, deviceId, name, dataSourceObjectId);
56  }
57 
67  CorrelationDataSource(int caseId,
68  int dataSourceId,
69  String deviceId,
70  String name,
71  Long dataSourceObjectId) {
72  this.caseID = caseId;
73  this.dataSourceID = dataSourceId;
74  this.deviceID = deviceId;
75  this.name = name;
76  this.dataSourceObjectID = dataSourceObjectId;
77  }
78 
92  public static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource) throws EamDbException {
93  Case curCase;
94  try {
95  curCase = Case.getCurrentCaseThrows();
96  } catch (NoCurrentCaseException ex) {
97  throw new EamDbException("Autopsy case is closed");
98  }
99 
100  CorrelationDataSource correlationDataSource = null;
101  boolean useCR = EamDbUtil.useCentralRepo();
102  if (useCR) {
103  correlationDataSource = EamDb.getInstance().getDataSource(correlationCase, dataSource.getId());
104  }
105 
106  if (correlationDataSource == null) {
107  String deviceId;
108  try {
109  deviceId = curCase.getSleuthkitCase().getDataSource(dataSource.getId()).getDeviceId();
110  } catch (TskDataException | TskCoreException ex) {
111  throw new EamDbException("Error getting data source info: " + ex.getMessage());
112  }
113  correlationDataSource = new CorrelationDataSource(correlationCase, deviceId, dataSource.getName(), dataSource.getId());
114  if (useCR) {
115  //add the correlation data source to the central repository and fill in the Central repository data source id in the object
116  correlationDataSource = EamDb.getInstance().newDataSource(correlationDataSource);
117  }
118  }
119  return correlationDataSource;
120  }
121 
122  @Override
123  public String toString() {
124  StringBuilder str = new StringBuilder();
125  str.append("(");
126  str.append("ID=").append(Integer.toString(getID()));
127  str.append(",caseID=").append(Integer.toString(getCaseID()));
128  str.append(",deviceID=").append(getDeviceID());
129  str.append(",name=").append(getName());
130  str.append(")");
131  return str.toString();
132  }
133 
139  int getID() {
140  return dataSourceID;
141  }
142 
148  public String getDeviceID() {
149  return deviceID;
150  }
151 
157  public int getCaseID() {
158  return caseID;
159  }
160 
166  public Long getDataSourceObjectID() {
167  return dataSourceObjectID;
168  }
169 
173  public String getName() {
174  return name;
175  }
176 }
CorrelationDataSource newDataSource(CorrelationDataSource eamDataSource)
static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource)
CorrelationDataSource getDataSource(CorrelationCase correlationCase, Long caseDbDataSourceId)
CorrelationDataSource(CorrelationCase correlationCase, String deviceId, String name, long dataSourceObjectId)

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