Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
CTSettings.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2023 Basis Technology Corp.
5 * Contact: carrier <at> sleuthkit <dot> org
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19package com.basistech.df.cybertriage.autopsy.incidentoptions;
20
21import java.io.IOException;
22import java.nio.file.Files;
23import java.nio.file.Path;
24import java.nio.file.Paths;
25import java.util.Objects;
26import java.util.logging.Level;
27import org.sleuthkit.autopsy.coreutils.Logger;
28import org.apache.commons.lang3.StringUtils;
29import org.openide.modules.Places;
30import org.sleuthkit.autopsy.coreutils.PlatformUtil;
31
36public class CTSettings {
37
38 private static final Logger LOGGER = Logger.getLogger(CTSettings.class.getCanonicalName());
39 private static final String DEFAULT_FILE_REPO_PATH = getAppDataLocalDirectory();
40
41 private static final String CYBERTRIAGE_FOLDER = "cybertriage";
42 private static final String CYBERTRIAGE_DOT_FOLDER = "." + CYBERTRIAGE_FOLDER;
43
44 // based on com.basistech.df.cybertriage.utils.SystemProperties
45 private static String getAppDataLocalDirectory() {
46 if (Objects.nonNull(Places.getUserDirectory()) && Places.getUserDirectory().getAbsolutePath().endsWith("testuserdir")) { // APP is in testing .. this should return the test path
47 LOGGER.log(Level.INFO, "Application Data (test mode) Path: " + Places.getUserDirectory().getAbsolutePath());
48 return Places.getUserDirectory().getAbsolutePath();
49 }
50
51 // try to use LOCALAPPDATA on windows
52 String localDataStr = System.getenv("LOCALAPPDATA");
53 if (StringUtils.isNotBlank(localDataStr)) {
54 Path localAppPath = Paths.get(localDataStr, CYBERTRIAGE_FOLDER);
55 try {
56 Files.createDirectories(localAppPath);
57 LOGGER.log(Level.INFO, "Application Data Path: " + localAppPath.toString());
58 return localAppPath.toString();
59 } catch (IOException ex) {
60 LOGGER.log(Level.SEVERE, "IO Error using " + localAppPath.toString(), ex);
61 }
62 }
63
64 // try to use ~/.cybertriage anywhere else
66 String homePathStr = System.getenv("HOME");
67 if (StringUtils.isNotBlank(homePathStr)) {
68 Path localAppPath = Paths.get(homePathStr, CYBERTRIAGE_DOT_FOLDER);
69 try {
70 Files.createDirectories(localAppPath);
71 LOGGER.log(Level.INFO, "Non-windows Application Data Path: " + localAppPath.toString());
72 return localAppPath.toString();
73 } catch (IOException ex) {
74 LOGGER.log(Level.SEVERE, "IO Error using " + localAppPath.toString(), ex);
75 }
76 }
77 }
78
79 // defer to user directory otherwise
80 return Places.getUserDirectory().getAbsolutePath(); // In case of an IO Error
81 }
82
83 public static String getDefaultFileRepoPath() {
85 }
86
87 static CTSettings getDefaultSettings() {
88 return new CTSettings()
90 }
91
93
94 public String getFileRepoPath() {
95 return fileRepoPath;
96 }
97
99 this.fileRepoPath = fileRepoPath;
100 return this;
101 }
102}
synchronized static Logger getLogger(String name)
Definition Logger.java:124

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.