mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
updates for consistency
This commit is contained in:
parent
7dba95ed2f
commit
097aa7075a
@ -22,7 +22,10 @@ package org.sleuthkit.autopsy.centralrepository.datamodel;
|
|||||||
* common interface for settings pertaining to the database in central repository
|
* common interface for settings pertaining to the database in central repository
|
||||||
*/
|
*/
|
||||||
public interface CentralRepoDbConnectivityManager {
|
public interface CentralRepoDbConnectivityManager {
|
||||||
|
void loadSettings();
|
||||||
|
|
||||||
|
void saveSettings();
|
||||||
|
|
||||||
boolean createDatabase();
|
boolean createDatabase();
|
||||||
|
|
||||||
boolean deleteDatabase();
|
boolean deleteDatabase();
|
||||||
|
@ -21,8 +21,8 @@ import org.sleuthkit.datamodel.CaseDbConnectionInfo;
|
|||||||
*
|
*
|
||||||
* @author gregd
|
* @author gregd
|
||||||
*/
|
*/
|
||||||
public class CentralRepoPostgresSettingsManager {
|
public class CentralRepoPostgresSettingsUtil {
|
||||||
private final static Logger LOGGER = Logger.getLogger(CentralRepoPostgresSettingsManager.class.getName());
|
private final static Logger LOGGER = Logger.getLogger(CentralRepoPostgresSettingsUtil.class.getName());
|
||||||
|
|
||||||
private final static String DEFAULT_HOST = ""; // NON-NLS
|
private final static String DEFAULT_HOST = ""; // NON-NLS
|
||||||
private final static int DEFAULT_PORT = 5432;
|
private final static int DEFAULT_PORT = 5432;
|
||||||
@ -102,7 +102,7 @@ public class CentralRepoPostgresSettingsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static PostgresConnectionSettings loadSettings() {
|
public static PostgresConnectionSettings loadCustomSettings() {
|
||||||
PostgresConnectionSettings settings = new PostgresConnectionSettings();
|
PostgresConnectionSettings settings = new PostgresConnectionSettings();
|
||||||
Map<String, String> keyVals = ModuleSettings.getConfigSettings(MODULE_KEY);
|
Map<String, String> keyVals = ModuleSettings.getConfigSettings(MODULE_KEY);
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ public class CentralRepoPostgresSettingsManager {
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveSettings(PostgresConnectionSettings settings) {
|
public static void saveCustomSettings(PostgresConnectionSettings settings) {
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
map.put(HOST_KEY, settings.getHost());
|
map.put(HOST_KEY, settings.getHost());
|
||||||
map.put(PORT_KEY, Integer.toString(settings.getPort()));
|
map.put(PORT_KEY, Integer.toString(settings.getPort()));
|
||||||
@ -145,9 +145,13 @@ public class CentralRepoPostgresSettingsManager {
|
|||||||
ModuleSettings.setConfigSettings(MODULE_KEY, map);
|
ModuleSettings.setConfigSettings(MODULE_KEY, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public static boolean isChanged(PostgresConnectionSettings settings) {
|
* checks if saved settings differ from the in-memory object provided in the 'settings' parameter
|
||||||
PostgresConnectionSettings saved = loadSettings();
|
* @param settings the in-memory object
|
||||||
|
* @return whether or not settings parameter differs from saved custom settings
|
||||||
|
*/
|
||||||
|
public static boolean areCustomSettingsChanged(PostgresConnectionSettings settings) {
|
||||||
|
PostgresConnectionSettings saved = loadCustomSettings();
|
||||||
return saved.equals(settings);
|
return saved.equals(settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,11 +26,7 @@ import java.sql.SQLException;
|
|||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
|
||||||
import org.sleuthkit.autopsy.coreutils.TextConverter;
|
|
||||||
import org.sleuthkit.autopsy.coreutils.TextConverterException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings for the Postgres implementation of the Central Repository database
|
* Settings for the Postgres implementation of the Central Repository database
|
||||||
@ -46,12 +42,34 @@ public final class PostgresCentralRepoSettings implements CentralRepoDbConnectiv
|
|||||||
private final static String JDBC_DRIVER = "org.postgresql.Driver"; // NON-NLS
|
private final static String JDBC_DRIVER = "org.postgresql.Driver"; // NON-NLS
|
||||||
|
|
||||||
|
|
||||||
private final PostgresConnectionSettings connSettings;
|
private final PostgresSettingsLoader loader;
|
||||||
|
private PostgresConnectionSettings connSettings;
|
||||||
|
|
||||||
public PostgresCentralRepoSettings(PostgresConnectionSettings connSettings) {
|
|
||||||
this.connSettings = connSettings;
|
public PostgresCentralRepoSettings(PostgresSettingsLoader loader) {
|
||||||
|
this.loader = loader;
|
||||||
|
loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default constructor that loads custom postgres settings from
|
||||||
|
*/
|
||||||
|
public PostgresCentralRepoSettings() {
|
||||||
|
this(PostgresSettingsLoader.CUSTOM_LOADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadSettings() {
|
||||||
|
this.connSettings = loader.loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveSettings() {
|
||||||
|
loader.saveSettings(connSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("PostgresCentralRepoSettings: [db type: postgres, host: %s:%d, db name: %s, username: %s]",
|
return String.format("PostgresCentralRepoSettings: [db type: postgres, host: %s:%d, db name: %s, username: %s]",
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package org.sleuthkit.autopsy.centralrepository.datamodel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author gregd
|
||||||
|
*/
|
||||||
|
public interface PostgresSettingsLoader {
|
||||||
|
PostgresConnectionSettings loadSettings();
|
||||||
|
void saveSettings(PostgresConnectionSettings settings);
|
||||||
|
|
||||||
|
public static PostgresSettingsLoader CUSTOM_LOADER = new Custom();
|
||||||
|
public static PostgresSettingsLoader MULTIUSER_LOADER = new MultiUser();
|
||||||
|
|
||||||
|
|
||||||
|
static class Custom implements PostgresSettingsLoader {
|
||||||
|
@Override
|
||||||
|
public PostgresConnectionSettings loadSettings() {
|
||||||
|
return CentralRepoPostgresSettingsUtil.loadCustomSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveSettings(PostgresConnectionSettings settings) {
|
||||||
|
CentralRepoPostgresSettingsUtil.saveCustomSettings(settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static class MultiUser implements PostgresSettingsLoader {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PostgresConnectionSettings loadSettings() {
|
||||||
|
return CentralRepoPostgresSettingsUtil.loadMultiUserSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveSettings(PostgresConnectionSettings settings) {}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user