19 package org.sleuthkit.autopsy.coreutils;
21 import java.io.IOException;
22 import java.net.MalformedURLException;
24 import java.net.UnknownHostException;
25 import java.util.logging.Level;
26 import org.apache.commons.lang.StringUtils;
27 import org.apache.commons.validator.routines.DomainValidator;
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)) {
static String extractDomain(String urlString)
static final Logger logger
static String getBaseDomain(String url)
static String getLocalHostName()
synchronized static Logger getLogger(String name)