Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
ExternalResults.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014 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.externalresults;
20 
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.List;
24 
25 import org.openide.util.NbBundle;
26 import org.sleuthkit.datamodel.Content;
27 
31 final public class ExternalResults {
32 
33  private final Content dataSource;
34  private final List<Artifact> artifacts = new ArrayList<>();
35  private final List<Report> reports = new ArrayList<>();
36  private final List<DerivedFile> derivedFiles = new ArrayList<>();
37 
38  ExternalResults(Content dataSource) {
39  this.dataSource = dataSource;
40  }
41 
42  Content getDataSource() {
43  return this.dataSource;
44  }
45 
46  Artifact addArtifact(String type, String sourceFilePath) {
47  if (type.isEmpty()) {
48  throw new IllegalArgumentException(
49  NbBundle.getMessage(this.getClass(), "ExternalResults.addArtifact.exception.msg1.text"));
50  }
51  if (sourceFilePath.isEmpty()) {
52  throw new IllegalArgumentException(
53  NbBundle.getMessage(this.getClass(), "ExternalResults.addArtifact.exception.msg2.text"));
54  }
55  Artifact artifact = new Artifact(type, sourceFilePath);
56  artifacts.add(artifact);
57  return artifact;
58  }
59 
60  List<Artifact> getArtifacts() {
61  return Collections.unmodifiableList(artifacts);
62  }
63 
64  void addReport(String localPath, String sourceModuleName, String reportName) {
65  if (localPath.isEmpty()) {
66  throw new IllegalArgumentException(
67  NbBundle.getMessage(this.getClass(), "ExternalResults.addReport.exception.msg1.text"));
68  }
69  if (sourceModuleName.isEmpty()) {
70  throw new IllegalArgumentException(
71  NbBundle.getMessage(this.getClass(), "ExternalResults.addReport.exception.msg2.text"));
72  }
73  Report report = new Report(localPath, sourceModuleName, reportName);
74  reports.add(report);
75  }
76 
77  List<Report> getReports() {
78  return Collections.unmodifiableList(reports);
79  }
80 
81  void addDerivedFile(String localPath, String parentPath) {
82  if (localPath.isEmpty()) {
83  throw new IllegalArgumentException(
84  NbBundle.getMessage(this.getClass(), "ExternalResults.addDerivedFile.exception.msg1.text"));
85  }
86  if (parentPath.isEmpty()) {
87  throw new IllegalArgumentException(
88  NbBundle.getMessage(this.getClass(), "ExternalResults.addDerivedFile.exception.msg2.text"));
89  }
90  DerivedFile file = new DerivedFile(localPath, parentPath);
91  derivedFiles.add(file);
92  }
93 
94  List<DerivedFile> getDerivedFiles() {
95  return Collections.unmodifiableList(derivedFiles);
96  }
97 
98  static final class Artifact {
99 
100  private final String type;
101  private final String sourceFilePath;
102  private final ArrayList<ArtifactAttribute> attributes = new ArrayList<>();
103 
104  Artifact(String type, String sourceFilePath) {
105  this.type = type;
106  this.sourceFilePath = sourceFilePath;
107  }
108 
109  String getType() {
110  return type;
111  }
112 
113  String getSourceFilePath() {
114  return sourceFilePath;
115  }
116 
117  void addAttribute(String type, String value, String valueType, String sourceModule) {
118  if (type.isEmpty()) {
119  throw new IllegalArgumentException(NbBundle.getMessage(this.getClass(),
120  "ExternalResults.Artifact.addAttribute.exception.msg1.text"));
121  }
122  if (value.isEmpty()) {
123  throw new IllegalArgumentException(NbBundle.getMessage(this.getClass(),
124  "ExternalResults.Artifact.addAttribute.exception.msg2.text"));
125  }
126  if (valueType.isEmpty()) {
127  throw new IllegalArgumentException(NbBundle.getMessage(this.getClass(),
128  "ExternalResults.Artifact.addAttribute.exception.msg3.text"));
129  }
130  attributes.add(new ArtifactAttribute(type, value, valueType, sourceModule));
131  }
132 
133  List<ArtifactAttribute> getAttributes() {
134  return Collections.unmodifiableList(attributes);
135  }
136  }
137 
138  static final class ArtifactAttribute {
139 
140  private final String type;
141  private final String valueType;
142  private final String value;
143  private final String sourceModule;
144 
145  private ArtifactAttribute(String type, String value, String valueType, String sourceModule) {
146  this.type = type;
147  this.value = value;
148  this.valueType = valueType;
149  this.sourceModule = sourceModule;
150  }
151 
152  String getType() {
153  return type;
154  }
155 
156  String getValue() {
157  return value;
158  }
159 
160  String getValueType() {
161  return valueType;
162  }
163 
164  String getSourceModule() {
165  return sourceModule;
166  }
167  }
168 
169  static final class Report {
170 
171  private final String localPath;
172  private final String sourceModuleName;
173  private final String reportName;
174 
175  Report(String localPath, String sourceModuleName, String displayName) {
176  this.localPath = localPath;
177  this.sourceModuleName = sourceModuleName;
178  this.reportName = displayName;
179  }
180 
181  String getLocalPath() {
182  return localPath;
183  }
184 
185  String getSourceModuleName() {
186  return sourceModuleName;
187  }
188 
189  String getReportName() {
190  return reportName;
191  }
192  }
193 
194  static final class DerivedFile {
195 
196  private final String localPath;
197  private final String parentPath;
198 
199  DerivedFile(String localPath, String parentPath) {
200  this.localPath = localPath;
201  this.parentPath = parentPath;
202  }
203 
204  String getLocalPath() {
205  return localPath;
206  }
207 
208  String getParentPath() {
209  return parentPath;
210  }
211  }
212 }

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