Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
CRDefaultSetupAction.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2017-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 */
19package org.sleuthkit.autopsy.centralrepository.eventlisteners;
20
21import java.lang.reflect.InvocationTargetException;
22import java.util.Map;
23import java.util.logging.Level;
24import javax.swing.JOptionPane;
25import javax.swing.SwingUtilities;
26import org.openide.util.NbBundle;
27import org.sleuthkit.autopsy.centralrepository.CentralRepoSettings;
28import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbChoice;
29import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbManager;
30import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException;
31import org.sleuthkit.autopsy.core.RuntimeProperties;
32import org.sleuthkit.autopsy.core.UserPreferences;
33import org.sleuthkit.autopsy.coreutils.Logger;
34import org.sleuthkit.autopsy.coreutils.ModuleSettings;
35
41
42 private static final Logger logger = Logger.getLogger(CRDefaultSetupAction.class.getName());
44
46 return INSTANCE;
47 }
48
50 }
51
59 Map<String, String> centralRepoSettings = ModuleSettings.getConfigSettings(CentralRepoSettings.getInstance().getModuleSettingsKey());
60 String initializedStr = centralRepoSettings.get("initialized");
61
62 // check to see if the repo has been initialized asking to setup cr
63 boolean initialized = Boolean.parseBoolean(initializedStr);
64
65 // if it hasn't received that flag, check for a previous install where cr is already setup
66 if (!initialized) {
67 boolean prevRepo = Boolean.parseBoolean(centralRepoSettings.get("db.useCentralRepo"));
68 // if it has been previously set up and is in use, mark as previously initialized and save the settings
69 if (prevRepo) {
70 initialized = true;
72 }
73 }
74
75 if (initialized) {
76 return false; // Nothing to do
77 }
78
79 try {
82 // Set up using existing multi-user settings.
84 } else {
85 manager.setupDefaultSqliteDb();
86 }
87 } catch (CentralRepoException ex) {
88 logger.log(Level.SEVERE, "There was an error while initializing the central repository database", ex);
89
91 }
92
94 return true;
95 }
96
103 @NbBundle.Messages({"Installer.centralRepoUpgradeFailed.title=Central repository disabled"})
106 try {
107 SwingUtilities.invokeAndWait(() -> {
108 JOptionPane.showMessageDialog(null,
109 ex.getUserMessage(),
110 NbBundle.getMessage(this.getClass(), "Installer.centralRepoUpgradeFailed.title"),
111 JOptionPane.ERROR_MESSAGE);
112 });
113 } catch (InterruptedException | InvocationTargetException e) {
114 logger.log(Level.WARNING, e.getMessage(), e);
115 }
116 }
117 }
118
119}
synchronized static Logger getLogger(String name)
Definition Logger.java:124
static synchronized void setConfigSetting(String moduleName, String settingName, String settingVal)
static synchronized Map< String, String > getConfigSettings(String moduleName)

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.