Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
FilesSetsManager.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014-2018 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  */
19 package org.sleuthkit.autopsy.modules.interestingitems;
20 
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.Collections;
24 import java.util.HashMap;
25 import java.util.List;
26 import java.util.Map;
27 import java.util.Observable;
28 import org.openide.util.NbBundle;
31 
38 public final class FilesSetsManager extends Observable {
39 
40  @NbBundle.Messages({"FilesSetsManager.allFilesAndDirectories=All Files and Directories (Not Unallocated Space)",
41  "FilesSetsManager.allFilesDirectoriesAndUnallocated=All Files, Directories, and Unallocated Space"})
42  private static final List<String> ILLEGAL_FILE_NAME_CHARS = Collections.unmodifiableList(new ArrayList<>(Arrays.asList("\\", "/", ":", "*", "?", "\"", "<", ">")));
43  private static final List<String> ILLEGAL_FILE_PATH_CHARS = Collections.unmodifiableList(new ArrayList<>(Arrays.asList("\\", ":", "*", "?", "\"", "<", ">")));
44  private static final String LEGACY_FILES_SET_DEFS_FILE_NAME = "InterestingFilesSetDefs.xml"; //NON-NLS
45  private static final String INTERESTING_FILES_SET_DEFS_NAME = "InterestingFileSets.settings";
46  private static final String FILE_INGEST_FILTER_DEFS_NAME = "FileIngestFilterDefs.settings";
47  private static final Object FILE_INGEST_FILTER_LOCK = new Object();
48  private static final Object INTERESTING_FILES_SET_LOCK = new Object();
49  private static FilesSetsManager instance;
50  private static final FilesSet FILES_DIRS_INGEST_FILTER = new FilesSet(
51  Bundle.FilesSetsManager_allFilesAndDirectories(), Bundle.FilesSetsManager_allFilesAndDirectories(), false, true, new HashMap<String, Rule>() {
52  {
53  put(Bundle.FilesSetsManager_allFilesAndDirectories(),
54  new Rule(Bundle.FilesSetsManager_allFilesAndDirectories(), null,
55  new MetaTypeCondition(MetaTypeCondition.Type.ALL), null, null, null, null));
56  }
57  });
59  Bundle.FilesSetsManager_allFilesDirectoriesAndUnallocated(), Bundle.FilesSetsManager_allFilesDirectoriesAndUnallocated(),
60  false, false, new HashMap<String, Rule>() {
61  {
62  put(Bundle.FilesSetsManager_allFilesDirectoriesAndUnallocated(),
63  new Rule(Bundle.FilesSetsManager_allFilesDirectoriesAndUnallocated(), null,
64  new MetaTypeCondition(MetaTypeCondition.Type.ALL), null, null, null, null));
65  }
66  });
67 
71  public synchronized static FilesSetsManager getInstance() {
72  if (instance == null) {
73  instance = new FilesSetsManager();
74  }
75  return instance;
76  }
77 
83  static List<String> getIllegalFileNameChars() {
85  }
86 
93  static List<String> getIllegalFilePathChars() {
94  return FilesSetsManager.ILLEGAL_FILE_PATH_CHARS;
95  }
96 
102  public static List<FilesSet> getStandardFileIngestFilters() {
103  return Arrays.asList(FILES_DIRS_UNALLOC_INGEST_FILTER, FILES_DIRS_INGEST_FILTER);
104  }
105 
114  public Map<String, FilesSet> getCustomFileIngestFilters() throws FilesSetsManagerException {
115  synchronized (FILE_INGEST_FILTER_LOCK) {
116  return FileSetsDefinitions.readSerializedDefinitions(FILE_INGEST_FILTER_DEFS_NAME);
117  }
118  }
119 
126  public static FilesSet getDefaultFilter() {
128  }
129 
137  void setCustomFileIngestFilters(Map<String, FilesSet> filesSets) throws FilesSetsManagerException {
138  synchronized (FILE_INGEST_FILTER_LOCK) {
139  FileSetsDefinitions.writeDefinitionsFile(FILE_INGEST_FILTER_DEFS_NAME, filesSets);
140  }
141  }
142 
143 
150  public Map<String, FilesSet> getInterestingFilesSets() throws FilesSetsManagerException {
151  synchronized (INTERESTING_FILES_SET_LOCK) {
152  return InterestingItemsFilesSetSettings.readDefinitionsFile(INTERESTING_FILES_SET_DEFS_NAME, LEGACY_FILES_SET_DEFS_FILE_NAME);
153  }
154  }
155 
156 
164  void setInterestingFilesSets(Map<String, FilesSet> filesSets) throws FilesSetsManagerException {
165  synchronized (INTERESTING_FILES_SET_LOCK) {
166  InterestingItemsFilesSetSettings.writeDefinitionsFile(INTERESTING_FILES_SET_DEFS_NAME, filesSets);
167  this.setChanged();
168  this.notifyObservers();
169  }
170  }
171 
172 
173 
174  public static class FilesSetsManagerException extends Exception {
175 
177 
178  }
179 
180  FilesSetsManagerException(String message) {
181  super(message);
182  }
183 
184  FilesSetsManagerException(String message, Throwable cause) {
185  super(message, cause);
186  }
187 
188  FilesSetsManagerException(Throwable cause) {
189  super(cause);
190  }
191  }
192 }

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.