mirror of
https://github.com/elisspace/autopsy.git
synced 2026-10-04 16:26:16 +00:00
1903 renamed Manager and Settings class for handling FilesSet objects
This commit is contained in:
@@ -40,7 +40,7 @@ import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
import org.sleuthkit.autopsy.coreutils.PlatformUtil;
|
||||
import org.sleuthkit.autopsy.modules.interestingitems.FilesSet;
|
||||
import org.sleuthkit.autopsy.modules.interestingitems.InterestingItemDefsManager;
|
||||
import org.sleuthkit.autopsy.modules.interestingitems.FilesSetsManager;
|
||||
|
||||
/**
|
||||
* Encapsulates the ingest job settings for a particular execution context.
|
||||
@@ -355,7 +355,7 @@ public class IngestJobSettings {
|
||||
if (ModuleSettings.settingExists(this.executionContext, IngestJobSettings.LAST_FILE_INGEST_FILTER_KEY) == false) {
|
||||
ModuleSettings.setConfigSetting(this.executionContext, IngestJobSettings.LAST_FILE_INGEST_FILTER_KEY, IngestJobSettings.ALL_AND_UNALLOC_FILES_INGEST_FILTER.getName());
|
||||
}
|
||||
this.fileIngestFilter = InterestingItemDefsManager.getInstance()
|
||||
this.fileIngestFilter = FilesSetsManager.getInstance()
|
||||
.getFileIngestFilters()
|
||||
.get(ModuleSettings.getConfigSetting(this.executionContext, IngestJobSettings.LAST_FILE_INGEST_FILTER_KEY));
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.IngestJobInfoPanel;
|
||||
import org.sleuthkit.autopsy.corecomponents.AdvancedConfigurationDialog;
|
||||
import org.sleuthkit.autopsy.modules.interestingitems.FileIngestFilterDefsOptionsPanelController;
|
||||
import org.sleuthkit.autopsy.modules.interestingitems.InterestingItemDefsManager;
|
||||
import org.sleuthkit.autopsy.modules.interestingitems.FilesSetsManager;
|
||||
import org.sleuthkit.datamodel.Content;
|
||||
import org.sleuthkit.datamodel.IngestJobInfo;
|
||||
import org.sleuthkit.datamodel.IngestModuleInfo;
|
||||
@@ -425,7 +425,7 @@ public final class IngestJobSettingsPanel extends javax.swing.JPanel {
|
||||
|
||||
} else if (evt.getActionCommand().equals("comboBoxChanged")) {
|
||||
|
||||
settings.setFileIngestFilter(InterestingItemDefsManager.getInstance()
|
||||
settings.setFileIngestFilter(FilesSetsManager.getInstance()
|
||||
.getFileIngestFilters()
|
||||
.get(jComboBox1.getSelectedItem().toString()));
|
||||
}
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ public final class FileIngestFilterDefsOptionsPanelController extends OptionsPan
|
||||
*/
|
||||
private InterestingItemDefsPanel getPanel() {
|
||||
if (panel == null) {
|
||||
panel = new InterestingItemDefsPanel(InterestingItemDefsManager.getFileIngestFilterDefsName(), "");
|
||||
panel = new InterestingItemDefsPanel(FilesSetsManager.getFileIngestFilterDefsName(), "");
|
||||
panel.addPropertyChangeListener(new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
|
||||
+5
-5
@@ -62,7 +62,7 @@ final class FilesIdentifierIngestJobSettingsPanel extends IngestModuleIngestJobS
|
||||
// interesting file set definitions. This is used to keep this panel in
|
||||
// synch with changes made using the global settings/option panel for
|
||||
// this module.
|
||||
InterestingItemDefsManager.getInstance().addObserver(panel);
|
||||
FilesSetsManager.getInstance().addObserver(panel);
|
||||
|
||||
return panel;
|
||||
}
|
||||
@@ -83,8 +83,8 @@ final class FilesIdentifierIngestJobSettingsPanel extends IngestModuleIngestJobS
|
||||
*/
|
||||
List<FilesSetRow> filesSetRows = new ArrayList<>();
|
||||
try {
|
||||
this.filesSetSnapshot = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets(InterestingItemDefsManager.getInterestingFilesSetDefsName(), InterestingItemDefsManager.getLegacyFilesSetDefsFileName()));
|
||||
} catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) {
|
||||
this.filesSetSnapshot = new TreeMap<>(FilesSetsManager.getInstance().getInterestingFilesSets(FilesSetsManager.getInterestingFilesSetDefsName(), FilesSetsManager.getLegacyFilesSetDefsFileName()));
|
||||
} catch (FilesSetsManager.FilesSetsManagerException ex) {
|
||||
MessageNotifyUtil.Message.error(Bundle.FilesIdentifierIngestJobSettingsPanel_getError());
|
||||
this.filesSetSnapshot = new TreeMap<>();
|
||||
}
|
||||
@@ -138,8 +138,8 @@ final class FilesIdentifierIngestJobSettingsPanel extends IngestModuleIngestJobS
|
||||
List<FilesSetRow> rowModels = new ArrayList<>();
|
||||
TreeMap<String, FilesSet> newFilesSetSnapshot;
|
||||
try {
|
||||
newFilesSetSnapshot = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets(InterestingItemDefsManager.getInterestingFilesSetDefsName(), InterestingItemDefsManager.getLegacyFilesSetDefsFileName()));
|
||||
} catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) {
|
||||
newFilesSetSnapshot = new TreeMap<>(FilesSetsManager.getInstance().getInterestingFilesSets(FilesSetsManager.getInterestingFilesSetDefsName(), FilesSetsManager.getLegacyFilesSetDefsFileName()));
|
||||
} catch (FilesSetsManager.FilesSetsManagerException ex) {
|
||||
MessageNotifyUtil.Message.error(Bundle.FilesIdentifierIngestJobSettingsPanel_updateError());
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-2
@@ -83,12 +83,12 @@ final class FilesIdentifierIngestModule implements FileIngestModule {
|
||||
// to disable the interesting files set definition UI during ingest.
|
||||
List<FilesSet> filesSets = new ArrayList<>();
|
||||
try {
|
||||
for (FilesSet set : InterestingItemDefsManager.getInstance().getInterestingFilesSets(InterestingItemDefsManager.getInterestingFilesSetDefsName(), InterestingItemDefsManager.getLegacyFilesSetDefsFileName()).values()) {
|
||||
for (FilesSet set : FilesSetsManager.getInstance().getInterestingFilesSets(FilesSetsManager.getInterestingFilesSetDefsName(), FilesSetsManager.getLegacyFilesSetDefsFileName()).values()) {
|
||||
if (settings.interestingFilesSetIsEnabled(set.getName())) {
|
||||
filesSets.add(set);
|
||||
}
|
||||
}
|
||||
} catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) {
|
||||
} catch (FilesSetsManager.FilesSetsManagerException ex) {
|
||||
throw new IngestModuleException(Bundle.FilesIdentifierIngestModule_getFilesError(), ex);
|
||||
}
|
||||
FilesIdentifierIngestModule.interestingFileSetsByJob.put(context.getJobId(), filesSets);
|
||||
|
||||
@@ -57,8 +57,8 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(FilesSetRulePanel.class.getName());
|
||||
private static final String SLEUTHKIT_PATH_SEPARATOR = "/"; // NON-NLS
|
||||
private static final List<String> ILLEGAL_FILE_NAME_CHARS = InterestingItemDefsManager.getIllegalFileNameChars();
|
||||
private static final List<String> ILLEGAL_FILE_PATH_CHARS = InterestingItemDefsManager.getIllegalFilePathChars();
|
||||
private static final List<String> ILLEGAL_FILE_NAME_CHARS = FilesSetsManager.getIllegalFileNameChars();
|
||||
private static final List<String> ILLEGAL_FILE_PATH_CHARS = FilesSetsManager.getIllegalFilePathChars();
|
||||
private JButton okButton;
|
||||
private JButton cancelButton;
|
||||
|
||||
|
||||
+4
-3
@@ -22,13 +22,14 @@ import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* A map of FilesSets for saving all the settings in FilesSetsManager in one item.
|
||||
*
|
||||
* @author oliver
|
||||
*/
|
||||
class InterestingItemsFilesSetSettings implements Serializable {
|
||||
class FilesSetSettings implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Map<String, FilesSet> filesSets;
|
||||
InterestingItemsFilesSetSettings(Map<String, FilesSet> filesSets) {
|
||||
FilesSetSettings(Map<String, FilesSet> filesSets) {
|
||||
this.filesSets = filesSets;
|
||||
}
|
||||
|
||||
+27
-27
@@ -44,27 +44,27 @@ import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
/**
|
||||
* Provides access to interesting item definitions persisted to disk. Clients
|
||||
* receive copies of the most recent interesting item definitions via
|
||||
* synchronized methods, allowing the definitions to be safely published to
|
||||
* multiple threads.
|
||||
* Provides access to collections of FilesSet definitions persisted to disk. Clients
|
||||
* receive copies of the most recent FilesSet definitions for Interesting Items or
|
||||
* File Ingest Filters via synchronized methods, allowing the definitions to be
|
||||
* safely published to multiple threads.
|
||||
*/
|
||||
public final class InterestingItemDefsManager extends Observable {
|
||||
public final class FilesSetsManager extends Observable {
|
||||
|
||||
private static final List<String> ILLEGAL_FILE_NAME_CHARS = Collections.unmodifiableList(new ArrayList<>(Arrays.asList("\\", "/", ":", "*", "?", "\"", "<", ">")));
|
||||
private static final List<String> ILLEGAL_FILE_PATH_CHARS = Collections.unmodifiableList(new ArrayList<>(Arrays.asList("\\", ":", "*", "?", "\"", "<", ">")));
|
||||
private static final String LEGACY_FILES_SET_DEFS_FILE_NAME = "InterestingFilesSetDefs.xml"; //NON-NLS
|
||||
private static final String INTERESTING_FILES_SET_DEFS_NAME = "InterestingFileSets.settings";
|
||||
private static final String FILE_INGEST_FILTER_DEFS_NAME = "FileIngestFilterDefs.settings";
|
||||
private static InterestingItemDefsManager instance;
|
||||
private static FilesSetsManager instance;
|
||||
|
||||
/**
|
||||
* Gets the interesting item definitions manager singleton.
|
||||
*/
|
||||
|
||||
public synchronized static InterestingItemDefsManager getInstance() {
|
||||
public synchronized static FilesSetsManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new InterestingItemDefsManager();
|
||||
instance = new FilesSetsManager();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public final class InterestingItemDefsManager extends Observable {
|
||||
* @return A list of characters.
|
||||
*/
|
||||
static List<String> getIllegalFileNameChars() {
|
||||
return InterestingItemDefsManager.ILLEGAL_FILE_NAME_CHARS;
|
||||
return FilesSetsManager.ILLEGAL_FILE_NAME_CHARS;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +85,7 @@ public final class InterestingItemDefsManager extends Observable {
|
||||
* @return A list of characters.
|
||||
*/
|
||||
static List<String> getIllegalFilePathChars() {
|
||||
return InterestingItemDefsManager.ILLEGAL_FILE_PATH_CHARS;
|
||||
return FilesSetsManager.ILLEGAL_FILE_PATH_CHARS;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ public final class InterestingItemDefsManager extends Observable {
|
||||
* @return A map of interesting files set names to interesting file sets,
|
||||
* possibly empty.
|
||||
*/
|
||||
synchronized Map<String, FilesSet> getInterestingFilesSets(String fileName, String legacyFileName) throws InterestingItemDefsManagerException {
|
||||
synchronized Map<String, FilesSet> getInterestingFilesSets(String fileName, String legacyFileName) throws FilesSetsManagerException {
|
||||
return FilesSetXML.readDefinitionsFile(fileName, legacyFileName);
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ public final class InterestingItemDefsManager extends Observable {
|
||||
Map<String, FilesSet> returnMap = new HashMap<>();
|
||||
try {
|
||||
returnMap.putAll(FilesSetXML.readDefinitionsFile(getFileIngestFilterDefsName(), ""));
|
||||
} catch (InterestingItemDefsManagerException ex) {
|
||||
} catch (FilesSetsManagerException ex) {
|
||||
Exceptions.printStackTrace(ex); //WJS-TODO change manager to not use file names, if this function is still needed fix error handling to be done properly.
|
||||
|
||||
}
|
||||
@@ -148,7 +148,7 @@ public final class InterestingItemDefsManager extends Observable {
|
||||
* @param filesSets A mapping of interesting files set names to files sets,
|
||||
* used to enforce unique files set names.
|
||||
*/
|
||||
synchronized void setInterestingFilesSets(Map<String, FilesSet> filesSets, String fileName) throws InterestingItemDefsManagerException {
|
||||
synchronized void setInterestingFilesSets(Map<String, FilesSet> filesSets, String fileName) throws FilesSetsManagerException {
|
||||
FilesSetXML.writeDefinitionsFile(fileName, filesSets);
|
||||
this.setChanged();
|
||||
this.notifyObservers();
|
||||
@@ -162,7 +162,7 @@ public final class InterestingItemDefsManager extends Observable {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(FilesSetXML.class.getName());
|
||||
private static final String XML_ENCODING = "UTF-8"; //NON-NLS
|
||||
private static final List<String> illegalFileNameChars = InterestingItemDefsManager.getIllegalFileNameChars();
|
||||
private static final List<String> illegalFileNameChars = FilesSetsManager.getIllegalFileNameChars();
|
||||
|
||||
// The following tags and attributes are identical to those used in the
|
||||
// TSK Framework interesting files set definitions file schema.
|
||||
@@ -198,7 +198,7 @@ public final class InterestingItemDefsManager extends Observable {
|
||||
// Note: This method takes a file path to support the possibility of
|
||||
// multiple intersting files set definition files, e.g., one for
|
||||
// definitions that ship with Autopsy and one for user definitions.
|
||||
static Map<String, FilesSet> readDefinitionsFile(String fileName, String legacyFileName) throws InterestingItemDefsManagerException {
|
||||
static Map<String, FilesSet> readDefinitionsFile(String fileName, String legacyFileName) throws FilesSetsManagerException {
|
||||
Map<String, FilesSet> filesSets = readSerializedDefinitions(fileName);
|
||||
|
||||
if (!filesSets.isEmpty()) {
|
||||
@@ -246,9 +246,9 @@ public final class InterestingItemDefsManager extends Observable {
|
||||
* @return the map representing settings saved to serialization file,
|
||||
* empty set if the file does not exist.
|
||||
*
|
||||
* @throws InterestingItemDefsManagerException if file could not be read
|
||||
* @throws FilesSetsManagerException if file could not be read
|
||||
*/
|
||||
private static Map<String, FilesSet> readSerializedDefinitions(String serialFileName) throws InterestingItemDefsManagerException {
|
||||
private static Map<String, FilesSet> readSerializedDefinitions(String serialFileName) throws FilesSetsManagerException {
|
||||
String filePath;
|
||||
filePath = PlatformUtil.getUserConfigDirectory() + File.separator + serialFileName;
|
||||
System.out.println(filePath);
|
||||
@@ -256,11 +256,11 @@ public final class InterestingItemDefsManager extends Observable {
|
||||
if (fileSetFile.exists()) {
|
||||
try {
|
||||
try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(filePath))) {
|
||||
InterestingItemsFilesSetSettings filesSetsSettings = (InterestingItemsFilesSetSettings) in.readObject();
|
||||
FilesSetSettings filesSetsSettings = (FilesSetSettings) in.readObject();
|
||||
return filesSetsSettings.getFilesSets();
|
||||
}
|
||||
} catch (IOException | ClassNotFoundException ex) {
|
||||
throw new InterestingItemDefsManagerException(String.format("Failed to read settings from %s", filePath), ex);
|
||||
throw new FilesSetsManagerException(String.format("Failed to read settings from %s", filePath), ex);
|
||||
}
|
||||
} else {
|
||||
return new HashMap<>();
|
||||
@@ -572,31 +572,31 @@ public final class InterestingItemDefsManager extends Observable {
|
||||
// Note: This method takes a file path to support the possibility of
|
||||
// multiple intersting files set definition files, e.g., one for
|
||||
// definitions that ship with Autopsy and one for user definitions.
|
||||
static boolean writeDefinitionsFile(String fileName, Map<String, FilesSet> interestingFilesSets) throws InterestingItemDefsManagerException {
|
||||
static boolean writeDefinitionsFile(String fileName, Map<String, FilesSet> interestingFilesSets) throws FilesSetsManagerException {
|
||||
try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(PlatformUtil.getUserConfigDirectory() + File.separator + fileName))) {
|
||||
out.writeObject(new InterestingItemsFilesSetSettings(interestingFilesSets));
|
||||
out.writeObject(new FilesSetSettings(interestingFilesSets));
|
||||
} catch (IOException ex) {
|
||||
throw new InterestingItemDefsManagerException(String.format("Failed to write settings to %s", fileName), ex);
|
||||
throw new FilesSetsManagerException(String.format("Failed to write settings to %s", fileName), ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class InterestingItemDefsManagerException extends Exception {
|
||||
public static class FilesSetsManagerException extends Exception {
|
||||
|
||||
InterestingItemDefsManagerException() {
|
||||
FilesSetsManagerException() {
|
||||
|
||||
}
|
||||
|
||||
InterestingItemDefsManagerException(String message) {
|
||||
FilesSetsManagerException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
InterestingItemDefsManagerException(String message, Throwable cause) {
|
||||
FilesSetsManagerException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
InterestingItemDefsManagerException(Throwable cause) {
|
||||
FilesSetsManagerException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -115,7 +115,7 @@ public final class InterestingItemDefsOptionsPanelController extends OptionsPane
|
||||
|
||||
private InterestingItemDefsPanel getPanel() {
|
||||
if (panel == null) {
|
||||
panel = new InterestingItemDefsPanel(InterestingItemDefsManager.getInterestingFilesSetDefsName(), InterestingItemDefsManager.getLegacyFilesSetDefsFileName());
|
||||
panel = new InterestingItemDefsPanel(FilesSetsManager.getInterestingFilesSetDefsName(), FilesSetsManager.getLegacyFilesSetDefsFileName());
|
||||
panel.addPropertyChangeListener(new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
|
||||
+4
-4
@@ -153,8 +153,8 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
|
||||
@Override
|
||||
public void saveSettings() {
|
||||
try {
|
||||
InterestingItemDefsManager.getInstance().setInterestingFilesSets(this.filesSets, settingsFileName);
|
||||
} catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) {
|
||||
FilesSetsManager.getInstance().setInterestingFilesSets(this.filesSets, settingsFileName);
|
||||
} catch (FilesSetsManager.FilesSetsManagerException ex) {
|
||||
MessageNotifyUtil.Message.error(Bundle.InterestingItemsDefsPanel_saveError());
|
||||
}
|
||||
}
|
||||
@@ -177,8 +177,8 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
|
||||
try {
|
||||
// Get a working copy of the interesting files set definitions and sort
|
||||
// by set name.
|
||||
this.filesSets = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets(settingsFileName, settingsLegacyFileName));
|
||||
} catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) {
|
||||
this.filesSets = new TreeMap<>(FilesSetsManager.getInstance().getInterestingFilesSets(settingsFileName, settingsLegacyFileName));
|
||||
} catch (FilesSetsManager.FilesSetsManagerException ex) {
|
||||
MessageNotifyUtil.Message.error(Bundle.InterestingItemsDefsPanel_loadError());
|
||||
this.filesSets = new TreeMap<>();
|
||||
}
|
||||
|
||||
+3
-3
@@ -69,7 +69,7 @@ final public class InterestingItemsIngestModuleFactory extends IngestModuleFacto
|
||||
|
||||
@Override
|
||||
public IngestModuleGlobalSettingsPanel getGlobalSettingsPanel() {
|
||||
InterestingItemDefsPanel panel = new InterestingItemDefsPanel(InterestingItemDefsManager.getInterestingFilesSetDefsName(), InterestingItemDefsManager.getLegacyFilesSetDefsFileName());
|
||||
InterestingItemDefsPanel panel = new InterestingItemDefsPanel(FilesSetsManager.getInterestingFilesSetDefsName(), FilesSetsManager.getLegacyFilesSetDefsFileName());
|
||||
panel.load();
|
||||
return panel;
|
||||
}
|
||||
@@ -83,10 +83,10 @@ final public class InterestingItemsIngestModuleFactory extends IngestModuleFacto
|
||||
// Doing so also keeps the serialization simple.
|
||||
List<String> enabledFilesSetNames = new ArrayList<>();
|
||||
try {
|
||||
for (String name : InterestingItemDefsManager.getInstance().getInterestingFilesSets(InterestingItemDefsManager.getInterestingFilesSetDefsName(), InterestingItemDefsManager.getLegacyFilesSetDefsFileName()).keySet()) {
|
||||
for (String name : FilesSetsManager.getInstance().getInterestingFilesSets(FilesSetsManager.getInterestingFilesSetDefsName(), FilesSetsManager.getLegacyFilesSetDefsFileName()).keySet()) {
|
||||
enabledFilesSetNames.add(name);
|
||||
}
|
||||
} catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) {
|
||||
} catch (FilesSetsManager.FilesSetsManagerException ex) {
|
||||
MessageNotifyUtil.Message.error(Bundle.InterestingItemsIngestModuleFactory_defaultSettingsError());
|
||||
}
|
||||
return new FilesIdentifierIngestJobSettings(enabledFilesSetNames);
|
||||
|
||||
Reference in New Issue
Block a user