Sleuth Kit Java Bindings (JNI)  4.2
Java bindings for using The Sleuth Kit
OSInfo.java
Go to the documentation of this file.
1 /*
2  * Sleuth Kit Data Model
3  *
4  * Copyright 2013 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 
22 
23 import java.util.Map;
24 import java.util.HashMap;
25 import java.util.ArrayList;
26 import java.util.List;
27 
31 public class OSInfo {
32 
33  private final List<BlackboardArtifact> artifacts;
34  private final Map<Integer, String> attributeMap;
35  private final boolean isBackup;
36  private final boolean haveFsContent;
37  private final long fileSystemId;
38  private final boolean haveParentId;
39  private final long parentObjId;
40 
41  public OSInfo() {
42  artifacts = new ArrayList<BlackboardArtifact>();
43  attributeMap = new HashMap<Integer, String>();
44  isBackup = false;
45  fileSystemId = 0;
46  haveFsContent = false;
47  parentObjId = 0;
48  haveParentId = false;
49  }
50 
63  public OSInfo(BlackboardArtifact a_art, boolean a_isBackup, long a_fileSystemId, Content a_parent) throws TskCoreException {
64  artifacts = new ArrayList<BlackboardArtifact>();
65  artifacts.add(a_art);
66  isBackup = a_isBackup;
67  fileSystemId = a_fileSystemId;
68  haveFsContent = true;
69  attributeMap = new HashMap<Integer, String>();
70  for (BlackboardAttribute attr : a_art.getAttributes()) {
71  attributeMap.put(attr.getAttributeTypeID(), attr.getValueString());
72  }
73 
74  if (a_parent != null) {
75  parentObjId = a_parent.getId();
76  haveParentId = true;
77  } else {
78  parentObjId = 0;
79  haveParentId = false;
80  }
81  }
82 
93  public OSInfo(BlackboardArtifact a_art, boolean a_isBackup, Content a_parent) throws TskCoreException {
94  artifacts = new ArrayList<BlackboardArtifact>();
95  artifacts.add(a_art);
96  isBackup = a_isBackup;
97  fileSystemId = 0;
98  haveFsContent = false;
99  if (a_parent != null) {
100  parentObjId = a_parent.getId();
101  haveParentId = true;
102  } else {
103  parentObjId = 0;
104  haveParentId = false;
105  }
106  attributeMap = new HashMap<Integer, String>();
107  for (BlackboardAttribute attr : a_art.getAttributes()) {
108  attributeMap.put(attr.getAttributeTypeID(), attr.getValueString());
109  }
110  }
111 
118  public boolean matches(OSInfo a_osInfo) {
119 
120  // Check if the two are in the same directory.
121  // OSInfo is only dependant on SYSTEM and SOFTWARE, which should always be in the same directory
122  // on the file system.
123  if (haveParentId && a_osInfo.haveParentId) {
124 
125  return (parentObjId == a_osInfo.parentObjId);
126  }
127 
128  // If we don't have a parent directory, just see if they're on the same file system,
129  // and both have the same backup status.
130  if (haveFsContent && a_osInfo.haveFsContent) {
131  return ((a_osInfo.isBackup == isBackup) && (a_osInfo.fileSystemId == fileSystemId));
132  }
133 
134  return false;
135  }
136 
142  public void combine(OSInfo a_osInfo) {
143  artifacts.addAll(a_osInfo.artifacts);
144  attributeMap.putAll(a_osInfo.attributeMap);
145  }
146 
147  public List<BlackboardArtifact> getArtifacts() {
148  return artifacts;
149  }
150 
151  public boolean haveFileSystem() {
152  return haveFsContent;
153  }
154 
155  public long getFileSystemId() {
156  return fileSystemId;
157  }
158 
159  public boolean getIsBackup() {
160  return isBackup;
161  }
162 
169  public String getAttributeValue(ATTRIBUTE_TYPE attrType) {
170  if (attributeMap.containsKey(attrType.getTypeID())) {
171  return attributeMap.get(attrType.getTypeID());
172  }
173  return "";
174  }
175 
176  /*
177  * Dedicated getters for the most common attributes.
178  */
179  public String getCompName() {
181  }
182 
183  public String getProcessorArchitecture() {
185  }
186 
187  public String getDomain() {
189  }
190 
191  public String getOSName() {
193  }
194 
195 }
final Map< Integer, String > attributeMap
Definition: OSInfo.java:34
OSInfo(BlackboardArtifact a_art, boolean a_isBackup, Content a_parent)
Definition: OSInfo.java:93
OSInfo(BlackboardArtifact a_art, boolean a_isBackup, long a_fileSystemId, Content a_parent)
Definition: OSInfo.java:63
final boolean haveFsContent
Definition: OSInfo.java:36
boolean matches(OSInfo a_osInfo)
Definition: OSInfo.java:118
List< BlackboardArtifact > getArtifacts()
Definition: OSInfo.java:147
final boolean haveParentId
Definition: OSInfo.java:38
final List< BlackboardArtifact > artifacts
Definition: OSInfo.java:33
void combine(OSInfo a_osInfo)
Definition: OSInfo.java:142
String getAttributeValue(ATTRIBUTE_TYPE attrType)
Definition: OSInfo.java:169

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