Sleuth Kit Java Bindings (JNI)  4.6.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.ResourceBundle;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
30 
36 public class DerivedFile extends AbstractFile {
37 
38  private volatile DerivedMethod derivedMethod;
39  private static final Logger logger = Logger.getLogger(DerivedFile.class.getName());
40  private static ResourceBundle bundle = ResourceBundle.getBundle("org.sleuthkit.datamodel.Bundle");
41  private boolean hasDerivedMethod = true;
42 
87  long objId,
88  long dataSourceObjectId,
89  String name,
92  long size,
93  long ctime, long crtime, long atime, long mtime,
95  String parentPath,
96  String localPath,
97  long parentId,
98  String mimeType,
99  TskData.EncodingType encodingType,
100  String extension) {
101  // TODO (AUT-1904): The parent id should be passed to AbstractContent
102  // through the class hierarchy contructors.
103  super(db, objId, dataSourceObjectId, TskData.TSK_FS_ATTR_TYPE_ENUM.TSK_FS_ATTR_TYPE_DEFAULT, 0,
104  name, TSK_DB_FILES_TYPE_ENUM.LOCAL, 0L, 0, dirType, metaType, dirFlag,
105  metaFlags, size, ctime, crtime, atime, mtime, (short) 0, 0, 0, md5Hash, knownState, parentPath, mimeType, extension);
106  setLocalFilePath(localPath, false);
107  setEncodingType(encodingType);
108  }
109 
116  @Override
117  public boolean isRoot() {
118  return false;
119  }
120 
129  public synchronized DerivedMethod getDerivedMethod() throws TskCoreException {
130  if (derivedMethod == null && hasDerivedMethod == true) {
131  try {
132  derivedMethod = getSleuthkitCase().getDerivedMethod(getId());
133  if (derivedMethod == null) {
134  hasDerivedMethod = false; //do not attempt to lazy load
135  }
136  } catch (TskCoreException e) {
137  String msg = MessageFormat.format(bundle.getString("DerviedFile.derivedMethod.exception.msg1.text"), getId());
138  logger.log(Level.WARNING, msg, e);
139  throw new TskCoreException(msg, e);
140  }
141  }
142  return derivedMethod;
143  }
144 
153  @Override
154  public <T> T accept(SleuthkitItemVisitor<T> v) {
155  return v.visit(this);
156  }
157 
166  @Override
167  public <T> T accept(ContentVisitor<T> v) {
168  return v.visit(this);
169  }
170 
176  @Override
177  protected void finalize() throws Throwable {
178  try {
179  close();
180  } finally {
181  super.finalize();
182  }
183  }
184 
192  @Override
193  public String toString(boolean preserveState) {
194  return super.toString(preserveState) + "DerivedFile{" //NON-NLS
195  + "derivedMethod=" + derivedMethod //NON-NLS
196  + ", hasDerivedMethod=" + hasDerivedMethod //NON-NLS
197  + '}';
198  }
199 
203  public static class DerivedMethod {
204 
205  private final int derivedId;
206  private String toolName;
207  private String toolVersion;
208  private String other;
209  private String rederiveDetails;
210 
211  public DerivedMethod(int derivedId, String rederiveDetails) {
212  this.derivedId = derivedId;
213  this.rederiveDetails = rederiveDetails;
214  if (this.rederiveDetails == null) {
215  this.rederiveDetails = "";
216  }
217  this.toolName = "";
218  this.toolVersion = "";
219  this.other = "";
220  }
221 
222  void setToolName(String toolName) {
223  this.toolName = toolName;
224  }
225 
226  void setToolVersion(String toolVersion) {
227  this.toolVersion = toolVersion;
228  }
229 
230  void setOther(String other) {
231  this.other = other;
232  }
233 
234  public int getDerivedId() {
235  return derivedId;
236  }
237 
238  public String getToolName() {
239  return toolName;
240  }
241 
242  public String getToolVersion() {
243  return toolVersion;
244  }
245 
246  public String getOther() {
247  return other;
248  }
249 
250  public String getRederiveDetails() {
251  return rederiveDetails;
252  }
253 
254  @Override
255  public String toString() {
256  return "DerivedMethod{" + "derived_id=" + derivedId + ", toolName=" + toolName + ", toolVersion=" + toolVersion + ", other=" + other + ", rederiveDetails=" + rederiveDetails + '}'; //NON-NLS
257  }
258  }
259 
294  @Deprecated
295  @SuppressWarnings("deprecation")
297  long objId,
298  String name,
300  TSK_FS_NAME_FLAG_ENUM dirFlag, short metaFlags,
301  long size,
302  long ctime, long crtime, long atime, long mtime,
303  String md5Hash, FileKnown knownState,
304  String parentPath,
305  String localPath,
306  long parentId) {
307  this(db, objId, db.getDataSourceObjectId(objId), name, dirType, metaType, dirFlag, metaFlags, size,
308  ctime, crtime, atime, mtime,
310  parentPath, localPath, parentId, null, TskData.EncodingType.NONE, null);
311  }
312 
313 }
final TSK_FS_NAME_TYPE_ENUM dirType
DerivedMethod(int derivedId, String rederiveDetails)
final TSK_FS_NAME_FLAG_ENUM dirFlag
LOCAL
Local file that was added (not from a disk image)
Definition: TskData.java:673
String toString(boolean preserveState)
final Set< TSK_FS_META_FLAG_ENUM > metaFlags
synchronized DerivedMethod getDerivedMethod()
final TSK_FS_META_TYPE_ENUM metaType

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