Autopsy  4.17.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
SingleDetailsViewEvent.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.timeline.ui.detailview.datamodel;
20 
21 import com.google.common.collect.ImmutableMap;
22 import com.google.common.collect.ImmutableSortedSet;
23 import java.util.Collections;
24 import java.util.Comparator;
25 import java.util.Optional;
26 import java.util.Set;
27 import java.util.SortedSet;
28 import org.joda.time.Interval;
29 import org.sleuthkit.datamodel.TimelineEvent;
30 import org.sleuthkit.datamodel.TimelineEventType;
31 import org.sleuthkit.datamodel.TimelineLevelOfDetail;
32 
36 public class SingleDetailsViewEvent implements DetailViewEvent {
37 
38  private final long eventID;
43  private final long fileObjId;
44 
49  private final Long artifactID;
50 
54  private final long dataSourceObjId;
55 
59  private final long time;
63  private final TimelineEventType type;
64 
69  private final ImmutableMap<TimelineLevelOfDetail, String> descriptions;
70 
75  private final boolean hashHit;
76 
80  private final boolean tagged;
81 
86  private MultiEvent<?> parent = null;
87 
103  public SingleDetailsViewEvent(long eventID, long dataSourceObjId, long fileObjId, Long artifactID, long time, TimelineEventType type, String fullDescription, String medDescription, String shortDescription, boolean hashHit, boolean tagged) {
104  this.eventID = eventID;
105  this.dataSourceObjId = dataSourceObjId;
106  this.fileObjId = fileObjId;
107  this.artifactID = Long.valueOf(0).equals(artifactID) ? null : artifactID;
108  this.time = time;
109  this.type = type;
110  descriptions = ImmutableMap.<TimelineLevelOfDetail, String>of(TimelineLevelOfDetail.HIGH, fullDescription,
111  TimelineLevelOfDetail.MEDIUM, medDescription,
112  TimelineLevelOfDetail.LOW, shortDescription);
113  this.hashHit = hashHit;
114  this.tagged = tagged;
115  }
116 
117  public SingleDetailsViewEvent(TimelineEvent singleEvent) {
118  this(singleEvent.getEventID(),
119  singleEvent.getDataSourceObjID(),
120  singleEvent.getContentObjID(),
121  singleEvent.getArtifactID().orElse(null),
122  singleEvent.getTime(),
123  singleEvent.getEventType(),
124  singleEvent.getDescription(TimelineLevelOfDetail.HIGH),
125  singleEvent.getDescription(TimelineLevelOfDetail.MEDIUM),
126  singleEvent.getDescription(TimelineLevelOfDetail.LOW),
127  singleEvent.eventSourceHasHashHits(),
128  singleEvent.eventSourceIsTagged());
129  }
130 
141  SingleDetailsViewEvent singleEvent = new SingleDetailsViewEvent(eventID, dataSourceObjId, fileObjId, artifactID, time, type, descriptions.get(TimelineLevelOfDetail.HIGH), descriptions.get(TimelineLevelOfDetail.MEDIUM), descriptions.get(TimelineLevelOfDetail.LOW), hashHit, tagged);
142  singleEvent.parent = newParent;
143  return singleEvent;
144  }
145 
151  public boolean isTagged() {
152  return tagged;
153  }
154 
163  public boolean isHashHit() {
164  return hashHit;
165  }
166 
173  public Optional<Long> getArtifactID() {
174  return Optional.ofNullable(artifactID);
175  }
176 
182  public long getEventID() {
183  return eventID;
184  }
185 
192  public long getFileID() {
193  return fileObjId;
194  }
195 
201  public long getTime() {
202  return time;
203  }
204 
205  @Override
206  public TimelineEventType getEventType() {
207  return type;
208  }
209 
215  public String getFullDescription() {
216  return getDescription(TimelineLevelOfDetail.HIGH);
217  }
218 
224  public String getMedDescription() {
225  return getDescription(TimelineLevelOfDetail.MEDIUM);
226  }
227 
233  public String getShortDescription() {
234  return getDescription(TimelineLevelOfDetail.LOW);
235  }
236 
244  public String getDescription(TimelineLevelOfDetail lod) {
245  return descriptions.get(lod);
246  }
247 
253  public long getDataSourceObjID() {
254  return dataSourceObjId;
255  }
256 
257  @Override
258  public Set<Long> getEventIDs() {
259  return Collections.singleton(eventID);
260  }
261 
262  @Override
263  public Set<Long> getEventIDsWithHashHits() {
264  return isHashHit() ? Collections.singleton(eventID) : Collections.emptySet();
265  }
266 
267  @Override
268  public Set<Long> getEventIDsWithTags() {
269  return isTagged() ? Collections.singleton(eventID) : Collections.emptySet();
270  }
271 
272  @Override
273  public long getEndMillis() {
274  return time * 1000;
275  }
276 
277  @Override
278  public long getStartMillis() {
279  return time * 1000;
280  }
281 
282  @Override
283  public int hashCode() {
284  int hash = 7;
285  hash = 13 * hash + (int) (this.eventID ^ (this.eventID >>> 32));
286  return hash;
287  }
288 
289  @Override
290  public boolean equals(Object obj) {
291  if (obj == null) {
292  return false;
293  }
294  if (getClass() != obj.getClass()) {
295  return false;
296  }
298  return this.eventID == other.eventID;
299  }
300 
301  @Override
302  public SortedSet<EventCluster> getClusters() {
303  EventCluster eventCluster = new EventCluster(new Interval(time * 1000, time * 1000), type, getEventIDs(), getEventIDsWithHashHits(), getEventIDsWithTags(), getFullDescription(), TimelineLevelOfDetail.HIGH);
304  return ImmutableSortedSet.orderedBy(Comparator.comparing(EventCluster::getStartMillis)).add(eventCluster).build();
305  }
306 
307  @Override
308  public String getDescription() {
309  return getFullDescription();
310  }
311 
312  @Override
313  public TimelineLevelOfDetail getDescriptionLevel() {
314  return TimelineLevelOfDetail.HIGH;
315  }
316 
325  @Override
326  public Optional<EventStripe> getParentStripe() {
327  if (parent == null) {
328  return Optional.empty();
329  } else if (parent instanceof EventStripe) {
330  return Optional.of((EventStripe) parent);
331  } else {
332  return parent.getParentStripe();
333  }
334  }
335 }
SingleDetailsViewEvent(long eventID, long dataSourceObjId, long fileObjId, Long artifactID, long time, TimelineEventType type, String fullDescription, String medDescription, String shortDescription, boolean hashHit, boolean tagged)

Copyright © 2012-2021 Basis Technology. Generated on: Tue Jan 19 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.