List of usage examples for com.google.common.net InternetDomainName from
public static InternetDomainName from(String domain)
From source file:webindex.core.models.URL.java
public static boolean isValidHost(String host) { return HostSpecifier.isValid(host) && InternetDomainName.isValid(host) && InternetDomainName.from(host).isUnderPublicSuffix(); }
From source file:focusedCrawler.util.LinkRelevance.java
public InternetDomainName getDomainName() { String host = url.getHost();/* w w w . j av a 2 s.c o m*/ InternetDomainName domain = InternetDomainName.from(host); if (host.startsWith("www.")) { return InternetDomainName.from(host.substring(4)); } else { return domain; } }
From source file:org.fineract.module.stellar.federation.StellarAddress.java
private static InternetDomainName getInternetDomainName(final String domain) throws InvalidStellarAddressException { try {/*from w w w . ja v a 2 s. c o m*/ return InternetDomainName.from(domain); } catch (final IllegalArgumentException e) { throw InvalidStellarAddressException.invalidDomainName(domain); } }
From source file:google.registry.tools.GetApplicationIdsCommand.java
@Override public void run() { for (String domainName : mainParameters) { InternetDomainName tld = findTldForNameOrThrow(InternetDomainName.from(domainName)); assertTldExists(tld.toString()); System.out.printf("%s:%n", domainName); // Sample output: // example.tld: // 1 (NewRegistrar) // 2 (OtherRegistrar) // example2.tld: // No applications exist for 'example2.tld'. ImmutableList<DomainApplication> applications = ImmutableList .copyOf(loadActiveApplicationsByDomainName(domainName, DateTime.now(UTC))); if (applications.isEmpty()) { System.out.printf(" No applications exist for \'%s\'.%n", domainName); } else {/* www . j av a 2 s.com*/ for (DomainApplication application : applications) { System.out.printf(" %s (%s)%n", application.getForeignKey(), application.getCurrentSponsorClientId()); } } } }
From source file:google.registry.util.DomainNameUtils.java
/** * Returns the canonicalized TLD part of a valid fully-qualified domain name by stripping off the * leftmost part.//from w w w . j a v a 2s . co m * * <p>This method should not be called for subdomains. * * <p>This function is compatible with multi-part tlds, e.g. {@code co.uk}. This function will * also work on domains for which the registry is not authoritative. If you are certain that the * input will be under a TLD this registry controls, then it is preferable to use * {@link google.registry.model.registry.Registries#findTldForName(InternetDomainName) * Registries#findTldForName}, which will work on hostnames in addition to domains. * * @param fullyQualifiedDomainName must be a punycode SLD (not a host or unicode) * @throws IllegalArgumentException if there is no TLD */ public static String getTldFromDomainName(String fullyQualifiedDomainName) { checkArgument(!Strings.isNullOrEmpty(fullyQualifiedDomainName), "secondLevelDomainName cannot be null or empty"); return getTldFromDomainName(InternetDomainName.from(fullyQualifiedDomainName)); }
From source file:net.orpiske.mdm.broker.processors.tcs.TcsRequestConversor.java
/** * Gets a domain object out of data from the request * @param wrapper the request wrapper//www . j av a2 s.c o m * @return a Domain object */ private Domain getCspFromRequest(LoadServiceWrapper wrapper) { Domain csp = new Domain(); String cspName = wrapper.getCspType().getName(); String domain = wrapper.getCspType().getDomain(); csp.setName(cspName); if (domain == null) { logger.warn("The requester did not inform a domain, defaulting to .csp " + " for further processing"); csp.setDomain(cspName + INVALID_DOMAIN); } else { InternetDomainName d = InternetDomainName.from(domain); if (!d.isPublicSuffix()) { logger.warn("Input domain " + domain + " is not a public suffix"); } csp.setDomain(domain); } return csp; }
From source file:org.fineract.module.stellar.federation.LocalFederationService.java
public boolean handlesDomain(final InternetDomainName domain) { final InternetDomainName federationDomainName; try {/*from w ww. j a v a2 s .c o m*/ federationDomainName = InternetDomainName.from(federationDomain); } catch (final IllegalArgumentException e) { return false; //If we are not configured with a valid domain name, we don't handle this one. } return domain.equals(federationDomainName); }
From source file:com.github.fge.jsonschema.format.helpers.SharedHostNameAttribute.java
@Override public void validate(final ProcessingReport report, final MessageBundle bundle, final FullData data) throws ProcessingException { final String value = data.getInstance().getNode().textValue(); try {/* w ww. j av a2 s . c o m*/ InternetDomainName.from(value); } catch (IllegalArgumentException ignored) { report.error(newMsg(data, bundle, "err.format.invalidHostname").putArgument("value", value)); } }
From source file:org.sindice.core.analytics.commons.util.URIUtil.java
/** * Return the second-level domain name. Returns null if the domain is not valid. * This method normalises domain names by removing the leading www sub-domain, * if present.// w w w . j a v a 2 s . c om * @param domain * @return */ public static String getSndDomain(String domain) { if (domain == null) { return null; } // Remove www subdomain if it exists if (domain.startsWith("www.")) { domain = domain.substring(4); } if (InternetDomainName.isValid(domain)) { // the domain is valid according to the RFC3490 final InternetDomainName idn = InternetDomainName.from(domain); if (idn.hasPublicSuffix()) { // the domain has a public suffix if (idn.isUnderPublicSuffix()) { return idn.topPrivateDomain().name(); } else if (idn.hasParent()) { final List<String> parts = idn.parts(); return parts.get(parts.size() - 2).concat(".").concat(parts.get(parts.size() - 1)); } } } return null; }
From source file:google.registry.model.pricing.StaticPremiumListPricingEngine.java
@Override public DomainPrices getDomainPrices(String fullyQualifiedDomainName, DateTime priceTime) { String tld = getTldFromDomainName(fullyQualifiedDomainName); String label = InternetDomainName.from(fullyQualifiedDomainName).parts().get(0); Registry registry = Registry.get(checkNotNull(tld, "tld")); Optional<Money> premiumPrice = Optional.<Money>absent(); if (registry.getPremiumList() != null) { String listName = registry.getPremiumList().getName(); Optional<PremiumList> premiumList = PremiumList.get(listName); checkState(premiumList.isPresent(), "Could not load premium list: %s", listName); premiumPrice = premiumList.get().getPremiumPrice(label); }// w w w .j a v a 2 s.c om boolean isNameCollisionInSunrise = registry.getTldState(priceTime).equals(SUNRISE) && getReservation(label, tld) == NAME_COLLISION; String feeClass = emptyToNull(Joiner.on('-').skipNulls().join(premiumPrice.isPresent() ? "premium" : null, isNameCollisionInSunrise ? "collision" : null)); return DomainPrices.create(premiumPrice.isPresent(), premiumPrice.or(registry.getStandardCreateCost()), premiumPrice.or(registry.getStandardRenewCost(priceTime)), Optional.<String>fromNullable(feeClass)); }