Autopsy  4.5.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-2017 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;
23 import org.sleuthkit.datamodel.Content;
24 import org.sleuthkit.datamodel.TskCoreException;
25 import org.sleuthkit.datamodel.TskDataException;
26 
32 public class CorrelationDataSource implements Serializable {
33 
34  private static final long serialVersionUID = 1L;
35 
36  private final int caseID; //the value in the id column of the case table in the central repo
37  private final int dataSourceID; //< Id in the central repo
38  private final String deviceID; //< Unique to its associated case (not necessarily globally unique)
39  private final String name;
40 
47  public CorrelationDataSource(int caseId, String deviceId, String name) {
48  this(caseId, -1, deviceId, name);
49  }
50 
51  CorrelationDataSource(int caseId,
52  int dataSourceId,
53  String deviceId,
54  String name) {
55  this.caseID = caseId;
56  this.dataSourceID = dataSourceId;
57  this.deviceID = deviceId;
58  this.name = name;
59  }
60 
73  public static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource) throws EamDbException {
74  Case curCase;
75  try {
76  curCase = Case.getCurrentCase();
77  } catch (IllegalStateException ex) {
78  throw new EamDbException("Autopsy case is closed");
79  }
80  String deviceId;
81  try {
82  deviceId = curCase.getSleuthkitCase().getDataSource(dataSource.getId()).getDeviceId();
83  } catch (TskDataException | TskCoreException ex) {
84  throw new EamDbException("Error getting data source info: " + ex.getMessage());
85  }
86  return new CorrelationDataSource(correlationCase.getID(), -1, deviceId, dataSource.getName());
87  }
88 
89  @Override
90  public String toString() {
91  StringBuilder str = new StringBuilder();
92  str.append("(");
93  str.append("ID=").append(Integer.toString(getID()));
94  str.append(",caseID=").append(Integer.toString(getCaseID()));
95  str.append(",deviceID=").append(getDeviceID());
96  str.append(",name=").append(getName());
97  str.append(")");
98  return str.toString();
99  }
100 
106  int getID() {
107  return dataSourceID;
108  }
109 
115  public String getDeviceID() {
116  return deviceID;
117  }
118 
124  public int getCaseID() {
125  return caseID;
126  }
127 
131  public String getName() {
132  return name;
133  }
134 }
static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource)

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