19 package org.sleuthkit.autopsy.centralrepository.datamodel;
21 import java.io.Serializable;
22 import java.util.ArrayList;
23 import java.util.List;
24 import java.util.Objects;
25 import java.util.regex.Pattern;
26 import org.openide.util.NbBundle.Messages;
36 "EamArtifactInstances.knownStatus.bad=Bad",
37 "EamArtifactInstances.knownStatus.known=Known",
38 "EamArtifactInstances.knownStatus.unknown=Unknown"})
41 private static final long serialVersionUID = 1L;
53 String correlationValue,
59 this(correlationType, correlationValue, -1, eamCase, eamDataSource, filePath, null, TskData.FileKnown.UNKNOWN);
63 String correlationValue,
69 TskData.FileKnown knownStatus
71 this(correlationType, correlationValue, -1, eamCase, eamDataSource, filePath, comment, knownStatus);
76 String correlationValue,
80 this(correlationType, correlationValue, -1, correlationCase, fromTSKDataSource, string,
"", TskData.FileKnown.UNKNOWN);
90 this(aType, value, -1, null, null,
"",
"", TskData.FileKnown.UNKNOWN);
101 TskData.FileKnown knownStatus
103 if (filePath == null) {
104 throw new EamDbException(
"file path is null");
107 this.correlationType = type;
108 this.correlationValue = CorrelationAttributeNormalizer.normalize(type, value);
109 this.ID = instanceId;
110 this.correlationCase = eamCase;
111 this.correlationDataSource = eamDataSource;
113 this.filePath = filePath.toLowerCase();
114 this.comment = comment;
115 this.knownStatus = knownStatus;
119 return ((this.getID() == otherInstance.
getID())
124 && (this.getFilePath().equals(otherInstance.
getFilePath()))
126 && (this.getComment().equals(otherInstance.
getComment())));
132 + this.getCorrelationCase().getCaseUUID()
133 + this.getCorrelationDataSource().getDeviceID()
135 + this.getCorrelationType().toString()
136 + this.getCorrelationValue()
137 + this.getKnownStatus()
145 return correlationValue;
153 this.correlationValue = correlationValue.toLowerCase();
160 return correlationType;
167 this.correlationType = correlationType;
191 return correlationCase;
198 return correlationDataSource;
212 return null == comment ?
"" : comment;
219 this.comment = comment;
240 this.knownStatus = knownStatus;
244 public static final int FILES_TYPE_ID = 0;
245 public static final int DOMAIN_TYPE_ID = 1;
246 public static final int EMAIL_TYPE_ID = 2;
247 public static final int PHONE_TYPE_ID = 3;
248 public static final int USBID_TYPE_ID = 4;
256 @Messages({
"CorrelationType.FILES.displayName=Files",
257 "CorrelationType.DOMAIN.displayName=Domains",
258 "CorrelationType.EMAIL.displayName=Email Addresses",
259 "CorrelationType.PHONE.displayName=Phone Numbers",
260 "CorrelationType.USBID.displayName=USB Devices"})
265 DEFAULT_CORRELATION_TYPES.add(
new CorrelationAttributeInstance.
Type(EMAIL_TYPE_ID, Bundle.CorrelationType_EMAIL_displayName(),
"email_address",
true,
true));
266 DEFAULT_CORRELATION_TYPES.add(
new CorrelationAttributeInstance.
Type(PHONE_TYPE_ID, Bundle.CorrelationType_PHONE_displayName(),
"phone_number",
true,
true));
268 return DEFAULT_CORRELATION_TYPES;
274 @SuppressWarnings(
"serial")
275 public static class
Type implements Serializable {
282 private final static String DB_NAMES_REGEX =
"[a-z][a-z0-9_]*";
294 public Type(
int typeId, String displayName, String dbTableName, Boolean supported, Boolean enabled)
throws EamDbException {
295 if (dbTableName == null) {
296 throw new EamDbException(
"dbTableName is null");
298 this.typeId = typeId;
299 this.displayName = displayName;
300 this.dbTableName = dbTableName;
301 this.supported = supported;
302 this.enabled = enabled;
303 if (!Pattern.matches(DB_NAMES_REGEX, dbTableName)) {
304 throw new EamDbException(
"Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'.");
320 public Type(String displayName, String dbTableName, Boolean supported, Boolean enabled)
throws EamDbException {
321 this(-1, displayName, dbTableName, supported, enabled);
351 return this.typeId == that.getId()
352 && Objects.equals(this.supported, that.isSupported())
353 && Objects.equals(
this.enabled, that.isEnabled());
359 hash = 67 * hash + Objects.hashCode(this.typeId);
360 hash = 67 * hash + Objects.hashCode(this.supported);
361 hash = 67 * hash + Objects.hashCode(this.enabled);
367 StringBuilder str =
new StringBuilder(55);
370 .append(
", displayName=")
371 .append(getDisplayName())
372 .append(
", dbTableName=")
373 .append(getDbTableName())
374 .append(
", supported=")
375 .append(isSupported().toString())
376 .append(
", enabled=")
377 .append(isEnabled().toString())
379 return str.toString();
393 this.typeId = typeId;
411 this.supported = supported;
429 this.enabled = enabled;
443 this.displayName = displayName;
486 if (!Pattern.matches(DB_NAMES_REGEX, dbTableName)) {
487 throw new EamDbException(
"Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'.");
489 this.dbTableName = dbTableName;
void setCorrelationType(Type correlationType)
Type(String displayName, String dbTableName, Boolean supported, Boolean enabled)
boolean isDatabaseInstance()
TskData.FileKnown knownStatus
CorrelationAttributeInstance(Type correlationType, String correlationValue, CorrelationCase correlationCase, CorrelationDataSource fromTSKDataSource, String string)
CorrelationAttributeInstance(String correlationValue, CorrelationAttributeInstance.Type correlationType, CorrelationCase eamCase, CorrelationDataSource eamDataSource, String filePath, String comment, TskData.FileKnown knownStatus)
static List< CorrelationAttributeInstance.Type > getDefaultCorrelationTypes()
CorrelationDataSource correlationDataSource
boolean sameType(CorrelationAttributeInstance.Type that)
String getCorrelationValue()
void setDisplayName(String displayName)
CorrelationAttributeInstance(String correlationValue, CorrelationAttributeInstance.Type correlationType, CorrelationCase eamCase, CorrelationDataSource eamDataSource, String filePath)
TskData.FileKnown getKnownStatus()
Type getCorrelationType()
Type(int typeId, String displayName, String dbTableName, Boolean supported, Boolean enabled)
void setSupported(Boolean supported)
CorrelationAttributeInstance.Type correlationType
CorrelationCase correlationCase
void setKnownStatus(TskData.FileKnown knownStatus)
CorrelationAttributeInstance(Type aType, String value)
boolean equals(Object that)
CorrelationDataSource getCorrelationDataSource()
void setCorrelationValue(String correlationValue)
CorrelationCase getCorrelationCase()
void setEnabled(Boolean enabled)
void setDbTableName(String dbTableName)
void setComment(String comment)
Boolean equals(CorrelationAttributeInstance otherInstance)