Autopsy  4.8.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-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 String deviceID; //< Unique to its associated case (not necessarily globally unique)
40  private final String name;
41 
47  public CorrelationDataSource(CorrelationCase correlationCase, String deviceId, String name) {
48  this(correlationCase.getID(), -1, deviceId, name);
49  }
50 
58  CorrelationDataSource(int caseId,
59  int dataSourceId,
60  String deviceId,
61  String name) {
62  this.caseID = caseId;
63  this.dataSourceID = dataSourceId;
64  this.deviceID = deviceId;
65  this.name = name;
66  }
67 
81  public static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource) throws EamDbException {
82  Case curCase;
83  try {
84  curCase = Case.getCurrentCaseThrows();
85  } catch (NoCurrentCaseException ex) {
86  throw new EamDbException("Autopsy case is closed");
87  }
88  String deviceId;
89  try {
90  deviceId = curCase.getSleuthkitCase().getDataSource(dataSource.getId()).getDeviceId();
91  } catch (TskDataException | TskCoreException ex) {
92  throw new EamDbException("Error getting data source info: " + ex.getMessage());
93  }
94 
95  CorrelationDataSource correlationDataSource = null;
96  if (EamDbUtil.useCentralRepo()) {
97  correlationDataSource = EamDb.getInstance().getDataSource(correlationCase, deviceId);
98  }
99  if (correlationDataSource == null) {
100  correlationDataSource = new CorrelationDataSource(correlationCase, deviceId, dataSource.getName());
101  if (EamDbUtil.useCentralRepo()) {
102  EamDb.getInstance().newDataSource(correlationDataSource);
103  }
104  }
105  return correlationDataSource;
106  }
107 
108  @Override
109  public String toString() {
110  StringBuilder str = new StringBuilder();
111  str.append("(");
112  str.append("ID=").append(Integer.toString(getID()));
113  str.append(",caseID=").append(Integer.toString(getCaseID()));
114  str.append(",deviceID=").append(getDeviceID());
115  str.append(",name=").append(getName());
116  str.append(")");
117  return str.toString();
118  }
119 
125  int getID() {
126  return dataSourceID;
127  }
128 
134  public String getDeviceID() {
135  return deviceID;
136  }
137 
143  public int getCaseID() {
144  return caseID;
145  }
146 
150  public String getName() {
151  return name;
152  }
153 }
CorrelationDataSource getDataSource(CorrelationCase correlationCase, String dataSourceDeviceId)
CorrelationDataSource(CorrelationCase correlationCase, String deviceId, String name)
static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource)
void newDataSource(CorrelationDataSource eamDataSource)

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