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;
53 if (attributeType == null) {
60 String trimmedData = data.trim();
62 switch (attributeType.getId()) {
85 final String errorMessage = String.format(
86 "Validator function not found for attribute type: %s",
87 attributeType.getDisplayName());
106 if (typeOption.isPresent()) {
121 final String validMd5Regex =
"^[a-f0-9]{32}$";
122 final String dataLowered = data.toLowerCase();
123 if (dataLowered.matches(validMd5Regex)) {
135 DomainValidator validator = DomainValidator.getInstance(
true);
136 if (validator.isValid(data)) {
137 return data.toLowerCase();
139 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])$";
140 if (data.matches(validIpAddressRegex)) {
153 EmailValidator validator = EmailValidator.getInstance(
true,
true);
154 if (validator.isValid(data)) {
155 return data.toLowerCase();
165 if (data.matches(
"\\+?[0-9()\\-\\s]+")) {
166 String phoneNumber = data.replaceAll(
"[^0-9\\+]",
"");
195 if (data.length() <= 32) {
225 final String validIccidRegex =
"^89[f0-9]{17,22}$";
226 final String iccidWithoutSeperators = data.toLowerCase().replaceAll(SEPERATORS_REGEX,
"");
227 if (iccidWithoutSeperators.matches(validIccidRegex)) {
228 return iccidWithoutSeperators;
252 final String validImsiRegex =
"^[0-9]{14,15}$";
253 final String imsiWithoutSeperators = data.replaceAll(SEPERATORS_REGEX,
"");
254 if (imsiWithoutSeperators.matches(validImsiRegex)) {
255 return imsiWithoutSeperators;
276 final String validMacRegex =
"^([a-f0-9]{12}|[a-f0-9]{16})$";
277 final String macWithoutSeperators = data.toLowerCase().replaceAll(SEPERATORS_REGEX,
"");
278 if (macWithoutSeperators.matches(validMacRegex)) {
279 return macWithoutSeperators;
305 final String validImeiRegex =
"^[0-9]{14,16}$";
306 final String imeiWithoutSeperators = data.replaceAll(SEPERATORS_REGEX,
"");
307 if (imeiWithoutSeperators.matches(validImeiRegex)) {
308 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