Autopsy  4.1
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 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",
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));
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));
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 
112  public static FilesSet getDefaultFilter() {
114  }
115 
122  Map<String, FilesSet> getInterestingFilesSets() throws FilesSetsManagerException {
123  synchronized (INTERESTING_FILES_SET_LOCK) {
124  return InterestingItemsFilesSetSettings.readDefinitionsFile(INTERESTING_FILES_SET_DEFS_NAME, LEGACY_FILES_SET_DEFS_FILE_NAME);
125  }
126  }
127 
136  public Map<String, FilesSet> getCustomFileIngestFilters() throws FilesSetsManagerException {
137  synchronized (FILE_INGEST_FILTER_LOCK) {
138  return FileSetsDefinitions.readSerializedDefinitions(FILE_INGEST_FILTER_DEFS_NAME);
139  }
140  }
141 
149  void setInterestingFilesSets(Map<String, FilesSet> filesSets) throws FilesSetsManagerException {
150  synchronized (INTERESTING_FILES_SET_LOCK) {
151  InterestingItemsFilesSetSettings.writeDefinitionsFile(INTERESTING_FILES_SET_DEFS_NAME, filesSets);
152  this.setChanged();
153  this.notifyObservers();
154  }
155  }
156 
164  void setCustomFileIngestFilters(Map<String, FilesSet> filesSets) throws FilesSetsManagerException {
165  synchronized (FILE_INGEST_FILTER_LOCK) {
166  FileSetsDefinitions.writeDefinitionsFile(FILE_INGEST_FILTER_DEFS_NAME, filesSets);
167  }
168  }
169 
170  public static class FilesSetsManagerException extends Exception {
171 
172  FilesSetsManagerException() {
173 
174  }
175 
176  FilesSetsManagerException(String message) {
177  super(message);
178  }
179 
180  FilesSetsManagerException(String message, Throwable cause) {
181  super(message, cause);
182  }
183 
184  FilesSetsManagerException(Throwable cause) {
185  super(cause);
186  }
187  }
188 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon Apr 24 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.