Autopsy  4.11.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
FileTypeUtils.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2018-2019 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.datamodel.utils;
20 
21 import com.google.common.collect.ImmutableSet;
22 import static java.util.Arrays.asList;
23 import java.util.Collection;
24 import java.util.Collections;
25 import javax.imageio.ImageIO;
26 import static org.apache.commons.collections4.ListUtils.removeAll;
27 import org.openide.util.NbBundle;
28 
32 public final class FileTypeUtils {
33 
34  private static final ImmutableSet<String> IMAGE_MIME_TYPES
35  = new ImmutableSet.Builder<String>()
36  .addAll(removeAll(asList(ImageIO.getReaderMIMETypes()),
37  asList("application/octet-stream"))) //this claims to be supported, but is not really an image.
38  .add("image/bmp", //NON-NLS
39  "image/gif", //NON-NLS
40  "image/jpeg", //NON-NLS
41  "image/png", //NON-NLS
42  "image/tiff", //NON-NLS
43  "image/vnd.adobe.photoshop", //NON-NLS
44  "image/x-raw-nikon", //NON-NLS
45  "image/x-ms-bmp", //NON-NLS
46  "image/x-icon", //NON-NLS
47  "image/webp", //NON-NLS
48  "image/vnd.microsoft.icon", //NON-NLS
49  "image/x-rgb", //NON-NLS
50  "image/x-ms-bmp", //NON-NLS
51  "image/x-xbitmap", //NON-NLS
52  "image/x-portable-graymap", //NON-NLS
53  "image/x-portable-bitmap" //NON-NLS
54  ).build();
55  private static final ImmutableSet<String> AUDIO_MIME_TYPES
56  = new ImmutableSet.Builder<String>()
57  .add("audio/midi", //NON-NLS
58  "audio/mpeg", //NON-NLS
59  "audio/webm", //NON-NLS
60  "audio/ogg", //NON-NLS
61  "audio/wav", //NON-NLS
62  "audio/vnd.wave", //NON-NLS
63  "audio/x-ms-wma"//NON-NLS
64  ).build();
65  private static final ImmutableSet<String> VIDEO_MIME_TYPES
66  = new ImmutableSet.Builder<String>()
67  .add("video/webm", //NON-NLS
68  "video/3gpp", //NON-NLS
69  "video/3gpp2", //NON-NLS
70  "video/ogg", //NON-NLS
71  "video/mpeg", //NON-NLS
72  "video/mp4", //NON-NLS
73  "video/quicktime", //NON-NLS
74  "video/x-msvideo", //NON-NLS
75  "video/x-flv", //NON-NLS
76  "video/x-m4v", //NON-NLS
77  "video/x-ms-wmv"//NON-NLS
78  ).build();
79  private static final ImmutableSet<String> DOCUMENT_MIME_TYPES
80  = new ImmutableSet.Builder<String>()
81  .add("text/plain", //NON-NLS
82  "text/css", //NON-NLS
83  "text/html", //NON-NLS
84  "text/csv", //NON-NLS
85  "text/xml", //NON-NLS
86  "text/x-log", //NON-NLS
87  "application/rtf", //NON-NLS
88  "application/pdf", //NON-NLS
89  "application/json", //NON-NLS
90  "application/javascript", //NON-NLS
91  "application/xml", //NON-NLS
92  "application/xhtml+xml", //NON-NLS
93  "application/x-msoffice", //NON-NLS
94  "application/x-ooxml", //NON-NLS
95  "application/msword", //NON-NLS
96  "application/msword2", //NON-NLS
97  "application/vnd.wordperfect", //NON-NLS
98  "application/vnd.openxmlformats-officedocument.wordprocessingml.document", //NON-NLS
99  "application/vnd.ms-powerpoint", //NON-NLS
100  "application/vnd.openxmlformats-officedocument.presentationml.presentation", //NON-NLS
101  "application/vnd.ms-excel", //NON-NLS
102  "application/vnd.ms-excel.sheet.4", //NON-NLS
103  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", //NON-NLS
104  "application/vnd.oasis.opendocument.presentation", //NON-NLS
105  "application/vnd.oasis.opendocument.spreadsheet", //NON-NLS
106  "application/vnd.oasis.opendocument.text" //NON-NLS
107  ).build();
108  private static final ImmutableSet<String> EXECUTABLE_MIME_TYPES
109  = new ImmutableSet.Builder<String>()
110  .add("application/x-bat",//NON-NLS
111  "application/x-dosexec",//NON-NLS
112  "application/vnd.microsoft.portable-executable",//NON-NLS
113  "application/x-msdownload",//NON-NLS
114  "application/exe",//NON-NLS
115  "application/x-exe",//NON-NLS
116  "application/dos-exe",//NON-NLS
117  "vms/exe",//NON-NLS
118  "application/x-winexe",//NON-NLS
119  "application/msdos-windows",//NON-NLS
120  "application/x-msdos-program"//NON-NLS
121  ).build();
122  private static final ImmutableSet<String> MULTI_MEDIA_MIME_TYPES
123  = new ImmutableSet.Builder<String>()
124  .addAll(IMAGE_MIME_TYPES)
125  .addAll(AUDIO_MIME_TYPES)
126  .addAll(VIDEO_MIME_TYPES)
127  .build();
128  private static final ImmutableSet<String> VISUAL_MEDIA_MIME_TYPES
129  = new ImmutableSet.Builder<String>()
130  .addAll(IMAGE_MIME_TYPES)
131  .addAll(VIDEO_MIME_TYPES)
132  .add("application/vnd.ms-asf", //NON-NLS
133  "application/vnd.rn-realmedia", //NON-NLS
134  "application/x-shockwave-flash" //NON-NLS
135  ).build();
136 
137  private FileTypeUtils() {
138 
139  }
140 
144  @NbBundle.Messages({
145  "FileTypeCategory.Audio.displayName=Audio",
146  "FileTypeCategory.Video.displayName=Video",
147  "FileTypeCategory.Image.displayName=Image",
148  "FileTypeCategory.Media.displayName=Media",
149  "FileTypeCategory.Visual.displayName=Visual",
150  "FileTypeCategory.Documents.displayName=Documents",
151  "FileTypeCategory.Executables.displayName=Executables"})
152  public enum FileTypeCategory {
153 
154  IMAGE(Bundle.FileTypeCategory_Image_displayName(),
156  Collections.emptyList()),
157  VIDEO(Bundle.FileTypeCategory_Video_displayName(),
159  Collections.emptyList()),
160  AUDIO(Bundle.FileTypeCategory_Audio_displayName(),
162  Collections.emptyList()),
166  VISUAL(Bundle.FileTypeCategory_Visual_displayName(),
168  Collections.emptyList()),
172  MEDIA(Bundle.FileTypeCategory_Media_displayName(),
174  Collections.emptyList()),
175  EXECUTABLE(Bundle.FileTypeCategory_Executables_displayName(),
177  Collections.emptyList()),
181  DOCUMENTS(Bundle.FileTypeCategory_Documents_displayName(),
183  Collections.emptyList());
184 
185  private final String displayName;
186  private final ImmutableSet<String> mediaTypes;
187  private final ImmutableSet<String> extensions;
188 
189  private FileTypeCategory(String displayName, Collection<String> mediaTypes, Collection<String> extensions) {
190  this.displayName = displayName;
191  this.mediaTypes = ImmutableSet.copyOf(mediaTypes);
192  this.extensions = ImmutableSet.copyOf(extensions);
193  }
194 
195  public String getDisplayName() {
196  return displayName;
197  }
198 
199  public ImmutableSet<String> getMediaTypes() {
200  return mediaTypes;
201 
202  }
203 
204  public ImmutableSet<String> getExtensions() {
205  throw new UnsupportedOperationException("This method is not implemented yet."); //just to be explicit.
206  }
207  }
208 }
static final ImmutableSet< String > VISUAL_MEDIA_MIME_TYPES
static final ImmutableSet< String > AUDIO_MIME_TYPES
FileTypeCategory(String displayName, Collection< String > mediaTypes, Collection< String > extensions)
static final ImmutableSet< String > MULTI_MEDIA_MIME_TYPES
static final ImmutableSet< String > EXECUTABLE_MIME_TYPES
static final ImmutableSet< String > VIDEO_MIME_TYPES
static final ImmutableSet< String > IMAGE_MIME_TYPES
static final ImmutableSet< String > DOCUMENT_MIME_TYPES

Copyright © 2012-2018 Basis Technology. Generated on: Fri Jun 21 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.