List of usage examples for com.google.common.net InternetDomainName from
public static InternetDomainName from(String domain)
From source file:google.registry.whois.NameserverLookupByIpCommand.java
@Override public WhoisResponse executeQuery(DateTime now) throws WhoisException { ImmutableList<HostResource> hosts = FluentIterable .from(queryNotDeleted(HostResource.class, now, "inetAddresses", ipAddress)) .filter(new Predicate<HostResource>() { @Override/*www . ja va 2s . c o m*/ public boolean apply(final HostResource host) { return Registries.findTldForName(InternetDomainName.from(host.getFullyQualifiedHostName())) .isPresent(); } }).toList(); if (hosts.isEmpty()) { throw new WhoisException(now, SC_NOT_FOUND, "No nameservers found."); } return new NameserverWhoisResponse(hosts, now); }
From source file:io.fluo.commoncrawl.data.util.LinkUtil.java
public static String getTopPrivate(String url) throws ParseException { if (hasIP(url)) { return getHost(url); }//from ww w. java2 s . c om return InternetDomainName.from(getHost(url)).topPrivateDomain().name(); }
From source file:org.eel.kitchen.jsonschema.format.HostnameFormatAttribute.java
@Override public void checkValue(final String fmt, final ValidationContext ctx, final ValidationReport report, final JsonNode value) { final Message.Builder msg = newMsg(fmt).setMessage("string is not a valid hostname").addInfo("value", value);//from w w w . j ava 2 s. c o m final InternetDomainName hostname; try { hostname = InternetDomainName.from(value.textValue()); } catch (IllegalArgumentException ignored) { report.addMessage(msg.build()); return; } if (ctx.hasFeature(ValidationFeature.STRICT_RFC_CONFORMANCE)) return; if (!hostname.hasParent()) report.addMessage(msg.build()); }
From source file:org.eel.kitchen.jsonschema.format.HostnameFormatSpecifier.java
@Override public void checkValue(final String fmt, final ValidationContext ctx, final ValidationReport report, final JsonNode value) { final ValidationMessage.Builder msg = newMsg(fmt).setMessage("string is not a valid hostname") .addInfo("value", value); final InternetDomainName hostname; try {//from w w w. j ava2 s . c o m hostname = InternetDomainName.from(value.textValue()); } catch (IllegalArgumentException ignored) { report.addMessage(msg.build()); return; } if (ctx.hasFeature(ValidationFeature.STRICT_RFC_CONFORMANCE)) return; if (!hostname.hasParent()) report.addMessage(msg.build()); }
From source file:com.francetelecom.clara.cloud.paas.projection.cf.RouteStrategyImpl.java
public void setRouteNameSuffix(String routeNameSuffix) { InternetDomainName.from(routeNameSuffix); //Throws IllegalArgumentException is suffix is invalid int maxSuffixLength = 253 - 63 - 1; //reserve 63 chars for the subdomains if (routeNameSuffix.length() > maxSuffixLength) { throw new IllegalArgumentException( "Too large configured route suffix, need to be smaller than " + maxSuffixLength + " currently: " + routeNameSuffix.length() + " suffix is:" + routeNameSuffix); }//from w w w . j ava2 s. c om this.routeNameSuffix = routeNameSuffix; }
From source file:google.registry.tools.EppToolCommand.java
/** * Helper function for grouping sets of domain names into respective TLDs. Useful for batched * EPP calls when invoking commands (i.e. domain check) with sets of domains across multiple TLDs. *///from ww w . ja va 2s . c o m protected static Multimap<String, String> validateAndGroupDomainNamesByTld(List<String> names) { ImmutableMultimap.Builder<String, String> builder = new ImmutableMultimap.Builder<>(); for (String name : names) { InternetDomainName tld = findTldForNameOrThrow(InternetDomainName.from(name)); builder.put(tld.toString(), name); } return builder.build(); }
From source file:uk.bl.wa.extract.LinkExtractor.java
public static String extractPublicSuffixFromHost(String host) { if (host == null) return null; // Parse out the public suffix: InternetDomainName domainName;// w ww . j a v a 2s . c om try { domainName = InternetDomainName.from(host); } catch (Exception e) { return null; } InternetDomainName suffix = null; if (host.endsWith(".uk")) { ImmutableList<String> parts = domainName.parts(); if (parts.size() >= 2) { suffix = InternetDomainName.from(parts.get(parts.size() - 2) + "." + parts.get(parts.size() - 1)); } } else { suffix = domainName.publicSuffix(); } // Return a value: if (suffix == null) return null; return suffix.toString(); }
From source file:google.registry.tools.AuctionStatusCommand.java
@Override public void run() throws Exception { final ImmutableSet<String> domains = ImmutableSet.copyOf(mainArguments); Files.write(output,/*from ww w.j av a 2s . co m*/ FluentIterable.from(domains).transformAndConcat(new Function<String, Iterable<String>>() { @Override public Iterable<String> apply(String fullyQualifiedDomainName) { checkState(findTldForName(InternetDomainName.from(fullyQualifiedDomainName)).isPresent(), "No tld found for %s", fullyQualifiedDomainName); return ofy().transactNewReadOnly(new Work<Iterable<String>>() { @Override public Iterable<String> run() { ImmutableList.Builder<DomainApplication> applications = new ImmutableList.Builder<>(); for (String domain : domains) { applications.addAll( loadActiveApplicationsByDomainName(domain, ofy().getTransactionTime())); } return Lists.transform( FluentIterable.from(applications.build()).toSortedList(ORDERING), APPLICATION_FORMATTER); } }); } }), UTF_8); }
From source file:google.registry.tools.CreateAnchorTenantCommand.java
@Override protected void initMutatingEppToolCommand() { checkArgument(superuser, "This command must be run as a superuser."); findTldForNameOrThrow(InternetDomainName.from(domainName)); // Check that the tld exists. if (isNullOrEmpty(password)) { password = createToken(ANCHOR_TENANT, passwordGenerator); }//ww w . j a va2 s . c o m Money cost = null; if (fee) { cost = getDomainCreateCost(domainName, DateTime.now(UTC), DEFAULT_ANCHOR_TENANT_PERIOD_YEARS); } setSoyTemplate(CreateAnchorTenantSoyInfo.getInstance(), CreateAnchorTenantSoyInfo.CREATEANCHORTENANT); addSoyRecord(clientId, new SoyMapData("domainName", domainName, "contactId", contact, "reason", reason, "password", password, "period", DEFAULT_ANCHOR_TENANT_PERIOD_YEARS, "feeCurrency", cost != null ? cost.getCurrencyUnit().toString() : null, "fee", cost != null ? cost.getAmount().toString() : null)); }
From source file:org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions.java
/** * will replace the default domain used when ordering virtual guests. Note * this needs to contain a public suffix! * //from w ww. j a v a 2s. c o m * @see VirtualGuestClient#orderVirtualGuest * @see InternetDomainName#hasPublicSuffix */ public TemplateOptions domainName(String domainName) { checkNotNull(domainName, "domainName was null"); checkArgument(InternetDomainName.from(domainName).hasPublicSuffix(), "domainName %s has no public suffix", domainName); this.domainName = domainName; return this; }