Autopsy  4.16.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DomainSearchArtifactsLoader.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2020 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.discovery.search;
20 
21 import com.google.common.cache.CacheLoader;
22 import java.util.List;
23 import java.util.ArrayList;
24 import org.sleuthkit.datamodel.BlackboardAttribute;
25 import org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
26 import org.sleuthkit.datamodel.BlackboardAttribute.Type;
27 import org.sleuthkit.datamodel.TskCoreException;
28 import org.sleuthkit.datamodel.SleuthkitCase;
29 import org.sleuthkit.datamodel.BlackboardArtifact;
30 
36 public class DomainSearchArtifactsLoader extends CacheLoader<DomainSearchArtifactsRequest, List<BlackboardArtifact>> {
37 
38  private static final Type TSK_DOMAIN = new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_DOMAIN);
39  private static final Type TSK_URL = new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_URL);
40 
41  @Override
42  public List<BlackboardArtifact> load(DomainSearchArtifactsRequest artifactsRequest) throws TskCoreException {
43  final SleuthkitCase caseDb = artifactsRequest.getSleuthkitCase();
44  final String normalizedDomain = artifactsRequest.getDomain().toLowerCase();
45  final List<BlackboardArtifact> artifacts = caseDb.getBlackboardArtifacts(artifactsRequest.getArtifactType());
46  final List<BlackboardArtifact> matchingDomainArtifacts = new ArrayList<>();
47 
48  for (BlackboardArtifact artifact : artifacts) {
49  final BlackboardAttribute tskDomain = artifact.getAttribute(TSK_DOMAIN);
50  final BlackboardAttribute tskUrl = artifact.getAttribute(TSK_URL);
51 
52  if (tskDomain != null && tskDomain.getValueString().equalsIgnoreCase(normalizedDomain)) {
53  matchingDomainArtifacts.add(artifact);
54  } else if (tskUrl != null && tskUrl.getValueString().toLowerCase().contains(normalizedDomain)) {
55  matchingDomainArtifacts.add(artifact);
56  }
57  }
58 
59  return matchingDomainArtifacts;
60  }
61 }
Type(int value, String displayName, Collection< String > mediaTypes, Collection< BlackboardArtifact.ARTIFACT_TYPE > artifactTypes)
List< BlackboardArtifact > load(DomainSearchArtifactsRequest artifactsRequest)

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