Autopsy  4.7.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 
80  public static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource) throws EamDbException {
81  Case curCase;
82  try {
83  curCase = Case.getCurrentCaseThrows();
84  } catch (NoCurrentCaseException ex) {
85  throw new EamDbException("Autopsy case is closed");
86  }
87  String deviceId;
88  try {
89  deviceId = curCase.getSleuthkitCase().getDataSource(dataSource.getId()).getDeviceId();
90  } catch (TskDataException | TskCoreException ex) {
91  throw new EamDbException("Error getting data source info: " + ex.getMessage());
92  }
93 
94  CorrelationDataSource correlationDataSource = null;
95  if (EamDbUtil.useCentralRepo()) {
96  correlationDataSource = EamDb.getInstance().getDataSource(correlationCase, deviceId);
97  }
98  if (correlationDataSource == null) {
99  correlationDataSource = new CorrelationDataSource(correlationCase, deviceId, dataSource.getName());
100  if (EamDbUtil.useCentralRepo()) {
101  EamDb.getInstance().newDataSource(correlationDataSource);
102  }
103  }
104  return correlationDataSource;
105  }
106 
107  @Override
108  public String toString() {
109  StringBuilder str = new StringBuilder();
110  str.append("(");
111  str.append("ID=").append(Integer.toString(getID()));
112  str.append(",caseID=").append(Integer.toString(getCaseID()));
113  str.append(",deviceID=").append(getDeviceID());
114  str.append(",name=").append(getName());
115  str.append(")");
116  return str.toString();
117  }
118 
124  int getID() {
125  return dataSourceID;
126  }
127 
133  public String getDeviceID() {
134  return deviceID;
135  }
136 
142  public int getCaseID() {
143  return caseID;
144  }
145 
149  public String getName() {
150  return name;
151  }
152 }
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-2016 Basis Technology. Generated on: Mon Jun 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.