Go to the documentation of this file.
19package org.sleuthkit.autopsy.coreutils;
21import java.io.IOException;
22import java.net.MalformedURLException;
24import java.net.UnknownHostException;
25import java.util.logging.Level;
26import org.apache.commons.lang.StringUtils;
27import org.apache.commons.validator.routines.DomainValidator;
28import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException;
47 hostName = java.net.InetAddress.getLocalHost().getHostName();
48 }
catch (UnknownHostException ex) {
51 hostName = System.getenv(
"COMPUTERNAME");
53 if (hostName ==
null || hostName.isEmpty()) {
54 hostName = System.getenv(
"COMPUTERNAME");
69 String cleanUrl = url.replaceFirst(
".*:\\/\\/",
"");
72 String dirToks[] = cleanUrl.split(
"\\/");
73 if (dirToks.length > 0) {
81 base = DomainTokenizer.getInstance().getDomain(host);
82 }
catch (IOException ex) {
83 logger.log(Level.WARNING,
"Unable to load resources for domain categorization.", ex);
87 if (base.matches(
".*[~`!@#$%^&\\*\\(\\)\\+={}\\[\\];:\\?<>,/ ].*")) {
92 if (!base.contains(
".")) {
107 if (urlString ==
null) {
110 String urlHost =
null;
113 URL url =
new URL(urlString);
114 urlHost = url.getHost();
115 }
catch (MalformedURLException ex) {
119 String result = (StringUtils.isNotBlank(urlHost))
125 DomainValidator validator = DomainValidator.getInstance(
true);
126 if (validator.isValid(result)) {
129 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])$";
130 if (result.matches(validIpAddressRegex)) {
synchronized static Logger getLogger(String name)
static final Logger logger
static String getLocalHostName()
static String extractDomain(String urlString)
static String getBaseDomain(String url)
Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 United States License.