20 package org.sleuthkit.autopsy.centralrepository.datamodel;
22 import java.util.List;
23 import java.util.Optional;
24 import org.apache.commons.validator.routines.DomainValidator;
25 import org.apache.commons.validator.routines.EmailValidator;
49 if (attributeType == null) {
56 String trimmedData = data.trim();
58 switch (attributeType.getId()) {
86 if (defaultCorrelationType.getId() == attributeType.getId()) {
90 final String errorMessage = String.format(
91 "Validator function not found for attribute type: %s",
92 attributeType.getDisplayName());
114 if (typeOption.isPresent()) {
129 final String validMd5Regex =
"^[a-f0-9]{32}$";
130 final String dataLowered = data.toLowerCase();
131 if (dataLowered.matches(validMd5Regex)) {
143 DomainValidator validator = DomainValidator.getInstance(
true);
144 if (validator.isValid(data)) {
145 return data.toLowerCase();
147 final String validIpAddressRegex =
"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";
148 if (data.matches(validIpAddressRegex)) {
161 return CommunicationsUtils.normalizeEmailAddress(data);
163 catch(TskCoreException ex) {
173 return CommunicationsUtils.normalizePhoneNum(data);
175 catch(TskCoreException ex) {
202 if (data.length() <= 32) {
232 final String validIccidRegex =
"^89[f0-9]{17,22}$";
233 final String iccidWithoutSeperators = data.toLowerCase().replaceAll(SEPERATORS_REGEX,
"");
234 if (iccidWithoutSeperators.matches(validIccidRegex)) {
235 return iccidWithoutSeperators;
259 final String validImsiRegex =
"^[0-9]{14,15}$";
260 final String imsiWithoutSeperators = data.replaceAll(SEPERATORS_REGEX,
"");
261 if (imsiWithoutSeperators.matches(validImsiRegex)) {
262 return imsiWithoutSeperators;
283 final String validMacRegex =
"^([a-f0-9]{12}|[a-f0-9]{16})$";
284 final String macWithoutSeperators = data.toLowerCase().replaceAll(SEPERATORS_REGEX,
"");
285 if (macWithoutSeperators.matches(validMacRegex)) {
286 return macWithoutSeperators;
312 final String validImeiRegex =
"^[0-9]{14,16}$";
313 final String imeiWithoutSeperators = data.replaceAll(SEPERATORS_REGEX,
"");
314 if (imeiWithoutSeperators.matches(validImeiRegex)) {
315 return imeiWithoutSeperators;
static final String SEPERATORS_REGEX
static final int EMAIL_TYPE_ID
static final int USBID_TYPE_ID
static String normalizePhone(String data)
static String normalizeImsi(String data)
static String normalizeImei(String data)
static final int ICCID_TYPE_ID
static String normalize(int attributeTypeId, String data)
static List< CorrelationAttributeInstance.Type > getDefaultCorrelationTypes()
static String normalizeMd5(String data)
static final int IMEI_TYPE_ID
static String normalizeMac(String data)
static String normalize(CorrelationAttributeInstance.Type attributeType, String data)
static String normalizeIccid(String data)
static final int DOMAIN_TYPE_ID
static String normalizeDomain(String data)
static final int PHONE_TYPE_ID
static final int MAC_TYPE_ID
static final int IMSI_TYPE_ID
static String verifySsid(String data)
CorrelationAttributeNormalizer()
static String normalizeEmail(String data)
static final int SSID_TYPE_ID
static String normalizeUsbId(String data)
static final int FILES_TYPE_ID