mirror of
https://github.com/elisspace/autopsy.git
synced 2026-09-15 15:32:59 +00:00
fix for separating official hash sets
This commit is contained in:
@@ -74,6 +74,8 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
private static final String HASH_DATABASE_FILE_EXTENSON = "kdb"; //NON-NLS
|
||||
private static HashDbManager instance = null;
|
||||
private List<HashDb> hashSets = new ArrayList<>();
|
||||
private List<HashDb> officialHashSets = new ArrayList<>();
|
||||
|
||||
private Set<String> hashSetNames = new HashSet<>();
|
||||
private Set<String> hashSetPaths = new HashSet<>();
|
||||
PropertyChangeSupport changeSupport = new PropertyChangeSupport(HashDbManager.class);
|
||||
@@ -417,7 +419,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
|
||||
void save() throws HashDbManagerException {
|
||||
try {
|
||||
if (!HashLookupSettings.writeSettings(new HashLookupSettings(HashLookupSettings.convertHashSetList(this.hashSets)))) {
|
||||
if (!HashLookupSettings.writeSettings(new HashLookupSettings(HashLookupSettings.convertHashSetList(getNonOfficialHashSets())))) {
|
||||
throw new HashDbManagerException(NbBundle.getMessage(this.getClass(), "HashDbManager.saveErrorExceptionMsg"));
|
||||
}
|
||||
} catch (HashLookupSettings.HashLookupSettingsException ex) {
|
||||
@@ -438,10 +440,9 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
} catch (TskCoreException ex) {
|
||||
Logger.getLogger(HashDbManager.class.getName()).log(Level.SEVERE, "Error loading central repository hash sets", ex); //NON-NLS
|
||||
}
|
||||
|
||||
List<HashDb> hashDbs = new ArrayList<>();
|
||||
hashDbs.addAll(this.hashSets);
|
||||
return hashDbs;
|
||||
|
||||
return Stream.concat(this.officialHashSets.stream(), this.hashSets.stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -450,16 +451,10 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
* @return A list, possibly empty, of hash databases.
|
||||
*/
|
||||
public synchronized List<HashDb> getKnownFileHashSets() {
|
||||
List<HashDb> hashDbs = new ArrayList<>();
|
||||
try {
|
||||
updateHashSetsFromCentralRepository();
|
||||
} catch (TskCoreException ex) {
|
||||
Logger.getLogger(HashDbManager.class.getName()).log(Level.SEVERE, "Error loading central repository hash sets", ex); //NON-NLS
|
||||
}
|
||||
this.hashSets.stream().filter((db) -> (db.getKnownFilesType() == HashDb.KnownFilesType.KNOWN)).forEach((db) -> {
|
||||
hashDbs.add(db);
|
||||
});
|
||||
return hashDbs;
|
||||
return getAllHashSets()
|
||||
.stream()
|
||||
.filter((db) -> (db.getKnownFilesType() == HashDb.KnownFilesType.KNOWN))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -468,16 +463,10 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
* @return A list, possibly empty, of hash databases.
|
||||
*/
|
||||
public synchronized List<HashDb> getKnownBadFileHashSets() {
|
||||
List<HashDb> hashDbs = new ArrayList<>();
|
||||
try {
|
||||
updateHashSetsFromCentralRepository();
|
||||
} catch (TskCoreException ex) {
|
||||
Logger.getLogger(HashDbManager.class.getName()).log(Level.SEVERE, "Error loading central repository hash sets", ex); //NON-NLS
|
||||
}
|
||||
this.hashSets.stream().filter((db) -> (db.getKnownFilesType() == HashDb.KnownFilesType.KNOWN_BAD)).forEach((db) -> {
|
||||
hashDbs.add(db);
|
||||
});
|
||||
return hashDbs;
|
||||
return getAllHashSets()
|
||||
.stream()
|
||||
.filter((db) -> (db.getKnownFilesType() == HashDb.KnownFilesType.KNOWN_BAD))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -486,26 +475,28 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
* @return A list, possibly empty, of hash databases.
|
||||
*/
|
||||
public synchronized List<HashDb> getUpdateableHashSets() {
|
||||
return getUpdateableHashSets(this.hashSets);
|
||||
return getUpdateableHashSets(getAllHashSets());
|
||||
}
|
||||
|
||||
private List<HashDb> getNonOfficialHashSets() {
|
||||
return getAllHashSets()
|
||||
.stream()
|
||||
.filter((HashDb db) -> (db instanceof SleuthkitHashSet && ((SleuthkitHashSet) db).isOfficialSet()) ? false : true)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<HashDb> getUpdateableHashSets(List<HashDb> hashDbs) {
|
||||
ArrayList<HashDb> updateableDbs = new ArrayList<>();
|
||||
try {
|
||||
updateHashSetsFromCentralRepository();
|
||||
} catch (TskCoreException ex) {
|
||||
Logger.getLogger(HashDbManager.class.getName()).log(Level.SEVERE, "Error loading central repository hash sets", ex); //NON-NLS
|
||||
}
|
||||
for (HashDb db : hashDbs) {
|
||||
try {
|
||||
if (db.isUpdateable()) {
|
||||
updateableDbs.add(db);
|
||||
}
|
||||
} catch (TskCoreException ex) {
|
||||
Logger.getLogger(HashDbManager.class.getName()).log(Level.SEVERE, "Error checking updateable status of " + db.getHashSetName() + " hash set", ex); //NON-NLS
|
||||
}
|
||||
}
|
||||
return updateableDbs;
|
||||
return hashDbs
|
||||
.stream()
|
||||
.filter((HashDb db) -> {
|
||||
try {
|
||||
return db.isUpdateable();
|
||||
} catch (TskCoreException ex) {
|
||||
Logger.getLogger(HashDbManager.class.getName()).log(Level.SEVERE, "Error checking updateable status of " + db.getHashSetName() + " hash set", ex); //NON-NLS
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<HashDbInfo> getCentralRepoHashSetsFromDatabase() {
|
||||
@@ -534,7 +525,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
* cancellation of configuration panels.
|
||||
*/
|
||||
public synchronized void loadLastSavedConfiguration() {
|
||||
closeHashDatabases(this.hashSets);
|
||||
closeHashDatabases(getAllHashSets());
|
||||
hashSetNames.clear();
|
||||
hashSetPaths.clear();
|
||||
|
||||
@@ -555,6 +546,13 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
}
|
||||
|
||||
private void loadHashsetsConfiguration() {
|
||||
try {
|
||||
officialHashSets = loadHashSetsFromFolder(OFFICIAL_HASH_SETS_FOLDER);
|
||||
} catch (HashDbManagerException ex) {
|
||||
logger.log(Level.WARNING, "There was an error loading the official hash sets.", ex);
|
||||
officialHashSets = new ArrayList<HashDb>();
|
||||
}
|
||||
|
||||
try {
|
||||
HashLookupSettings settings = HashLookupSettings.readSettings();
|
||||
this.configureSettings(settings);
|
||||
@@ -572,7 +570,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
*
|
||||
* @throws HashDbManagerException If folder does not exist.
|
||||
*/
|
||||
private List<HashDbInfo> loadHashSetsFromFolder(String folder) throws HashDbManagerException {
|
||||
private List<HashDb> loadHashSetsFromFolder(String folder) throws HashDbManagerException {
|
||||
File configFolder = InstalledFileLocator.getDefault().locate(
|
||||
folder, HashDbManager.class.getPackage().getName(), false);
|
||||
|
||||
@@ -584,7 +582,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
.map((f) -> {
|
||||
try {
|
||||
return getOfficialHashDbFromFile(f);
|
||||
} catch (HashDbManagerException ex) {
|
||||
} catch (HashDbManagerException | TskCoreException ex) {
|
||||
logger.log(Level.WARNING, String.format("Hashset: %s could not be properly read.", f.getAbsolutePath()), ex);
|
||||
return null;
|
||||
}
|
||||
@@ -605,7 +603,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
* HashDbManager.OFFICIAL_FILENAME for
|
||||
* regex).
|
||||
*/
|
||||
private HashDbInfo getOfficialHashDbFromFile(File file) throws HashDbManagerException {
|
||||
private HashDb getOfficialHashDbFromFile(File file) throws HashDbManagerException, TskCoreException {
|
||||
if (file == null || !file.exists()) {
|
||||
throw new HashDbManagerException(String.format("No file found for: %s", file == null ? "<null>" : file.getAbsolutePath()));
|
||||
}
|
||||
@@ -623,16 +621,16 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new HashDbManagerException(String.format("No KnownFilesType matches %s for file: %s", knownStatus, filename)));
|
||||
|
||||
return new HashDbInfo(
|
||||
return new SleuthkitHashSet(
|
||||
SleuthkitJNI.createHashDatabase(file.getAbsolutePath()),
|
||||
hashdbName,
|
||||
knownFilesType,
|
||||
false, //searchDuringIngest
|
||||
false, //sendIngestMessages
|
||||
file.getAbsolutePath(),
|
||||
true, // read only
|
||||
knownFilesType,
|
||||
true); // official set
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configures the given settings object by adding all contained hash db to
|
||||
* the system.
|
||||
@@ -644,18 +642,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
private void configureSettings(HashLookupSettings settings) {
|
||||
allDatabasesLoadedCorrectly = true;
|
||||
List<HashDbInfo> hashDbInfoList = settings.getHashDbInfo();
|
||||
|
||||
List<HashDbInfo> officialHashSets;
|
||||
try {
|
||||
officialHashSets = loadHashSetsFromFolder(OFFICIAL_HASH_SETS_FOLDER);
|
||||
} catch (HashDbManagerException ex) {
|
||||
logger.log(Level.WARNING, "There was an error loading the official hash sets.", ex);
|
||||
officialHashSets = new ArrayList<HashDbInfo>();
|
||||
}
|
||||
|
||||
final Stream<HashDbInfo> combined = Stream.concat(hashDbInfoList.stream(), officialHashSets.stream());
|
||||
|
||||
combined.forEach((HashDbInfo hashDbInfo) -> {
|
||||
for (HashDbInfo hashDbInfo : hashDbInfoList) {
|
||||
try {
|
||||
if (hashDbInfo.isFileDatabaseType()) {
|
||||
String dbPath = this.getValidFilePath(hashDbInfo.getHashSetName(), hashDbInfo.getPath());
|
||||
@@ -682,7 +669,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
allDatabasesLoadedCorrectly = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (CentralRepository.isEnabled()) {
|
||||
try {
|
||||
@@ -710,7 +697,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
*/
|
||||
if (!allDatabasesLoadedCorrectly && RuntimeProperties.runningWithGUI()) {
|
||||
try {
|
||||
HashLookupSettings.writeSettings(new HashLookupSettings(HashLookupSettings.convertHashSetList(this.hashSets)));
|
||||
HashLookupSettings.writeSettings(new HashLookupSettings(HashLookupSettings.convertHashSetList(getNonOfficialHashSets())));
|
||||
allDatabasesLoadedCorrectly = true;
|
||||
} catch (HashLookupSettings.HashLookupSettingsException ex) {
|
||||
allDatabasesLoadedCorrectly = false;
|
||||
@@ -734,7 +721,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
}
|
||||
|
||||
private boolean hashDbInfoIsNew(HashDbInfo dbInfo) {
|
||||
for (HashDb db : this.hashSets) {
|
||||
for (HashDb db : getAllHashSets()) {
|
||||
if (dbInfo.matches(db)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
*
|
||||
* Copyright 2011-2018 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.
|
||||
@@ -62,7 +62,7 @@ final class HashLookupSettings implements Serializable {
|
||||
private static final String CONFIG_FILE_NAME = "hashsets.xml"; //NON-NLS
|
||||
private static final String configFilePath = PlatformUtil.getUserConfigDirectory() + File.separator + CONFIG_FILE_NAME;
|
||||
private static final Logger logger = Logger.getLogger(HashDbManager.class.getName());
|
||||
|
||||
|
||||
private static final String USER_DIR_PLACEHOLDER = "[UserConfigFolder]";
|
||||
private static final String CURRENT_USER_DIR = PlatformUtil.getUserConfigDirectory();
|
||||
|
||||
@@ -77,13 +77,13 @@ final class HashLookupSettings implements Serializable {
|
||||
HashLookupSettings(List<HashDbInfo> hashDbInfoList) {
|
||||
this.hashDbInfoList = hashDbInfoList;
|
||||
}
|
||||
|
||||
static List<HashDbInfo> convertHashSetList(List<HashDbManager.HashDb> hashSets) throws HashLookupSettingsException {
|
||||
|
||||
static List<HashDbInfo> convertHashSetList(List<HashDbManager.HashDb> hashSets) throws HashLookupSettingsException{
|
||||
List<HashDbInfo> dbInfoList = new ArrayList<>();
|
||||
for (HashDbManager.HashDb db : hashSets) {
|
||||
try {
|
||||
for(HashDbManager.HashDb db:hashSets){
|
||||
try{
|
||||
dbInfoList.add(new HashDbInfo(db));
|
||||
} catch (TskCoreException ex) {
|
||||
} catch (TskCoreException ex){
|
||||
logger.log(Level.SEVERE, "Could not load hash set settings for {0}", db.getHashSetName());
|
||||
}
|
||||
}
|
||||
@@ -125,17 +125,15 @@ final class HashLookupSettings implements Serializable {
|
||||
* @throws HashLookupSettingsException If there's a problem importing the
|
||||
* settings
|
||||
*/
|
||||
private static HashLookupSettings readSerializedSettings() throws HashLookupSettingsException {
|
||||
private static HashLookupSettings readSerializedSettings() throws HashLookupSettingsException {
|
||||
try {
|
||||
try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(SERIALIZATION_FILE_PATH))) {
|
||||
HashLookupSettings filesSetsSettings = (HashLookupSettings) in.readObject();
|
||||
|
||||
/*
|
||||
* NOTE: to support JIRA-4177, we need to check if any of the
|
||||
* hash database paths are in Windows user directory. If so, we
|
||||
* replace the path with USER_DIR_PLACEHOLDER before saving to
|
||||
* disk. When reading from disk, USER_DIR_PLACEHOLDER needs to
|
||||
* be replaced with current user directory path.
|
||||
/* NOTE: to support JIRA-4177, we need to check if any of the hash
|
||||
database paths are in Windows user directory. If so, we replace the path
|
||||
with USER_DIR_PLACEHOLDER before saving to disk. When reading from disk,
|
||||
USER_DIR_PLACEHOLDER needs to be replaced with current user directory path.
|
||||
*/
|
||||
convertPlaceholderToPath(filesSetsSettings);
|
||||
return filesSetsSettings;
|
||||
@@ -293,12 +291,11 @@ final class HashLookupSettings implements Serializable {
|
||||
* @return Whether or not the settings were written successfully
|
||||
*/
|
||||
static boolean writeSettings(HashLookupSettings settings) {
|
||||
|
||||
/*
|
||||
* NOTE: to support JIRA-4177, we need to check if any of the hash
|
||||
* database paths are in Windows user directory. If so, replace the path
|
||||
* with USER_DIR_PLACEHOLDER so that when it is read, it gets updated to
|
||||
* be the current user directory path.
|
||||
|
||||
/* NOTE: to support JIRA-4177, we need to check if any of the hash
|
||||
database paths are in Windows user directory. If so, replace the path
|
||||
with USER_DIR_PLACEHOLDER so that when it is read, it gets updated to be
|
||||
the current user directory path.
|
||||
*/
|
||||
convertPathToPlaceholder(settings);
|
||||
try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(SERIALIZATION_FILE_PATH))) {
|
||||
@@ -313,10 +310,10 @@ final class HashLookupSettings implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* For file type hash sets, check if hash set paths needs to be modified per
|
||||
* JIRA-4177. If the file path is in current Windows user directory, replace
|
||||
* the path with USER_DIR_PLACEHOLDER.
|
||||
*
|
||||
* For file type hash sets, check if hash set paths needs to be modified
|
||||
* per JIRA-4177. If the file path is in current Windows user directory,
|
||||
* replace the path with USER_DIR_PLACEHOLDER.
|
||||
*
|
||||
* @param settings HashLookupSettings settings object to examiner and modify
|
||||
*/
|
||||
static void convertPathToPlaceholder(HashLookupSettings settings) {
|
||||
@@ -331,7 +328,7 @@ final class HashLookupSettings implements Serializable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For file type hash sets, check if hash set paths needs to be modified per
|
||||
* JIRA-4177. Replace USER_DIR_PLACEHOLDER with path to current Windows user
|
||||
@@ -352,6 +349,7 @@ final class HashLookupSettings implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents the serializable information within a hash lookup in order to
|
||||
* be written to disk. Used to hand off information when loading and saving
|
||||
@@ -359,11 +357,11 @@ final class HashLookupSettings implements Serializable {
|
||||
*/
|
||||
static final class HashDbInfo implements Serializable {
|
||||
|
||||
enum DatabaseType {
|
||||
enum DatabaseType{
|
||||
FILE,
|
||||
CENTRAL_REPOSITORY
|
||||
};
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final String hashSetName;
|
||||
private final HashDbManager.HashDb.KnownFilesType knownFilesType;
|
||||
@@ -374,7 +372,6 @@ final class HashLookupSettings implements Serializable {
|
||||
private final boolean readOnly;
|
||||
private final int referenceSetID;
|
||||
private DatabaseType dbType;
|
||||
private final boolean officialSet;
|
||||
|
||||
/**
|
||||
* Constructs a HashDbInfo object for files type
|
||||
@@ -387,25 +384,6 @@ final class HashLookupSettings implements Serializable {
|
||||
* @param path The path to the db
|
||||
*/
|
||||
HashDbInfo(String hashSetName, HashDbManager.HashDb.KnownFilesType knownFilesType, boolean searchDuringIngest, boolean sendIngestMessages, String path) {
|
||||
this(hashSetName, knownFilesType, searchDuringIngest, sendIngestMessages, path, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a HashDbInfo object for files type
|
||||
*
|
||||
* @param hashSetName The name of the hash set
|
||||
* @param knownFilesType The known files type
|
||||
* @param searchDuringIngest Whether or not the db is searched during
|
||||
* ingest
|
||||
* @param sendIngestMessages Whether or not ingest messages are sent
|
||||
* @param path The path to the db
|
||||
* @param readOnly Whether or not the hash set should be
|
||||
* readOnly
|
||||
* @param officialSet Whether or not the hash set is a Standard
|
||||
* Official Hash Set.
|
||||
*/
|
||||
HashDbInfo(String hashSetName, HashDbManager.HashDb.KnownFilesType knownFilesType, boolean searchDuringIngest,
|
||||
boolean sendIngestMessages, String path, boolean readOnly, boolean officialSet) {
|
||||
this.hashSetName = hashSetName;
|
||||
this.knownFilesType = knownFilesType;
|
||||
this.searchDuringIngest = searchDuringIngest;
|
||||
@@ -413,12 +391,11 @@ final class HashLookupSettings implements Serializable {
|
||||
this.path = path;
|
||||
this.referenceSetID = -1;
|
||||
this.version = "";
|
||||
this.readOnly = readOnly;
|
||||
this.readOnly = false;
|
||||
this.dbType = DatabaseType.FILE;
|
||||
this.officialSet = officialSet;
|
||||
}
|
||||
|
||||
HashDbInfo(String hashSetName, String version, int referenceSetID, HashDbManager.HashDb.KnownFilesType knownFilesType, boolean readOnly, boolean searchDuringIngest, boolean sendIngestMessages) {
|
||||
|
||||
HashDbInfo(String hashSetName, String version, int referenceSetID, HashDbManager.HashDb.KnownFilesType knownFilesType, boolean readOnly, boolean searchDuringIngest, boolean sendIngestMessages){
|
||||
this.hashSetName = hashSetName;
|
||||
this.version = version;
|
||||
this.referenceSetID = referenceSetID;
|
||||
@@ -427,13 +404,12 @@ final class HashLookupSettings implements Serializable {
|
||||
this.searchDuringIngest = searchDuringIngest;
|
||||
this.sendIngestMessages = sendIngestMessages;
|
||||
this.path = "";
|
||||
dbType = DatabaseType.CENTRAL_REPOSITORY;
|
||||
this.officialSet = false;
|
||||
dbType = DatabaseType.CENTRAL_REPOSITORY;
|
||||
}
|
||||
|
||||
HashDbInfo(HashDbManager.HashDb db) throws TskCoreException {
|
||||
if (db instanceof HashDbManager.SleuthkitHashSet) {
|
||||
HashDbManager.SleuthkitHashSet fileTypeDb = (HashDbManager.SleuthkitHashSet) db;
|
||||
|
||||
HashDbInfo(HashDbManager.HashDb db) throws TskCoreException{
|
||||
if(db instanceof HashDbManager.SleuthkitHashSet){
|
||||
HashDbManager.SleuthkitHashSet fileTypeDb = (HashDbManager.SleuthkitHashSet)db;
|
||||
this.hashSetName = fileTypeDb.getHashSetName();
|
||||
this.knownFilesType = fileTypeDb.getKnownFilesType();
|
||||
this.searchDuringIngest = fileTypeDb.getSearchDuringIngest();
|
||||
@@ -447,31 +423,20 @@ final class HashLookupSettings implements Serializable {
|
||||
} else {
|
||||
this.path = fileTypeDb.getDatabasePath();
|
||||
}
|
||||
this.officialSet = ((HashDbManager.SleuthkitHashSet) db).isOfficialSet();
|
||||
} else {
|
||||
HashDbManager.CentralRepoHashSet centralRepoDb = (HashDbManager.CentralRepoHashSet) db;
|
||||
HashDbManager.CentralRepoHashSet centralRepoDb = (HashDbManager.CentralRepoHashSet)db;
|
||||
this.hashSetName = centralRepoDb.getHashSetName();
|
||||
this.version = centralRepoDb.getVersion();
|
||||
this.knownFilesType = centralRepoDb.getKnownFilesType();
|
||||
this.readOnly = !centralRepoDb.isUpdateable();
|
||||
this.readOnly = ! centralRepoDb.isUpdateable();
|
||||
this.searchDuringIngest = centralRepoDb.getSearchDuringIngest();
|
||||
this.sendIngestMessages = centralRepoDb.getSendIngestMessages();
|
||||
this.path = "";
|
||||
this.referenceSetID = centralRepoDb.getReferenceSetID();
|
||||
this.dbType = DatabaseType.CENTRAL_REPOSITORY;
|
||||
this.officialSet = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether or not this is an official set.
|
||||
*
|
||||
* @return Whether or not this is an official set.
|
||||
*/
|
||||
public boolean isOfficialSet() {
|
||||
return officialSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the hash set name.
|
||||
*
|
||||
@@ -480,22 +445,20 @@ final class HashLookupSettings implements Serializable {
|
||||
String getHashSetName() {
|
||||
return hashSetName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the version for the hash set
|
||||
*
|
||||
* @return version
|
||||
*/
|
||||
String getVersion() {
|
||||
String getVersion(){
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get whether the hash set is read only (only applies to central repo)
|
||||
*
|
||||
* @return readOnly
|
||||
*/
|
||||
boolean isReadOnly() {
|
||||
boolean isReadOnly(){
|
||||
return readOnly;
|
||||
}
|
||||
|
||||
@@ -516,7 +479,7 @@ final class HashLookupSettings implements Serializable {
|
||||
boolean getSearchDuringIngest() {
|
||||
return searchDuringIngest;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the search during ingest setting.
|
||||
*
|
||||
@@ -541,83 +504,81 @@ final class HashLookupSettings implements Serializable {
|
||||
*/
|
||||
String getPath() {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the path.
|
||||
*
|
||||
* @param path the path to set
|
||||
*/
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
int getReferenceSetID() {
|
||||
|
||||
int getReferenceSetID(){
|
||||
return referenceSetID;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether the database is a normal file type.
|
||||
*
|
||||
* @return true if database is type FILE
|
||||
*/
|
||||
boolean isFileDatabaseType() {
|
||||
boolean isFileDatabaseType(){
|
||||
return dbType == DatabaseType.FILE;
|
||||
}
|
||||
|
||||
boolean isCentralRepoDatabaseType() {
|
||||
|
||||
boolean isCentralRepoDatabaseType(){
|
||||
return dbType == DatabaseType.CENTRAL_REPOSITORY;
|
||||
}
|
||||
|
||||
boolean matches(HashDb hashDb) {
|
||||
if (hashDb == null) {
|
||||
|
||||
boolean matches(HashDb hashDb){
|
||||
if(hashDb == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.knownFilesType.equals(hashDb.getKnownFilesType())) {
|
||||
|
||||
if( ! this.knownFilesType.equals(hashDb.getKnownFilesType())){
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((this.dbType == DatabaseType.CENTRAL_REPOSITORY) && (!(hashDb instanceof CentralRepoHashSet))
|
||||
|| (this.dbType == DatabaseType.FILE) && (!(hashDb instanceof SleuthkitHashSet))) {
|
||||
|
||||
if((this.dbType == DatabaseType.CENTRAL_REPOSITORY) && (! (hashDb instanceof CentralRepoHashSet))
|
||||
|| (this.dbType == DatabaseType.FILE) && (! (hashDb instanceof SleuthkitHashSet))){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.hashSetName.equals(hashDb.getHashSetName())) {
|
||||
|
||||
if( ! this.hashSetName.equals(hashDb.getHashSetName())){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hashDb instanceof CentralRepoHashSet) {
|
||||
|
||||
if(hashDb instanceof CentralRepoHashSet){
|
||||
CentralRepoHashSet crDb = (CentralRepoHashSet) hashDb;
|
||||
if (this.referenceSetID != crDb.getReferenceSetID()) {
|
||||
if(this.referenceSetID != crDb.getReferenceSetID()){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!version.equals(crDb.getVersion())) {
|
||||
if(! version.equals(crDb.getVersion())){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
final HashDbInfo other = (HashDbInfo) obj;
|
||||
|
||||
if (!this.dbType.equals(other.dbType)) {
|
||||
|
||||
if(! this.dbType.equals(other.dbType)){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.dbType.equals(DatabaseType.FILE)) {
|
||||
|
||||
if(this.dbType.equals(DatabaseType.FILE)){
|
||||
// For files, we expect the name and known type to match
|
||||
return (this.hashSetName.equals(other.hashSetName)
|
||||
&& this.knownFilesType.equals(other.knownFilesType));
|
||||
@@ -635,27 +596,25 @@ final class HashLookupSettings implements Serializable {
|
||||
hash = 89 * hash + Objects.hashCode(this.hashSetName);
|
||||
hash = 89 * hash + Objects.hashCode(this.knownFilesType);
|
||||
hash = 89 * hash + Objects.hashCode(this.dbType);
|
||||
if (this.dbType.equals(DatabaseType.CENTRAL_REPOSITORY)) {
|
||||
if(this.dbType.equals(DatabaseType.CENTRAL_REPOSITORY)){
|
||||
hash = 89 * hash + this.referenceSetID;
|
||||
}
|
||||
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This overrides the default deserialization code so we can properly
|
||||
* set the dbType enum given an old settings file.
|
||||
*
|
||||
* This overrides the default deserialization code so we can
|
||||
* properly set the dbType enum given an old settings file.
|
||||
* @param stream
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
private void readObject(java.io.ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
|
||||
if (dbType == null) {
|
||||
|
||||
if(dbType == null){
|
||||
dbType = DatabaseType.FILE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user