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;
 
   37     "EamArtifactInstances.knownStatus.bad=Bad",
 
   38     "EamArtifactInstances.knownStatus.known=Known",
 
   39     "EamArtifactInstances.knownStatus.unknown=Unknown"})
 
   42     private static final long serialVersionUID = 1L;
 
   57             String correlationValue,
 
   64         this(correlationType, correlationValue, -1, eamCase, eamDataSource, filePath, comment, knownStatus, fileObjectId);
 
   78          this(type, value, -1, eamCase, eamDataSource, filePath, comment, knownStatus, fileObjectId, (long)-1);
 
   92         if (filePath == null) {
 
   96         this.correlationType = type;
 
   99         this.correlationCase = eamCase;
 
  100         this.correlationDataSource = eamDataSource;
 
  102         this.filePath = filePath.toLowerCase();
 
  103         this.comment = comment;
 
  104         this.knownStatus = knownStatus;
 
  105         this.objectId = fileObjectId;
 
  106         this.accountId = accountId;
 
  110         return ((this.getID() == otherInstance.
getID())
 
  115                 && (this.getFilePath().equals(otherInstance.
getFilePath()))
 
  117                 && (this.getComment().equals(otherInstance.
getComment()))
 
  118                 && (this.getAccountId().equals(otherInstance.
getAccountId())));
 
  124                 + this.getCorrelationCase().getCaseUUID()
 
  125                 + this.getCorrelationDataSource().getDeviceID()
 
  126                 + this.getAccountId()
 
  128                 + this.getCorrelationType().toString()
 
  129                 + this.getCorrelationValue()
 
  130                 + this.getKnownStatus()
 
  138         return correlationValue;
 
  145         return correlationType;
 
  169         return correlationCase;
 
  176         return correlationDataSource;
 
  190         return null == comment ? 
"" : comment;
 
  197         this.comment = comment;
 
  218         this.knownStatus = knownStatus;
 
  245     void setAccountId(Long accountId) {
 
  246         this.accountId = accountId;
 
  250     public static final int FILES_TYPE_ID = 0;
 
  251     public static final int DOMAIN_TYPE_ID = 1;
 
  252     public static final int EMAIL_TYPE_ID = 2;
 
  253     public static final int PHONE_TYPE_ID = 3;
 
  254     public static final int USBID_TYPE_ID = 4;
 
  255     public static final int SSID_TYPE_ID = 5;
 
  256     public static final int MAC_TYPE_ID = 6;
 
  257     public static final int IMEI_TYPE_ID = 7;
 
  258     public static final int IMSI_TYPE_ID = 8;
 
  259     public static final int ICCID_TYPE_ID = 9;
 
  260     public static final int INSTALLED_PROGS_TYPE_ID = 10;
 
  261     public static final int OSACCOUNT_TYPE_ID = 11;
 
  264     public static final int ADDITIONAL_TYPES_BASE_ID = 1000;
 
  272     @Messages({
"CorrelationType.FILES.displayName=File MD5",
 
  273         "CorrelationType.DOMAIN.displayName=Domain",
 
  274         "CorrelationType.EMAIL.displayName=Email Address",
 
  275         "CorrelationType.PHONE.displayName=Phone Number",
 
  276         "CorrelationType.USBID.displayName=USB Device",
 
  277         "CorrelationType.SSID.displayName=Wireless Network",
 
  278         "CorrelationType.MAC.displayName=MAC Address",
 
  279         "CorrelationType.IMEI.displayName=IMEI Number",
 
  280         "CorrelationType.IMSI.displayName=IMSI Number",
 
  281         "CorrelationType.PROG_NAME.displayName=Installed Program",
 
  282         "CorrelationType.ICCID.displayName=ICCID Number",
 
  283         "CorrelationType.OS_ACCOUNT.displayName=Os Account"})
 
  292         defaultCorrelationTypes.add(
new CorrelationAttributeInstance.
Type(SSID_TYPE_ID, Bundle.CorrelationType_SSID_displayName(), 
"wireless_networks", 
true, 
true)); 
 
  297         defaultCorrelationTypes.add(
new CorrelationAttributeInstance.
Type(INSTALLED_PROGS_TYPE_ID, Bundle.CorrelationType_PROG_NAME_displayName(), 
"installed_programs", 
true, 
true)); 
 
  298         defaultCorrelationTypes.add(
new CorrelationAttributeInstance.
Type(OSACCOUNT_TYPE_ID, Bundle.CorrelationType_OS_ACCOUNT_displayName(), 
"os_accounts", 
true, 
true)); 
 
  301         int correlationTypeId = ADDITIONAL_TYPES_BASE_ID;
 
  306                 defaultCorrelationTypes.add(
new CorrelationAttributeInstance.
Type(correlationTypeId, type.getDisplayName(), type.getTypeName().toLowerCase() + 
"_acct", 
true, 
true)); 
 
  311         return defaultCorrelationTypes;
 
  317     @SuppressWarnings(
"serial")
 
  318     public static class 
Type implements Serializable { 
 
  325         private final static String DB_NAMES_REGEX = 
"[a-z][a-z0-9_]*";
 
  338         @Messages({
"CorrelationAttributeInstance.nullName.message=Database name is null.",
 
  339             "CorrelationAttributeInstance.invalidName.message=Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'."})
 
  341             if (dbTableName == null) {
 
  342                 throw new CentralRepoException(
"dbTableName is null", Bundle.CorrelationAttributeInstance_nullName_message());
 
  344             this.typeId = typeId;
 
  345             this.displayName = displayName;
 
  346             this.dbTableName = dbTableName;
 
  347             this.supported = supported;
 
  348             this.enabled = enabled;
 
  349             if (!Pattern.matches(DB_NAMES_REGEX, dbTableName)) {
 
  350                 throw new CentralRepoException(
"Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'.", Bundle.CorrelationAttributeInstance_invalidName_message()); 
 
  368             this(-1, displayName, dbTableName, supported, enabled);
 
  398             return this.typeId == that.getId()
 
  399                     && Objects.equals(this.supported, that.isSupported())
 
  400                     && Objects.equals(
this.enabled, that.isEnabled());
 
  406             hash = 67 * hash + Objects.hashCode(this.typeId);
 
  407             hash = 67 * hash + Objects.hashCode(this.supported);
 
  408             hash = 67 * hash + Objects.hashCode(this.enabled);
 
  414             StringBuilder str = 
new StringBuilder(55);
 
  417                     .append(
", displayName=")
 
  418                     .append(getDisplayName())
 
  419                     .append(
", dbTableName=")
 
  420                     .append(getDbTableName())
 
  421                     .append(
", supported=")
 
  422                     .append(isSupported().toString())
 
  423                     .append(
", enabled=")
 
  424                     .append(isEnabled().toString())
 
  426             return str.toString();
 
  440             this.typeId = typeId;
 
  458             this.supported = supported;
 
  476             this.enabled = enabled;
 
  490             this.displayName = displayName;
 
  533             if (!Pattern.matches(DB_NAMES_REGEX, dbTableName)) {
 
  534                 throw new CentralRepoException(
"Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'."); 
 
  536             this.dbTableName = dbTableName;
 
Type(String displayName, String dbTableName, Boolean supported, Boolean enabled)
boolean isDatabaseInstance()
TskData.FileKnown knownStatus
CorrelationAttributeInstance(Type type, String value, int instanceId, CorrelationCase eamCase, CorrelationDataSource eamDataSource, String filePath, String comment, TskData.FileKnown knownStatus, Long fileObjectId, Long accountId)
static List< CorrelationAttributeInstance.Type > getDefaultCorrelationTypes()
CorrelationDataSource correlationDataSource
boolean sameType(CorrelationAttributeInstance.Type that)
String getCorrelationValue()
void setDisplayName(String displayName)
static final Account.Type PHONE
TskData.FileKnown getKnownStatus()
Type getCorrelationType()
Type(int typeId, String displayName, String dbTableName, Boolean supported, Boolean enabled)
static String normalize(CorrelationAttributeInstance.Type attributeType, String data)
void setSupported(Boolean supported)
CorrelationAttributeInstance(CorrelationAttributeInstance.Type correlationType, String correlationValue, CorrelationCase eamCase, CorrelationDataSource eamDataSource, String filePath, String comment, TskData.FileKnown knownStatus, long fileObjectId)
CorrelationAttributeInstance.Type correlationType
CorrelationCase correlationCase
void setKnownStatus(TskData.FileKnown knownStatus)
static final List< Account.Type > PREDEFINED_ACCOUNT_TYPES
boolean equals(Object that)
CorrelationDataSource getCorrelationDataSource()
CorrelationCase getCorrelationCase()
static final Account.Type DEVICE
void setEnabled(Boolean enabled)
void setDbTableName(String dbTableName)
static final Account.Type EMAIL
void setComment(String comment)
Boolean equals(CorrelationAttributeInstance otherInstance)