Sleuth Kit Java Bindings (JNI)  4.11.0
Java bindings for using The Sleuth Kit
DerivedFile.java
Go to the documentation of this file.
1 /*
2  * SleuthKit Java Bindings
3  *
4  * Copyright 2011-2017 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.datamodel;
20 
21 import java.text.MessageFormat;
22 import java.util.Collections;
23 import java.util.ResourceBundle;
24 import java.util.logging.Level;
25 import java.util.logging.Logger;
31 
37 public 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 
91  long objId,
92  long dataSourceObjectId,
93  String name,
96  long size,
97  long ctime, long crtime, long atime, long mtime,
98  String md5Hash, String sha256Hash, FileKnown knownState,
99  String parentPath,
100  String localPath,
101  long parentId,
102  String mimeType,
103  TskData.EncodingType encodingType,
104  String extension,
105  String ownerUid,
106  Long osAccountObjId) {
107  // TODO (AUT-1904): The parent id should be passed to AbstractContent
108  // through the class hierarchy contructors.
109  super(db, objId, dataSourceObjectId, TskData.TSK_FS_ATTR_TYPE_ENUM.TSK_FS_ATTR_TYPE_DEFAULT, 0,
110  name, TSK_DB_FILES_TYPE_ENUM.DERIVED, 0L, 0, dirType, metaType, dirFlag,
111  metaFlags, size, ctime, crtime, atime, mtime, (short) 0, 0, 0, md5Hash, sha256Hash, knownState, parentPath, mimeType, extension, ownerUid, osAccountObjId, Collections.emptyList());
112  setLocalFilePath(localPath);
113  setEncodingType(encodingType);
114  }
115 
122  @Override
123  public boolean isRoot() {
124  return false;
125  }
126 
135  public synchronized DerivedMethod getDerivedMethod() throws TskCoreException {
136  if (derivedMethod == null && hasDerivedMethod == true) {
137  try {
138  derivedMethod = getSleuthkitCase().getDerivedMethod(getId());
139  if (derivedMethod == null) {
140  hasDerivedMethod = false; //do not attempt to lazy load
141  }
142  } catch (TskCoreException e) {
143  String msg = MessageFormat.format(bundle.getString("DerviedFile.derivedMethod.exception.msg1.text"), getId());
144  logger.log(Level.WARNING, msg, e);
145  throw new TskCoreException(msg, e);
146  }
147  }
148  return derivedMethod;
149  }
150 
159  @Override
160  public <T> T accept(SleuthkitItemVisitor<T> v) {
161  return v.visit(this);
162  }
163 
172  @Override
173  public <T> T accept(ContentVisitor<T> v) {
174  return v.visit(this);
175  }
176 
182  @Override
183  protected void finalize() throws Throwable {
184  try {
185  close();
186  } finally {
187  super.finalize();
188  }
189  }
190 
198  @Override
199  public String toString(boolean preserveState) {
200  return super.toString(preserveState) + "DerivedFile{" //NON-NLS
201  + "derivedMethod=" + derivedMethod //NON-NLS
202  + ", hasDerivedMethod=" + hasDerivedMethod //NON-NLS
203  + '}';
204  }
205 
209  public static class DerivedMethod {
210 
211  private final int derivedId;
212  private String toolName;
213  private String toolVersion;
214  private String other;
215  private String rederiveDetails;
216 
217  public DerivedMethod(int derivedId, String rederiveDetails) {
218  this.derivedId = derivedId;
219  this.rederiveDetails = rederiveDetails;
220  if (this.rederiveDetails == null) {
221  this.rederiveDetails = "";
222  }
223  this.toolName = "";
224  this.toolVersion = "";
225  this.other = "";
226  }
227 
228  void setToolName(String toolName) {
229  this.toolName = toolName;
230  }
231 
232  void setToolVersion(String toolVersion) {
233  this.toolVersion = toolVersion;
234  }
235 
236  void setOther(String other) {
237  this.other = other;
238  }
239 
240  public int getDerivedId() {
241  return derivedId;
242  }
243 
244  public String getToolName() {
245  return toolName;
246  }
247 
248  public String getToolVersion() {
249  return toolVersion;
250  }
251 
252  public String getOther() {
253  return other;
254  }
255 
256  public String getRederiveDetails() {
257  return rederiveDetails;
258  }
259 
260  @Override
261  public String toString() {
262  return "DerivedMethod{" + "derived_id=" + derivedId + ", toolName=" + toolName + ", toolVersion=" + toolVersion + ", other=" + other + ", rederiveDetails=" + rederiveDetails + '}'; //NON-NLS
263  }
264  }
265 
299  @Deprecated
300  @SuppressWarnings("deprecation")
302  long objId,
303  String name,
305  TSK_FS_NAME_FLAG_ENUM dirFlag, short metaFlags,
306  long size,
307  long ctime, long crtime, long atime, long mtime,
308  String md5Hash, FileKnown knownState,
309  String parentPath,
310  String localPath,
311  long parentId) {
312  this(db, objId, db.getDataSourceObjectId(objId), name, dirType, metaType, dirFlag, metaFlags, size,
313  ctime, crtime, atime, mtime,
314  md5Hash, null, knownState,
315  parentPath, localPath, parentId, null, TskData.EncodingType.NONE, null, OsAccount.NO_OWNER_ID, OsAccount.NO_ACCOUNT);
316  }
317 
318 }
final TSK_FS_NAME_TYPE_ENUM dirType
DerivedMethod(int derivedId, String rederiveDetails)
String toString(boolean preserveState)
Set< TSK_FS_META_FLAG_ENUM > metaFlags
DERIVED
File derived from a parent file (i.e. from ZIP)
Definition: TskData.java:687
synchronized DerivedMethod getDerivedMethod()
final TSK_FS_META_TYPE_ENUM metaType

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