Sleuth Kit Java Bindings (JNI) 4.14.0
Java bindings for using The Sleuth Kit
Loading...
Searching...
No Matches
DerivedFile.java
Go to the documentation of this file.
1/*
2 * SleuthKit Java Bindings
3 *
4 * Copyright 2011-2022 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 org.sleuthkit.datamodel;
20
21import java.text.MessageFormat;
22import java.util.Collections;
23import java.util.ResourceBundle;
24import java.util.logging.Level;
25import java.util.logging.Logger;
26import org.sleuthkit.datamodel.TskData.FileKnown;
27import org.sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM;
28import org.sleuthkit.datamodel.TskData.TSK_FS_META_TYPE_ENUM;
29import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
30import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_TYPE_ENUM;
31
37public class DerivedFile extends AbstractFile {
38
39 private volatile DerivedMethod derivedMethod;
40 private static final Logger logger = Logger.getLogger(DerivedFile.class.getName());
41 private static ResourceBundle bundle = ResourceBundle.getBundle("org.sleuthkit.datamodel.Bundle");
42 private boolean hasDerivedMethod = true;
43
93 DerivedFile(SleuthkitCase db,
94 long objId,
95 long dataSourceObjectId,
97 String name,
100 long size,
101 long ctime, long crtime, long atime, long mtime,
102 String md5Hash, String sha256Hash, String sha1Hash,
104 String parentPath,
105 String localPath,
106 long parentId,
107 String mimeType,
108 TskData.EncodingType encodingType,
109 String extension,
110 String ownerUid,
111 Long osAccountObjId) {
112 // TODO (AUT-1904): The parent id should be passed to AbstractContent
113 // through the class hierarchy contructors.
114 super(db, objId, dataSourceObjectId, fileSystemObjectId, TskData.TSK_FS_ATTR_TYPE_ENUM.TSK_FS_ATTR_TYPE_DEFAULT, 0,
116 metaFlags, size, ctime, crtime, atime, mtime, (short) 0, 0, 0, md5Hash, sha256Hash, sha1Hash, knownState, parentPath, mimeType, extension, ownerUid, osAccountObjId, TskData.CollectedStatus.UNKNOWN, Collections.emptyList());
117 setLocalFilePath(localPath);
118 setEncodingType(encodingType);
119 }
120
127 @Override
128 public boolean isRoot() {
129 return false;
130 }
131
140 public synchronized DerivedMethod getDerivedMethod() throws TskCoreException {
141 if (derivedMethod == null && hasDerivedMethod == true) {
142 try {
143 derivedMethod = getSleuthkitCase().getDerivedMethod(getId());
144 if (derivedMethod == null) {
145 hasDerivedMethod = false; //do not attempt to lazy load
146 }
147 } catch (TskCoreException e) {
148 String msg = MessageFormat.format(bundle.getString("DerviedFile.derivedMethod.exception.msg1.text"), getId());
149 logger.log(Level.WARNING, msg, e);
150 throw new TskCoreException(msg, e);
151 }
152 }
153 return derivedMethod;
154 }
155
164 @Override
165 public <T> T accept(SleuthkitItemVisitor<T> v) {
166 return v.visit(this);
167 }
168
177 @Override
178 public <T> T accept(ContentVisitor<T> v) {
179 return v.visit(this);
180 }
181
187 @Override
188 protected void finalize() throws Throwable {
189 try {
190 close();
191 } finally {
192 super.finalize();
193 }
194 }
195
203 @Override
204 public String toString(boolean preserveState) {
205 return super.toString(preserveState) + "DerivedFile{" //NON-NLS
206 + "derivedMethod=" + derivedMethod //NON-NLS
207 + ", hasDerivedMethod=" + hasDerivedMethod //NON-NLS
208 + '}';
209 }
210
214 public static class DerivedMethod {
215
216 private final int derivedId;
217 private String toolName;
218 private String toolVersion;
219 private String other;
220 private String rederiveDetails;
221
222 public DerivedMethod(int derivedId, String rederiveDetails) {
223 this.derivedId = derivedId;
224 this.rederiveDetails = rederiveDetails;
225 if (this.rederiveDetails == null) {
226 this.rederiveDetails = "";
227 }
228 this.toolName = "";
229 this.toolVersion = "";
230 this.other = "";
231 }
232
233 void setToolName(String toolName) {
234 this.toolName = toolName;
235 }
236
237 void setToolVersion(String toolVersion) {
238 this.toolVersion = toolVersion;
239 }
240
241 void setOther(String other) {
242 this.other = other;
243 }
244
245 public int getDerivedId() {
246 return derivedId;
247 }
248
249 public String getToolName() {
250 return toolName;
251 }
252
253 public String getToolVersion() {
254 return toolVersion;
255 }
256
257 public String getOther() {
258 return other;
259 }
260
261 public String getRederiveDetails() {
262 return rederiveDetails;
263 }
264
265 @Override
266 public String toString() {
267 return "DerivedMethod{" + "derived_id=" + derivedId + ", toolName=" + toolName + ", toolVersion=" + toolVersion + ", other=" + other + ", rederiveDetails=" + rederiveDetails + '}'; //NON-NLS
268 }
269 }
270}
Set< TSK_FS_META_FLAG_ENUM > metaFlags
final TSK_FS_NAME_TYPE_ENUM dirType
final TSK_FS_META_TYPE_ENUM metaType
DerivedMethod(int derivedId, String rederiveDetails)
String toString(boolean preserveState)
synchronized DerivedMethod getDerivedMethod()
DERIVED
File derived from a parent file (i.e. from ZIP).
Definition TskData.java:697

Copyright © 2011-2024 Brian Carrier. (carrier -at- sleuthkit -dot- org)
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.