19 package org.sleuthkit.autopsy.core;
22 import java.io.FileInputStream;
23 import java.io.IOException;
24 import java.nio.file.Paths;
25 import java.time.ZoneId;
26 import java.util.Arrays;
27 import java.util.List;
28 import java.util.Properties;
30 import java.util.prefs.BackingStoreException;
32 import java.util.prefs.PreferenceChangeListener;
33 import org.apache.commons.lang3.StringUtils;
34 import org.apache.commons.lang3.tuple.Triple;
35 import org.openide.util.Lookup;
36 import org.python.icu.util.TimeZone;
81 private static final ConfigProperties
viewPreferences =
new ConfigProperties(VIEW_PREFERENCE_PATH);
83 private static final ConfigProperties
modePreferences =
new ConfigProperties(MODE_PREFERENCE_PATH);
91 viewPreferences.load();
92 machineSpecificPreferences.load();
93 modePreferences.load();
94 externalServicePreferences.load();
95 }
catch (IOException ex) {
136 private static final String
MODE =
"AutopsyMode";
166 KEEP_PREFERRED_VIEWER,
167 HIDE_KNOWN_FILES_IN_DATA_SRCS_TREE,
168 HIDE_KNOWN_FILES_IN_VIEWS_TREE,
169 HIDE_SLACK_FILES_IN_DATA_SRCS_TREE,
170 HIDE_SLACK_FILES_IN_VIEWS_TREE,
171 DISPLAY_TIMES_IN_LOCAL_TIME,
172 TIME_ZONE_FOR_DISPLAYS,
173 GROUP_ITEMS_IN_TREE_BY_DATASOURCE,
174 SHOW_ONLY_CURRENT_USER_TAGS,
176 DISPLAY_TRANSLATED_NAMES,
177 EXTERNAL_HEX_EDITOR_PATH,
178 RESULTS_TABLE_PAGE_SIZE
183 NUMBER_OF_FILE_INGEST_THREADS,
184 PROCESS_TIME_OUT_ENABLED,
185 PROCESS_TIME_OUT_HOURS,
188 HEALTH_MONITOR_REPORT_PATH,
190 GEO_OSM_TILE_ZIP_PATH,
191 GEO_MBTILES_FILE_PATH
203 IS_MULTI_USER_MODE_ENABLED,
205 OCR_TRANSLATION_ENABLED,
206 EXTERNAL_DATABASE_HOSTNAME_OR_IP,
207 EXTERNAL_DATABASE_PORTNUMBER,
208 EXTERNAL_DATABASE_NAME,
209 EXTERNAL_DATABASE_USER,
210 EXTERNAL_DATABASE_PASSWORD,
211 EXTERNAL_DATABASE_TYPE,
218 MESSAGE_SERVICE_PASSWORD,
219 MESSAGE_SERVICE_USER,
220 MESSAGE_SERVICE_HOST,
221 MESSAGE_SERVICE_PORT,
222 TEXT_TRANSLATOR_NAME,
223 GEO_OSM_SERVER_ADDRESS
228 static void updateConfig() {
229 List<Triple<File, ConfigProperties, List<String>>> fileAndKeys = Arrays.asList(
230 Triple.of(
new File(MODE_PREFERENCE_PATH), modePreferences, MODE_PREFERENCE_KEYS),
231 Triple.of(
new File(MACHINE_SPECIFIC_PREFERENCE_PATH), machineSpecificPreferences, MACHINE_PREFERENCE_KEYS),
232 Triple.of(
new File(VIEW_PREFERENCE_PATH), viewPreferences, VIEW_PREFERENCE_KEYS),
233 Triple.of(
new File(EXTERNAL_SERVICE_PREFERENCE_PATH), externalServicePreferences, EXTERNAL_SERVICE_KEYS)
236 boolean newSettingsExist = fileAndKeys.stream().anyMatch(triple -> triple.getLeft().exists());
238 File oldSettingsFile =
new File(LEGACY_CONFIG_PATH);
240 if (oldSettingsFile.exists() && !newSettingsExist) {
242 Properties allProperties =
new Properties();
243 try (FileInputStream oldPropsStream =
new FileInputStream(oldSettingsFile)) {
244 allProperties.load(oldPropsStream);
247 for (Triple<File, ConfigProperties, List<String>> fileKeys : fileAndKeys) {
248 ConfigProperties newProperties = fileKeys.getMiddle();
249 for (String key : fileKeys.getRight()) {
250 String val = allProperties.getProperty(key);
252 newProperties.put(key, val);
257 }
catch (IOException ex) {
261 ex.printStackTrace();
304 viewPreferences.sync();
305 machineSpecificPreferences.sync();
306 modePreferences.sync();
307 externalServicePreferences.sync();
318 viewPreferences.flush();
319 machineSpecificPreferences.flush();
320 modePreferences.flush();
321 externalServicePreferences.flush();
325 viewPreferences.addPreferenceChangeListener(listener);
326 machineSpecificPreferences.addPreferenceChangeListener(listener);
327 modePreferences.addPreferenceChangeListener(listener);
328 externalServicePreferences.addPreferenceChangeListener(listener);
332 viewPreferences.removePreferenceChangeListener(listener);
333 machineSpecificPreferences.removePreferenceChangeListener(listener);
334 modePreferences.removePreferenceChangeListener(listener);
335 externalServicePreferences.removePreferenceChangeListener(listener);
339 return viewPreferences.getBoolean(KEEP_PREFERRED_VIEWER,
false);
343 viewPreferences.putBoolean(KEEP_PREFERRED_VIEWER, value);
347 return viewPreferences.getBoolean(HIDE_KNOWN_FILES_IN_DATA_SRCS_TREE,
false);
351 viewPreferences.putBoolean(HIDE_KNOWN_FILES_IN_DATA_SRCS_TREE, value);
355 return viewPreferences.getBoolean(HIDE_KNOWN_FILES_IN_VIEWS_TREE,
true);
359 viewPreferences.putBoolean(HIDE_KNOWN_FILES_IN_VIEWS_TREE, value);
363 return viewPreferences.getBoolean(HIDE_SLACK_FILES_IN_DATA_SRCS_TREE,
true);
367 viewPreferences.putBoolean(HIDE_SLACK_FILES_IN_DATA_SRCS_TREE, value);
371 return viewPreferences.getBoolean(HIDE_SLACK_FILES_IN_VIEWS_TREE,
true);
375 viewPreferences.putBoolean(HIDE_SLACK_FILES_IN_VIEWS_TREE, value);
379 return viewPreferences.getBoolean(DISPLAY_TIMES_IN_LOCAL_TIME,
true);
383 viewPreferences.putBoolean(DISPLAY_TIMES_IN_LOCAL_TIME, value);
387 return viewPreferences.get(TIME_ZONE_FOR_DISPLAYS, TimeZone.GMT_ZONE.getID());
399 String timeZonePref = viewPreferences.get(TIME_ZONE_FOR_DISPLAYS, null);
400 if (StringUtils.isBlank(timeZonePref)) {
401 ZoneId systemZoneId = ZoneId.systemDefault();
402 if (systemZoneId != null) {
403 timeZonePref = systemZoneId.getId();
407 if (StringUtils.isBlank(timeZonePref)) {
408 timeZonePref = TimeZone.GMT_ZONE.getID();
415 viewPreferences.put(TIME_ZONE_FOR_DISPLAYS, timeZone);
419 return machineSpecificPreferences.getInt(NUMBER_OF_FILE_INGEST_THREADS, 2);
423 machineSpecificPreferences.putInt(NUMBER_OF_FILE_INGEST_THREADS, value);
428 return viewPreferences.getBoolean(GROUP_ITEMS_IN_TREE_BY_DATASOURCE,
false);
433 viewPreferences.putBoolean(GROUP_ITEMS_IN_TREE_BY_DATASOURCE, value);
443 return viewPreferences.getBoolean(SHOW_ONLY_CURRENT_USER_TAGS,
false);
453 viewPreferences.putBoolean(SHOW_ONLY_CURRENT_USER_TAGS, value);
464 return viewPreferences.getBoolean(HIDE_SCO_COLUMNS,
false);
475 viewPreferences.putBoolean(HIDE_SCO_COLUMNS, value);
479 viewPreferences.putBoolean(DISPLAY_TRANSLATED_NAMES, value);
483 return viewPreferences.getBoolean(DISPLAY_TRANSLATED_NAMES, DISPLAY_TRANSLATED_NAMES_DEFAULT);
496 dbType = DbType.valueOf(externalServicePreferences.get(EXTERNAL_DATABASE_TYPE,
"POSTGRESQL"));
497 }
catch (Exception ex) {
498 dbType = DbType.SQLITE;
501 return new CaseDbConnectionInfo(
502 externalServicePreferences.get(EXTERNAL_DATABASE_HOSTNAME_OR_IP,
""),
503 externalServicePreferences.get(EXTERNAL_DATABASE_PORTNUMBER,
"5432"),
504 externalServicePreferences.get(EXTERNAL_DATABASE_USER,
""),
508 throw new UserPreferencesException(
"Failure converting password hex text to text.", ex);
521 externalServicePreferences.put(EXTERNAL_DATABASE_HOSTNAME_OR_IP, connectionInfo.getHost());
522 externalServicePreferences.put(EXTERNAL_DATABASE_PORTNUMBER, connectionInfo.getPort());
523 externalServicePreferences.put(EXTERNAL_DATABASE_USER, connectionInfo.getUserName());
529 externalServicePreferences.put(EXTERNAL_DATABASE_TYPE, connectionInfo.getDbType().toString());
533 externalServicePreferences.putBoolean(IS_MULTI_USER_MODE_ENABLED, enabled);
537 return isMultiUserSupported() && externalServicePreferences.getBoolean(IS_MULTI_USER_MODE_ENABLED,
false);
551 if (multiUserSupported == null) {
553 multiUserSupported = Lookup.getDefault().lookupAll(
AutopsyService.class).stream()
554 .anyMatch(obj -> obj.getClass().getName().equalsIgnoreCase(
"org.sleuthkit.autopsy.keywordsearch.SolrSearchService"));
561 return externalServicePreferences.get(SOLR8_SERVER_HOST,
"");
565 externalServicePreferences.put(SOLR8_SERVER_HOST, hostName);
569 return externalServicePreferences.get(SOLR8_SERVER_PORT,
"8983");
573 externalServicePreferences.putInt(SOLR8_SERVER_PORT, port);
577 return externalServicePreferences.get(SOLR4_SERVER_HOST,
"");
581 externalServicePreferences.put(SOLR4_SERVER_HOST, hostName);
585 return externalServicePreferences.get(SOLR4_SERVER_PORT,
"");
589 externalServicePreferences.put(SOLR4_SERVER_PORT, port);
593 return externalServicePreferences.get(ZK_SERVER_HOST,
"");
597 externalServicePreferences.put(ZK_SERVER_HOST, hostName);
601 return externalServicePreferences.get(ZK_SERVER_PORT,
"9983");
605 externalServicePreferences.put(ZK_SERVER_PORT, port);
609 externalServicePreferences.put(TEXT_TRANSLATOR_NAME, textTranslatorName);
613 return externalServicePreferences.get(TEXT_TRANSLATOR_NAME, null);
617 externalServicePreferences.putBoolean(OCR_TRANSLATION_ENABLED, enableOcr);
621 return externalServicePreferences.getBoolean(OCR_TRANSLATION_ENABLED,
true);
632 externalServicePreferences.put(MESSAGE_SERVICE_HOST, info.getHost());
633 externalServicePreferences.put(MESSAGE_SERVICE_PORT, Integer.toString(info.getPort()));
634 externalServicePreferences.put(MESSAGE_SERVICE_USER, info.getUserName());
652 port = Integer.parseInt(externalServicePreferences.get(MESSAGE_SERVICE_PORT, DEFAULT_PORT_STRING));
653 }
catch (NumberFormatException ex) {
660 externalServicePreferences.get(MESSAGE_SERVICE_HOST,
""),
662 externalServicePreferences.get(MESSAGE_SERVICE_USER,
""),
665 throw new UserPreferencesException(
"Failed to convert password hex text to text.", ex);
675 int timeOut = machineSpecificPreferences.getInt(PROCESS_TIME_OUT_HOURS, DEFAULT_PROCESS_TIMEOUT_HR);
691 machineSpecificPreferences.putInt(PROCESS_TIME_OUT_HOURS, value);
702 boolean enabled = machineSpecificPreferences.getBoolean(PROCESS_TIME_OUT_ENABLED,
false);
714 machineSpecificPreferences.putBoolean(PROCESS_TIME_OUT_ENABLED, enabled);
732 modePreferences.put(APP_NAME, name);
741 return machineSpecificPreferences.getInt(MAX_NUM_OF_LOG_FILE, LOG_FILE_NUM_INT);
759 machineSpecificPreferences.putInt(MAX_NUM_OF_LOG_FILE, count);
771 return machineSpecificPreferences.getInt(SOLR_MAX_JVM_SIZE, DEFAULT_SOLR_HEAP_SIZE_MB_64BIT_PLATFORM);
773 return machineSpecificPreferences.getInt(SOLR_MAX_JVM_SIZE, DEFAULT_SOLR_HEAP_SIZE_MB_32BIT_PLATFORM);
783 machineSpecificPreferences.putInt(SOLR_MAX_JVM_SIZE, maxSize);
792 return viewPreferences.getInt(RESULTS_TABLE_PAGE_SIZE, 10_000);
801 viewPreferences.putInt(RESULTS_TABLE_PAGE_SIZE, pageSize);
810 viewPreferences.put(EXTERNAL_HEX_EDITOR_PATH, executablePath);
820 return viewPreferences.get(EXTERNAL_HEX_EDITOR_PATH, Paths.get(
"C:",
"Program Files",
"HxD",
"HxD.exe").toString());
829 externalServicePreferences.putInt(GEO_TILE_OPTION, option);
839 return externalServicePreferences.getInt(GEO_TILE_OPTION, 0);
848 machineSpecificPreferences.put(GEO_OSM_TILE_ZIP_PATH, absolutePath);
858 return machineSpecificPreferences.get(GEO_OSM_TILE_ZIP_PATH,
"");
868 externalServicePreferences.put(GEO_OSM_SERVER_ADDRESS, address);
877 return externalServicePreferences.get(GEO_OSM_SERVER_ADDRESS,
"");
886 machineSpecificPreferences.put(GEO_MBTILES_FILE_PATH, absolutePath);
895 return machineSpecificPreferences.get(GEO_MBTILES_FILE_PATH,
"");
914 File appTempDir = null;
918 appTempDir = (StringUtils.isBlank(customDirectory))
920 : Paths.get(customDirectory,
getAppName(), TEMP_FOLDER).toFile();
932 if (!appTempDir.exists()) {
936 return appTempDir.getAbsolutePath();
945 machineSpecificPreferences.put(HEALTH_MONITOR_REPORT_PATH, reportPath);
955 return machineSpecificPreferences.get(HEALTH_MONITOR_REPORT_PATH,
"");
static void setZkServerHost(String hostName)
static synchronized String getConfigSetting(String moduleName, String settingName)
static boolean getUseOcrInTranslation()
static final String HIDE_SLACK_FILES_IN_VIEWS_TREE
static int getDefaultLogFileCount()
static String getInferredUserTimeZone()
static void setGroupItemsInTreeByDatasource(boolean value)
static final ConfigProperties externalServicePreferences
static final ConfigProperties viewPreferences
static final boolean DISPLAY_TRANSLATED_NAMES_DEFAULT
static String getGeolocationOsmZipPath()
static final String HIDE_KNOWN_FILES_IN_VIEWS_TREE
static void setProcessTimeOutHrs(int value)
static void setZkServerPort(String port)
static final String VIEW_PREFERENCE_PATH
static void setKeepPreferredContentViewer(boolean value)
static String getExternalHexEditorPath()
static String getAppTempDirectory()
static int getProcessTimeOutHrs()
static String getSolr4ServerPort()
static String getTextTranslatorName()
static final String HIDE_SCO_COLUMNS
static boolean hideSlackFilesInDataSourcesTree()
static final List< String > EXTERNAL_SERVICE_KEYS
static final String LEGACY_CONFIG_PATH
static final int DEFAULT_PROCESS_TIMEOUT_HR
static String getIndexingServerPort()
static String getZkServerPort()
static final String SOLR_MAX_JVM_SIZE
static final String GROUP_ITEMS_IN_TREE_BY_DATASOURCE
static void setNumberOfFileIngestThreads(int value)
static String getAppName()
static void reloadFromStorage()
static void setGeolocationTileOption(int option)
static void setDisplayTimesInLocalTime(boolean value)
static final String EXTERNAL_DATABASE_NAME
static Boolean multiUserSupported
static final String EXTERNAL_DATABASE_USER
static int getLogFileCount()
static final String TEXT_TRANSLATOR_NAME
static void setMode(SelectedMode mode)
static final String GEO_OSM_TILE_ZIP_PATH
static boolean groupItemsInTreeByDatasource()
static final ConfigProperties modePreferences
static final String DEFAULT_PORT_STRING
static void setUseOcrInTranslation(boolean enableOcr)
static boolean getIsMultiUserModeEnabled()
static void setHideSlackFilesInViewsTree(boolean value)
static void setHealthMonitorReportPath(String reportPath)
static String getCustomTempDirectory()
static final ConfigProperties machineSpecificPreferences
static CaseDbConnectionInfo getDatabaseConnectionInfo()
static final String SHOW_ONLY_CURRENT_USER_TAGS
static boolean keepPreferredContentViewer()
static String getZkServerHost()
static boolean hideKnownFilesInViewsTree()
static void setHideSCOColumns(boolean value)
static void setIsTimeOutEnabled(boolean enabled)
static final List< String > MODE_PREFERENCE_KEYS
static void setMaxSolrVMSize(int maxSize)
static void setSolr4ServerPort(String port)
static void setResultsTablePageSize(int pageSize)
static String getGeolocationMBTilesFilePath()
static final String HIDE_KNOWN_FILES_IN_DATA_SRCS_TREE
static int getMaxSolrVMSize()
static final String EXTERNAL_HEX_EDITOR_PATH
static void setIsMultiUserModeEnabled(boolean enabled)
static final String SETTINGS_PROPERTIES
static void removeChangeListener(PreferenceChangeListener listener)
static final List< String > VIEW_PREFERENCE_KEYS
static void setMessageServiceConnectionInfo(MessageServiceConnectionInfo info)
static synchronized boolean settingExists(String moduleName, String settingName)
static final String IS_MULTI_USER_MODE_ENABLED
static final String NUMBER_OF_FILE_INGEST_THREADS
static boolean showOnlyCurrentUserTags()
static final String MODE_PREFERENCE_PATH
static final int DEFAULT_SOLR_HEAP_SIZE_MB_64BIT_PLATFORM
static void setHideKnownFilesInViewsTree(boolean value)
static boolean getIsTimeOutEnabled()
static int numberOfFileIngestThreads()
static final String DISPLAY_TIMES_IN_LOCAL_TIME
static void setTextTranslatorName(String textTranslatorName)
static final String SOLR8_SERVER_PORT
static void setAppName(String name)
static final String OCR_TRANSLATION_ENABLED
static boolean displayTranslatedFileNames()
static String getHealthMonitorReportPath()
static final int DEFAULT_PORT_INT
static void setDatabaseConnectionInfo(CaseDbConnectionInfo connectionInfo)
static final String EXTERNAL_DATABASE_PORTNUMBER
static final String PROCESS_TIME_OUT_ENABLED
static void setTimeZoneForDisplays(String timeZone)
static final String KEEP_PREFERRED_VIEWER
static File getSystemTempDirFile()
static synchronized void setConfigSetting(String moduleName, String settingName, String settingVal)
static final String SOLR8_SERVER_HOST
static final String RESULTS_TABLE_PAGE_SIZE
static final String GEO_MBTILES_FILE_PATH
static final String MESSAGE_SERVICE_PORT
static void saveToStorage()
static void setIndexingServerHost(String hostName)
static final String EXTERNAL_SERVICE_PREFERENCE_PATH
static void setDisplayTranslatedFileNames(boolean value)
static final String SOLR4_SERVER_PORT
static final String DISPLAY_TRANSLATED_NAMES
static final String MESSAGE_SERVICE_PASSWORD
static boolean getHideSCOColumns()
static boolean hideSlackFilesInViewsTree()
static String getSolr4ServerHost()
static final String HIDE_SLACK_FILES_IN_DATA_SRCS_TREE
static int getGeolocationtTileOption()
static final String ZK_SERVER_PORT
static void setHideSlackFilesInDataSourcesTree(boolean value)
static void setHideKnownFilesInDataSourcesTree(boolean value)
static void setIndexingServerPort(int port)
static void setGeolocationOsmZipPath(String absolutePath)
static final String PROCESS_TIME_OUT_HOURS
static void setLogFileCount(int count)
static final int LOG_FILE_NUM_INT
static final int DEFAULT_SOLR_HEAP_SIZE_MB_32BIT_PLATFORM
static String getSharedPreferencePath(String identifier)
static TempDirChoice getTempDirChoice()
static final String TEMP_FOLDER
static final String MESSAGE_SERVICE_HOST
static final String APP_NAME
static int getResultsTablePageSize()
static String getGeolocationOsmServerAddress()
static boolean isMultiUserSupported()
static boolean hideKnownFilesInDataSourcesTree()
static String getTimeZoneForDisplays()
static void setExternalHexEditorPath(String executablePath)
static final String MESSAGE_SERVICE_USER
static final String HEALTH_MONITOR_REPORT_PATH
static final String GEO_TILE_OPTION
static void addChangeListener(PreferenceChangeListener listener)
static final String ZK_SERVER_HOST
static final String EXTERNAL_DATABASE_TYPE
static final List< String > MACHINE_PREFERENCE_KEYS
static void setGeolocationMBTilesFilePath(String absolutePath)
static void setSolr4ServerHost(String hostName)
static void setShowOnlyCurrentUserTags(boolean value)
static String convertTextToHexText(String property)
static final String GEO_OSM_SERVER_ADDRESS
static void setGeolocationOsmServerAddress(String address)
static SelectedMode getMode()
static String getIndexingServerHost()
static final String TIME_ZONE_FOR_DISPLAYS
static boolean displayTimesInLocalTime()
static final String EXTERNAL_DATABASE_PASSWORD
static final String SOLR4_SERVER_HOST
static final String MAX_NUM_OF_LOG_FILE
static final String EXTERNAL_DATABASE_HOSTNAME_OR_IP
static final String MACHINE_SPECIFIC_PREFERENCE_PATH
static String getConfigPreferencePath(String identifier)
static MessageServiceConnectionInfo getMessageServiceConnectionInfo()
static String convertHexTextToText(String property)