List of usage examples for com.google.common.net InternetDomainName from
public static InternetDomainName from(String domain)
From source file:io.fluo.webindex.ui.util.WebUrl.java
public static String domainFromHost(String host) { return InternetDomainName.from(host).topPrivateDomain().toString(); }
From source file:com.codeabovelab.dm.cluman.ds.nodes.NodeUtils.java
/** * Node name must be valid host name. In this method we check it. * @param name//from w w w.ja va 2 s. co m */ public static void checkName(String name) { InternetDomainName.from(name); }
From source file:org.fineract.module.stellar.federation.StellarAddress.java
public static StellarAddress forTenant(final String tenantName, final String domain) { return new StellarAddress(InternetDomainName.from(domain), tenantName, Optional.empty()); }
From source file:edu.uga.cs.fluxbuster.utils.DomainNameUtils.java
/** * Extracts the effective second level domain name. * * @param domainname the full domain name * @return the second level domain name or null on error *//*ww w. j av a 2 s.c o m*/ public static String extractEffective2LD(String domainname) { String retval = null; try { InternetDomainName idn = InternetDomainName.from(domainname); InternetDomainName sld = idn.topPrivateDomain(); retval = sld.name(); } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Unable to extract 2LD.", e); } } return retval; }
From source file:org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdIdDomainName.java
public static MdId asMdId(String mdName) { if (mdName == null || !InternetDomainName.isValid(mdName)) { throw new IllegalArgumentException( "MD Name must follow internet domain name pattern " + " Rejecting: " + mdName); }// w w w . j a va2s . co m return asMdId(InternetDomainName.from(mdName)); }
From source file:io.fluo.commoncrawl.data.util.LinkUtil.java
public static URL createURL(String url) throws ParseException { String cleanUrl = DataUtil.cleanUrl(url); try {/*from w w w.j a va2 s. co m*/ URL u = new URL(cleanUrl); if (!u.getProtocol().equalsIgnoreCase("http") && !u.getProtocol().equalsIgnoreCase("https")) { throw new ParseException("Bad protocol: " + u.toString(), 0); } if (u.getUserInfo() != null) { throw new ParseException("No user info: " + u.toString(), 0); } if (!HostSpecifier.isValid(u.getHost())) { throw new ParseException("Invalid host: " + u.getHost(), 0); } if (InternetDomainName.isValid(u.getHost())) { if (!InternetDomainName.from(u.getHost()).isUnderPublicSuffix()) { throw new ParseException("Bad domain: " + u.getHost(), 0); } } String uri = DataUtil.toUri(cleanUrl); String reformUrl = DataUtil.toUrl(uri); if (!reformUrl.equals(cleanUrl)) { String msg = String.format("Url %s creates url %s when reformed from uri %s", cleanUrl, reformUrl, uri); log.info(msg); throw new ParseException(msg, 0); } return u; } catch (MalformedURLException e) { throw new ParseException(e.getMessage(), 0); } }
From source file:com.evidon.areweprivateyet.AnalysisUtils.java
public static String getGuavaDomain(String url) throws Exception { if (url.indexOf("#") > 0) { url = url.substring(0, url.indexOf("#")); }//from w w w. j a v a 2 s.c om if (url.indexOf("?") > 0) { url = url.substring(0, url.indexOf("?")); } if (url.indexOf(";") > 0) { url = url.substring(0, url.indexOf(";")); } if (url.indexOf("|") > 0) { url = url.substring(0, url.indexOf("|")); } if (url.indexOf("_") > 0) { url = url.replaceAll("_", ""); } if (url.indexOf("%") > 0) { url = url.replaceAll("%", ""); } // strip port if (url.indexOf(":8080") > 0) { url = url.replaceAll(":8080", ""); } String host = new URI(url).getHost(); try { InternetDomainName domainName = InternetDomainName.from(host); return domainName.topPrivateDomain().name(); } catch (java.lang.IllegalStateException e) { return AnalysisUtils.getBaseDomain(url); } catch (java.lang.IllegalArgumentException e) { if (url.startsWith("https://")) { url = url.substring(7); } if (url.startsWith("http://")) { url = url.substring(7); } if (url.indexOf("/") > 0) { url = url.substring(0, url.indexOf("/")); } if (url.matches("^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$")) { return url; } else { throw new Exception(); } } }
From source file:org.everit.json.schema.internal.HostnameFormatValidator.java
@Override public Optional<String> validate(final String subject) { try {/* ww w .j av a 2 s.c o m*/ InternetDomainName.from(subject); return Optional.empty(); } catch (IllegalArgumentException | NullPointerException e) { return Optional.of(String.format("[%s] is not a valid hostname", subject)); } }
From source file:google.registry.tools.params.InternetDomainNameParameter.java
@Override public InternetDomainName convert(String value) { return InternetDomainName.from(value); }
From source file:com.francetelecom.clara.cloud.techmodel.cf.RouteUri.java
public String getDomain() { return InternetDomainName.from(value).parent().name(); }