mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
central repo settings updates
This commit is contained in:
parent
ed07b15d4c
commit
a630a0f088
@ -316,6 +316,7 @@
|
||||
<package>org.sleuthkit.autopsy.casemodule.multiusercases</package>
|
||||
<package>org.sleuthkit.autopsy.casemodule.multiusercasesbrowser</package>
|
||||
<package>org.sleuthkit.autopsy.casemodule.services</package>
|
||||
<package>org.sleuthkit.autopsy.centralrepository.settings</package>
|
||||
<package>org.sleuthkit.autopsy.contentviewers</package>
|
||||
<package>org.sleuthkit.autopsy.coordinationservice</package>
|
||||
<package>org.sleuthkit.autopsy.core</package>
|
||||
|
@ -31,6 +31,7 @@ import javax.annotation.concurrent.Immutable;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.centralrepository.settings.CentralRepoSettings;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
import org.sleuthkit.datamodel.TagName;
|
||||
@ -375,7 +376,7 @@ final public class TagNameDefinition implements Comparable<TagNameDefinition> {
|
||||
* @return A list of tag names, or empty list if none were found.
|
||||
*/
|
||||
private static List<String> getCRNotableList() {
|
||||
String notableTagsProp = ModuleSettings.getConfigSetting("CentralRepository", "db.badTags"); // NON-NLS
|
||||
String notableTagsProp = ModuleSettings.getConfigSetting(CentralRepoSettings.getInstance().getModuleSettingsKey(), "db.badTags"); // NON-NLS
|
||||
if (notableTagsProp != null && !notableTagsProp.isEmpty()) {
|
||||
return Arrays.asList(notableTagsProp.split(","));
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Level;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.centralrepository.settings.CentralRepoSettings;
|
||||
import org.sleuthkit.autopsy.coordinationservice.CoordinationService;
|
||||
import org.sleuthkit.autopsy.core.UserPreferences;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
@ -38,7 +39,7 @@ public class CentralRepoDbManager {
|
||||
private static final Logger logger = Logger.getLogger(CentralRepoDbManager.class.getName());
|
||||
|
||||
private static final String CENTRAL_REPO_DB_NAME = "central_repository";
|
||||
private static final String CENTRAL_REPOSITORY_SETTINGS_KEY = "CentralRepository";
|
||||
private static final String CENTRAL_REPOSITORY_SETTINGS_KEY = CentralRepoSettings.getInstance().getModuleSettingsKey();
|
||||
private static final String DB_SELECTED_PLATFORM_KEY = "db.selectedPlatform";
|
||||
private static final String DISABLED_DUE_TO_FAILURE_KEY = "disabledDueToFailure";
|
||||
|
||||
|
@ -32,6 +32,7 @@ import org.openide.windows.WindowManager;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
import static org.sleuthkit.autopsy.centralrepository.datamodel.RdbmsCentralRepo.SOFTWARE_CR_DB_SCHEMA_VERSION;
|
||||
import org.sleuthkit.autopsy.centralrepository.settings.CentralRepoSettings;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -39,7 +40,7 @@ import static org.sleuthkit.autopsy.centralrepository.datamodel.RdbmsCentralRepo
|
||||
public class CentralRepoDbUtil {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(CentralRepoDbUtil.class.getName());
|
||||
private static final String CENTRAL_REPO_NAME = "CentralRepository";
|
||||
private static final String CENTRAL_REPO_NAME = CentralRepoSettings.getInstance().getModuleSettingsKey();
|
||||
private static final String CENTRAL_REPO_USE_KEY = "db.useCentralRepo";
|
||||
private static final String DEFAULT_ORG_NAME = "Not Specified";
|
||||
|
||||
|
@ -25,6 +25,7 @@ package org.sleuthkit.autopsy.centralrepository.datamodel;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import org.sleuthkit.autopsy.centralrepository.settings.CentralRepoSettings;
|
||||
import org.sleuthkit.autopsy.core.UserPreferences;
|
||||
import org.sleuthkit.autopsy.core.UserPreferencesException;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
@ -46,7 +47,7 @@ public class CentralRepoPostgresSettingsUtil {
|
||||
private static final String DBNAME_KEY = "db.postgresql.dbName";
|
||||
private static final String HOST_KEY = "db.postgresql.host";
|
||||
|
||||
private static final String MODULE_KEY = "CentralRepository";
|
||||
private static final String MODULE_KEY = CentralRepoSettings.getInstance().getModuleSettingsKey();
|
||||
|
||||
private static CentralRepoPostgresSettingsUtil instance = null;
|
||||
|
||||
|
@ -29,6 +29,7 @@ import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
import org.sleuthkit.autopsy.centralrepository.settings.CentralRepoSettings;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
import org.sleuthkit.autopsy.coreutils.PlatformUtil;
|
||||
@ -41,13 +42,13 @@ import org.sleuthkit.autopsy.coreutils.PlatformUtil;
|
||||
*/
|
||||
public final class SqliteCentralRepoSettings implements CentralRepoDbConnectivityManager {
|
||||
|
||||
public final static String DEFAULT_DBNAME = "central_repository.db"; // NON-NLS
|
||||
public final static String DEFAULT_DBNAME = CentralRepoSettings.getInstance().getDefaultDbName(); // NON-NLS
|
||||
private final static Logger LOGGER = Logger.getLogger(SqliteCentralRepoSettings.class.getName());
|
||||
private final Path userConfigDir = Paths.get(PlatformUtil.getUserDirectory().getAbsolutePath());
|
||||
private final static String DEFAULT_DBDIRECTORY = PlatformUtil.getUserDirectory() + File.separator + "central_repository"; // NON-NLS
|
||||
private final static String DEFAULT_DBDIRECTORY = CentralRepoSettings.getInstance().getDefaultDbPath();
|
||||
|
||||
//property names
|
||||
private static final String PROFILE_NAME = "CentralRepository";
|
||||
private static final String PROFILE_NAME = CentralRepoSettings.getInstance().getModuleSettingsKey();
|
||||
private static final String DATABASE_NAME = "db.sqlite.dbName"; //NON-NLS
|
||||
private static final String DATABASE_PATH = "db.sqlite.dbDirectory"; //NON-NLS
|
||||
private static final String BULK_THRESHOLD = "db.sqlite.bulkThreshold"; //NON-NLS
|
||||
|
@ -28,6 +28,7 @@ import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbChoice;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbManager;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException;
|
||||
import org.sleuthkit.autopsy.centralrepository.settings.CentralRepoSettings;
|
||||
import org.sleuthkit.autopsy.core.RuntimeProperties;
|
||||
import org.sleuthkit.autopsy.core.UserPreferences;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
@ -88,7 +89,7 @@ public class Installer extends ModuleInstall {
|
||||
* (in other words, developers are exempt from seeing the notification).
|
||||
*/
|
||||
private void setupDefaultCentralRepository() {
|
||||
Map<String, String> centralRepoSettings = ModuleSettings.getConfigSettings("CentralRepository");
|
||||
Map<String, String> centralRepoSettings = ModuleSettings.getConfigSettings(CentralRepoSettings.getInstance().getModuleSettingsKey());
|
||||
String initializedStr = centralRepoSettings.get("initialized");
|
||||
|
||||
// check to see if the repo has been initialized asking to setup cr
|
||||
@ -100,7 +101,7 @@ public class Installer extends ModuleInstall {
|
||||
// if it has been previously set up and is in use, mark as previously initialized and save the settings
|
||||
if (prevRepo) {
|
||||
initialized = true;
|
||||
ModuleSettings.setConfigSetting("CentralRepository", "initialized", "true");
|
||||
ModuleSettings.setConfigSetting(CentralRepoSettings.getInstance().getModuleSettingsKey(), "initialized", "true");
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,7 +127,7 @@ public class Installer extends ModuleInstall {
|
||||
doMessageBoxIfRunningInGUI(ex);
|
||||
}
|
||||
|
||||
ModuleSettings.setConfigSetting("CentralRepository", "initialized", "true");
|
||||
ModuleSettings.setConfigSetting(CentralRepoSettings.getInstance().getModuleSettingsKey(), "initialized", "true");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2022 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.centralrepository.settings;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import java.nio.file.Paths;
|
||||
import org.sleuthkit.autopsy.coreutils.PlatformUtil;
|
||||
|
||||
/**
|
||||
* Location for central repo settings and paths.
|
||||
*/
|
||||
@Beta
|
||||
public class CentralRepoSettings {
|
||||
|
||||
private static final CentralRepoSettings instance = new CentralRepoSettings();
|
||||
|
||||
/**
|
||||
* @return The singleton instance of this class.
|
||||
*/
|
||||
public static CentralRepoSettings getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static final String CENTRAL_REPOSITORY_FOLDER = "CentralRepository";
|
||||
private static final String CENTRAL_REPOSITORY_SETTINGS_NAME = "CentralRepository";
|
||||
private static final String CENTRAL_REPO_BASE_PATH = Paths.get(PlatformUtil.getUserConfigDirectory(), CENTRAL_REPOSITORY_FOLDER).toString();
|
||||
private static final String DEFAULT_DB_PARENT_PATH = Paths.get(CENTRAL_REPO_BASE_PATH, "LocalDatabase").toString();
|
||||
private static final String DEFAULT_DB_NAME = "central_repository.db";
|
||||
private static final String MODULE_SETTINGS_KEY = Paths.get(CENTRAL_REPOSITORY_FOLDER, CENTRAL_REPOSITORY_SETTINGS_NAME).toString();
|
||||
|
||||
/**
|
||||
* @return The base path for central repository settings.
|
||||
*/
|
||||
public String getSettingsBaseFolder() {
|
||||
return CENTRAL_REPO_BASE_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The module settings key that places the settings file within
|
||||
* getSettingsBaseFolder.
|
||||
*/
|
||||
public String getModuleSettingsKey() {
|
||||
return MODULE_SETTINGS_KEY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The default database parent path for sqlite cr.
|
||||
*/
|
||||
public String getDefaultDbPath() {
|
||||
return DEFAULT_DB_PARENT_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The default sqlite database name.
|
||||
*/
|
||||
public String getDefaultDbName() {
|
||||
return DEFAULT_DB_NAME;
|
||||
}
|
||||
}
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.centralrepository.datamodel;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
@ -43,9 +42,8 @@ import org.sleuthkit.autopsy.casemodule.CaseActionException;
|
||||
import org.sleuthkit.autopsy.casemodule.CaseDetails;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
import org.sleuthkit.datamodel.TskData;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.centralrepository.settings.CentralRepoSettings;
|
||||
import org.sleuthkit.autopsy.coreutils.FileUtil;
|
||||
|
||||
/**
|
||||
@ -59,7 +57,7 @@ import org.sleuthkit.autopsy.coreutils.FileUtil;
|
||||
*/
|
||||
public class CentralRepoDatamodelTest extends TestCase {
|
||||
|
||||
private static final String PROPERTIES_FILE = "CentralRepository";
|
||||
private static final String PROPERTIES_FILE = CentralRepoSettings.getInstance().getModuleSettingsKey();
|
||||
private static final String CR_DB_NAME = "testcentralrepo.db";
|
||||
|
||||
private static final Path testDirectory = Paths.get(System.getProperty("java.io.tmpdir"), "CentralRepoDatamodelTest");
|
||||
|
Loading…
x
Reference in New Issue
Block a user