mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 08:26:15 +00:00
fixes to capture disabled due to failure and validity checks on re-enable
This commit is contained in:
parent
e842893a32
commit
b6957fe2bc
@ -36,23 +36,69 @@ 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 DB_SELECTED_PLATFORM_KEY = "db.selectedPlatform";
|
||||
private static final String DISABLED_DUE_TO_FAILURE_KEY = "disabledDueToFailure";
|
||||
|
||||
private static volatile CentralRepoDbChoice savedChoice = null;
|
||||
|
||||
private static final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(CentralRepoDbManager.class);
|
||||
|
||||
private static final Object dbChoiceLock = new Object();
|
||||
private static final Object disabledDueToFailureLock = new Object();
|
||||
|
||||
/**
|
||||
* Save the selected platform to the config file.
|
||||
*/
|
||||
public static synchronized CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice) {
|
||||
CentralRepoDbChoice newChoice = (choice == null) ? CentralRepoDbChoice.DISABLED : choice;
|
||||
CentralRepoDbChoice oldChoice = savedChoice;
|
||||
savedChoice = newChoice;
|
||||
ModuleSettings.setConfigSetting("CentralRepository", "db.selectedPlatform", newChoice.getSettingKey());
|
||||
propertyChangeSupport.firePropertyChange("savedChoice", oldChoice, newChoice);
|
||||
return newChoice;
|
||||
public static CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice) {
|
||||
synchronized(dbChoiceLock) {
|
||||
CentralRepoDbChoice newChoice = (choice == null) ? CentralRepoDbChoice.DISABLED : choice;
|
||||
CentralRepoDbChoice oldChoice = savedChoice;
|
||||
savedChoice = newChoice;
|
||||
ModuleSettings.setConfigSetting(CENTRAL_REPOSITORY_SETTINGS_KEY, DB_SELECTED_PLATFORM_KEY, newChoice.getSettingKey());
|
||||
propertyChangeSupport.firePropertyChange("savedChoice", oldChoice, newChoice);
|
||||
return newChoice;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load the selectedPlatform boolean from the config file, if it is set.
|
||||
*/
|
||||
public static CentralRepoDbChoice getSavedDbChoice() {
|
||||
synchronized(dbChoiceLock) {
|
||||
if (savedChoice == null) {
|
||||
String selectedPlatformString = ModuleSettings.getConfigSetting(CENTRAL_REPOSITORY_SETTINGS_KEY, DB_SELECTED_PLATFORM_KEY); // NON-NLS
|
||||
savedChoice = fromKey(selectedPlatformString);
|
||||
}
|
||||
|
||||
return savedChoice;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set whether or not the repository has been disabled due to a database setup issue;
|
||||
* this is used when re-enabling multi-user as a flag to determine whether or not CR should be re-enabled
|
||||
*
|
||||
* @param disabledDueToFailure whether or not the repository has been disabled due to a database setup issue
|
||||
*/
|
||||
public static void setDisabledDueToFailure(boolean disabledDueToFailure) {
|
||||
synchronized(disabledDueToFailureLock) {
|
||||
ModuleSettings.setConfigSetting(CENTRAL_REPOSITORY_SETTINGS_KEY, DISABLED_DUE_TO_FAILURE_KEY, Boolean.toString(disabledDueToFailure));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieves setting whether or not the repository has been disabled due to a database setup issue;
|
||||
* this is used when re-enabling multi-user as a flag to determine whether or not CR should be re-enabled
|
||||
*
|
||||
* @return whether or not the repository has been disabled due to a database setup issue
|
||||
*/
|
||||
public static boolean isDisabledDueToFailure() {
|
||||
synchronized(disabledDueToFailureLock) {
|
||||
return Boolean.toString(true).equals(ModuleSettings.getConfigSetting(CENTRAL_REPOSITORY_SETTINGS_KEY, DISABLED_DUE_TO_FAILURE_KEY));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,17 +119,6 @@ public class CentralRepoDbManager {
|
||||
propertyChangeSupport.removePropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the selectedPlatform boolean from the config file, if it is set.
|
||||
*/
|
||||
public static synchronized CentralRepoDbChoice getSavedDbChoice() {
|
||||
if (savedChoice == null) {
|
||||
String selectedPlatformString = ModuleSettings.getConfigSetting("CentralRepository", "db.selectedPlatform"); // NON-NLS
|
||||
savedChoice = fromKey(selectedPlatformString);
|
||||
}
|
||||
|
||||
return savedChoice;
|
||||
}
|
||||
|
||||
|
||||
private static CentralRepoDbChoice fromKey(String keyName) {
|
||||
@ -214,6 +249,8 @@ public class CentralRepoDbManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private DatabaseTestResult testingStatus;
|
||||
private CentralRepoDbChoice selectedDbChoice;
|
||||
|
||||
|
@ -19,7 +19,7 @@ EamDbSettingsDialog.okButton.createDbDialog.title=Database Does Not Exist
|
||||
EamDbSettingsDialog.okButton.createDbError.title=Unable to Create Database
|
||||
EamDbSettingsDialog.okButton.createPostgresDbError.message=Unable to create Postgres Database, please ensure address, port, and login credentials are correct for Postgres server and try again.
|
||||
EamDbSettingsDialog.okButton.createSQLiteDbError.message=Unable to create SQLite Database, please ensure location exists and you have write permissions and try again.
|
||||
EamDbSettingsDialog.okButton.databaseConnectionFailed.message=Unable to connect to database please check your settings and try again.
|
||||
EamDbSettingsDialog.okButton.databaseConnectionFailed.message=Unable to connect to database. Please check your settings and try again.
|
||||
EamDbSettingsDialog.okButton.databaseConnectionFailed.title=Database Connection Failed
|
||||
EamDbSettingsDialog.okButton.errorMsg.text=Please restart Autopsy to begin using the new database platform.
|
||||
EamDbSettingsDialog.okButton.errorTitle.text=Restart Required.
|
||||
@ -33,6 +33,12 @@ EamDbSettingsDialog.validation.finished=Click OK to save your database settings
|
||||
EamDbSettingsDialog.validation.incompleteFields=Fill in all values for the selected database.
|
||||
EamOptionsController.moduleErr=Error processing value changes.
|
||||
EamOptionsController.moduleErr.msg=Value change processing failed.
|
||||
GlobalSettingsPanel.onMultiUserChange.disabledMu.description=The Central Repository will be reconfigured to use a local SQLite database.
|
||||
GlobalSettingsPanel.onMultiUserChange.disabledMu.description2=Press Configure PostgreSQL to change to a PostgreSQL database.
|
||||
GlobalSettingsPanel.onMultiUserChange.disabledMu.title=Central Repository Change Necessary
|
||||
GlobalSettingsPanel.onMultiUserChange.enable.description=Do you want to update the Central Repository to use this PostgreSQL database?
|
||||
GlobalSettingsPanel.onMultiUserChange.enable.description2=The Central Repository stores hash values and accounts from past cases.
|
||||
GlobalSettingsPanel.onMultiUserChange.enable.title=Use with Central Repository?
|
||||
GlobalSettingsPanel.updateFailed.title=Central repository disabled
|
||||
GlobalSettingsPanel.validationErrMsg.ingestRunning=You cannot change settings while ingest is running.
|
||||
GlobalSettingsPanel.validationerrMsg.mustConfigure=Configure the database to enable this module.
|
||||
|
@ -163,7 +163,7 @@ public class EamDbSettingsDialog extends JDialog {
|
||||
"EamDbSettingsDialog.okButton.createDbDialog.title=Database Does Not Exist",
|
||||
"EamDbSettingsDialog.okButton.createDbDialog.message=Database does not exist, would you like to create it?",
|
||||
"EamDbSettingsDialog.okButton.databaseConnectionFailed.title=Database Connection Failed",
|
||||
"EamDbSettingsDialog.okButton.databaseConnectionFailed.message=Unable to connect to database please check your settings and try again.",
|
||||
"EamDbSettingsDialog.okButton.databaseConnectionFailed.message=Unable to connect to database. Please check your settings and try again.",
|
||||
"EamDbSettingsDialog.okButton.createSQLiteDbError.message=Unable to create SQLite Database, please ensure location exists and you have write permissions and try again.",
|
||||
"EamDbSettingsDialog.okButton.createPostgresDbError.message=Unable to create Postgres Database, please ensure address, port, and login credentials are correct for Postgres server and try again.",
|
||||
"EamDbSettingsDialog.okButton.createDbError.title=Unable to Create Database"})
|
||||
@ -566,6 +566,9 @@ public class EamDbSettingsDialog extends JDialog {
|
||||
Bundle.EamDbSettingsDialog_okButton_errorTitle_text(),
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
});
|
||||
|
||||
parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
return false;
|
||||
}
|
||||
|
||||
parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
|
@ -44,6 +44,7 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.PostgresCentralRepoSett
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.SqliteCentralRepoSettings;
|
||||
import java.awt.Component;
|
||||
import java.util.logging.Level;
|
||||
import org.sleuthkit.autopsy.core.UserPreferences;
|
||||
|
||||
/**
|
||||
* Main settings panel for the Central Repository
|
||||
@ -125,8 +126,9 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
"GlobalSettingsPanel.onMultiUserChange.enable.description2=The Central Repository stores hash values and accounts from past cases."
|
||||
})
|
||||
public static void onMultiUserChange(Component parent, boolean muPreviouslySelected, boolean muCurrentlySelected) {
|
||||
boolean crMultiUser = CentralRepoDbUtil.allowUseOfCentralRepository() &&
|
||||
CentralRepoDbManager.getSavedDbChoice() == CentralRepoDbChoice.POSTGRESQL_MULTIUSER;
|
||||
boolean crEnabled = CentralRepoDbUtil.allowUseOfCentralRepository();
|
||||
boolean crMultiUser = CentralRepoDbManager.getSavedDbChoice() == CentralRepoDbChoice.POSTGRESQL_MULTIUSER;
|
||||
boolean crDisabledDueToFailure = CentralRepoDbManager.isDisabledDueToFailure();
|
||||
|
||||
if (!muPreviouslySelected && muCurrentlySelected) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
@ -148,14 +150,16 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
});
|
||||
}
|
||||
// moving from selected to not selected && 'PostgreSQL using multi-user settings' is selected
|
||||
else if (muPreviouslySelected && !muCurrentlySelected && crMultiUser) {
|
||||
else if (muPreviouslySelected && !muCurrentlySelected && crEnabled && crMultiUser) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
askForCentralRepoDbChoice(parent);
|
||||
});
|
||||
}
|
||||
// changing multi-user settings connection && 'PostgreSQL using multi-user settings' is selected
|
||||
else if (muPreviouslySelected && muCurrentlySelected && crMultiUser) {
|
||||
// changing multi-user settings connection && 'PostgreSQL using multi-user settings' is selected &&
|
||||
// central repo either enabled or was disabled due to error
|
||||
else if (muPreviouslySelected && muCurrentlySelected && crMultiUser && (crEnabled || crDisabledDueToFailure)) {
|
||||
// test databse for CR change
|
||||
CentralRepoDbUtil.setUseCentralRepo(true);
|
||||
handleDbChange(parent);
|
||||
}
|
||||
}
|
||||
@ -210,12 +214,14 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
boolean successful = EamDbSettingsDialog.testStatusAndCreate(parent, new CentralRepoDbManager());
|
||||
if (successful) {
|
||||
// clear any error if there was one
|
||||
CentralRepoDbManager.setDisabledDueToFailure(false);
|
||||
updateDatabase(parent);
|
||||
}
|
||||
else {
|
||||
// disable central repository
|
||||
// disable central repository due to error
|
||||
CentralRepoDbManager.setDisabledDueToFailure(true);
|
||||
CentralRepoDbUtil.setUseCentralRepo(false);
|
||||
CentralRepoDbManager.saveDbChoice(CentralRepoDbChoice.DISABLED);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -632,6 +638,14 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
@Override
|
||||
public void store() { // Click OK or Apply on Options Panel
|
||||
CentralRepoDbUtil.setUseCentralRepo(cbUseCentralRepo.isSelected());
|
||||
|
||||
// if moving to using CR, multi-user mode is disabled and selection is multiuser settings, set to disabled
|
||||
if (cbUseCentralRepo.isSelected() &&
|
||||
!UserPreferences.getIsMultiUserModeEnabled() &&
|
||||
CentralRepoDbManager.getSavedDbChoice() == CentralRepoDbChoice.POSTGRESQL_MULTIUSER) {
|
||||
|
||||
CentralRepoDbManager.saveDbChoice(CentralRepoDbChoice.DISABLED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user