Autopsy  4.18.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
CentralRepositoryService.java
Go to the documentation of this file.
1 /*
2  * Central Repository
3  *
4  * Copyright 2018-2020 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 org.openide.util.NbBundle;
22 import org.openide.util.lookup.ServiceProvider;
28 import org.sleuthkit.datamodel.Content;
29 import org.sleuthkit.datamodel.DataSource;
30 import org.sleuthkit.datamodel.TskCoreException;
31 
35 @ServiceProvider(service = AutopsyService.class)
36 public class CentralRepositoryService implements AutopsyService {
37 
38  private CaseEventListener caseEventListener = new CaseEventListener();
39  private IngestEventsListener ingestEventListener = new IngestEventsListener();
40 
41  @Override
42  @NbBundle.Messages({
43  "CentralRepositoryService.serviceName=Central Repository Service"
44  })
45  public String getServiceName() {
46  return Bundle.CentralRepositoryService_serviceName();
47  }
48 
49  @NbBundle.Messages({
50  "CentralRepositoryService.progressMsg.updatingSchema=Checking for schema updates..."
51  })
52  @Override
55  return;
56  }
57 
58  ProgressIndicator progress = context.getProgressIndicator();
59  progress.progress(Bundle.CentralRepositoryService_progressMsg_updatingSchema());
60  updateSchema();
61 
62  if (context.cancelRequested()) {
63  return;
64  }
65 
66  dataUpgradeForVersion1dot2(context.getCase());
67 
68  caseEventListener = new CaseEventListener();
69  caseEventListener.installListeners();
70 
71  ingestEventListener = new IngestEventsListener();
72  ingestEventListener.installListeners();
73 
74  }
75 
76  @NbBundle.Messages({
77  "CentralRepositoryService.progressMsg.waitingForListeners=Finishing adding data to central repository database...."
78  })
79  @Override
81  ProgressIndicator progress = context.getProgressIndicator();
82  progress.progress(Bundle.CentralRepositoryService_progressMsg_waitingForListeners());
83 
84  if (caseEventListener != null) {
85  caseEventListener.uninstallListeners();
86  caseEventListener.shutdown();
87  }
88 
89  if (ingestEventListener != null) {
90  ingestEventListener.uninstallListeners();
91  ingestEventListener.shutdown();
92  }
93  }
94 
100  private void updateSchema() throws AutopsyServiceException {
101  try {
103  } catch (CentralRepoException ex) {
104  throw new AutopsyServiceException("Failed to update the Central Repository schema", ex);
105  }
106  }
107 
115  private void dataUpgradeForVersion1dot2(Case currentCase) throws AutopsyServiceException {
116  try {
117  /*
118  * If the case is in the central repository, there may be missing
119  * data source object IDs in the data_sources.datasource_obj_id
120  * column that was added in the version 1.2 schema update.
121  */
122  CentralRepository centralRepository = CentralRepository.getInstance();
123  CorrelationCase correlationCase = centralRepository.getCase(currentCase);
124  if (correlationCase != null) {
125  for (CorrelationDataSource correlationDataSource : centralRepository.getDataSources()) {
126  /*
127  * ResultSet.getLong returns zero when the value in the
128  * result set is NULL.
129  */
130  if (correlationDataSource.getCaseID() == correlationCase.getID() && correlationDataSource.getDataSourceObjectID() == 0) {
131  for (Content dataSource : currentCase.getDataSources()) {
132  if (((DataSource) dataSource).getDeviceId().equals(correlationDataSource.getDeviceID()) && dataSource.getName().equals(correlationDataSource.getName())) {
133  centralRepository.addDataSourceObjectId(correlationDataSource.getID(), dataSource.getId());
134  break;
135  }
136  }
137  }
138  }
139  }
140  } catch (CentralRepoException | TskCoreException ex) {
141  throw new AutopsyServiceException("Failed to update data sources in the Central Repository for schema v1.2", ex);
142  }
143  }
144 
145 }
void addDataSourceObjectId(int rowId, long dataSourceObjectId)

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