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;
47 if (attributeType == null) {
54 String trimmedData = data.trim();
56 switch (attributeType.getId()) {
79 final String errorMessage = String.format(
80 "Validator function not found for attribute type: %s",
81 attributeType.getDisplayName());
100 if (typeOption.isPresent()) {
115 final String validMd5Regex =
"^[a-f0-9]{32}$";
116 final String dataLowered = data.toLowerCase();
117 if (dataLowered.matches(validMd5Regex)) {
129 DomainValidator validator = DomainValidator.getInstance(
true);
130 if (validator.isValid(data)) {
131 return data.toLowerCase();
133 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])$";
134 if (data.matches(validIpAddressRegex)) {
147 EmailValidator validator = EmailValidator.getInstance(
true,
true);
148 if (validator.isValid(data)) {
149 return data.toLowerCase();
159 if (data.matches(
"\\+?[0-9()\\-\\s]+")) {
160 String phoneNumber = data.replaceAll(
"[^0-9\\+]",
"");
189 if (data.length() <= 32) {
219 final String validIccidRegex =
"^89[f0-9]{17,22}$";
220 final String iccidWithoutSeperators = data.toLowerCase().replaceAll(SEPERATORS_REGEX,
"");
221 if (iccidWithoutSeperators.matches(validIccidRegex)) {
222 return iccidWithoutSeperators;
246 final String validImsiRegex =
"^[0-9]{14,15}$";
247 final String imsiWithoutSeperators = data.replaceAll(SEPERATORS_REGEX,
"");
248 if (imsiWithoutSeperators.matches(validImsiRegex)) {
249 return imsiWithoutSeperators;
270 final String validMacRegex =
"^([a-f0-9]{12}|[a-f0-9]{16})$";
271 final String macWithoutSeperators = data.toLowerCase().replaceAll(SEPERATORS_REGEX,
"");
272 if (macWithoutSeperators.matches(validMacRegex)) {
273 return macWithoutSeperators;
299 final String validImeiRegex =
"^[0-9]{14,16}$";
300 final String imeiWithoutSeperators = data.replaceAll(SEPERATORS_REGEX,
"");
301 if (imeiWithoutSeperators.matches(validImeiRegex)) {
302 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