List of usage examples for com.google.common.net InternetDomainName toString
@Override
public String toString()
From source file:google.registry.flows.domain.DomainCheckFlow.java
private String getMessageForCheck(InternetDomainName domainName, Set<String> existingIds, DateTime now) { if (existingIds.contains(domainName.toString())) { return "In use"; }/*from w w w. j a va 2 s. c om*/ Registry registry = Registry.get(domainName.parent().toString()); if (PENDING_ALLOCATION_TLD_STATES.contains(registry.getTldState(now)) && FluentIterable.from(loadActiveApplicationsByDomainName(domainName.toString(), now)) .anyMatch(new Predicate<DomainApplication>() { @Override public boolean apply(DomainApplication input) { return !input.getApplicationStatus().isFinalStatus(); } })) { return "Pending allocation"; } ReservationType reservationType = getReservationType(domainName); if (reservationType == UNRESERVED && isDomainPremium(domainName.toString(), now) && registry.getPremiumPriceAckRequired() && eppInput.getSingleExtension(FeeCheckCommandExtension.class) == null) { return "Premium names require EPP ext."; } return reservationType.getMessageForCheck(); }
From source file:google.registry.flows.domain.DomainFlowUtils.java
static void verifyNotReserved(InternetDomainName domainName, boolean isSunrise) throws EppException { if (isReserved(domainName, isSunrise)) { throw new DomainReservedException(domainName.toString()); }//ww w .ja va2s.c o m }
From source file:focusedCrawler.util.LinkRelevance.java
public String getTopLevelDomainName() { InternetDomainName domain = this.getDomainName(); try {/*from w w w. j a v a 2 s . co m*/ if (domain.isUnderPublicSuffix()) { return domain.topPrivateDomain().toString(); } else { // if the domain is a public suffix, just use it as top level domain return domain.toString(); } } catch (Exception e) { throw new IllegalStateException("Invalid top private domain name=[" + domain + "] in URL=[" + url + "]", e); } }
From source file:org.archive.modules.fetcher.BdbCookieStore.java
/** * Returns a {@link LimitedCookieStoreFacade} whose * {@link LimitedCookieStoreFacade#getCookies()} method returns only cookies * from {@code host} and its parent domains, if applicable. *//* w w w . j a v a 2 s. co m*/ public CookieStore cookieStoreFor(String host) { CompositeCollection cookieCollection = new CompositeCollection(); if (InternetDomainName.isValid(host)) { InternetDomainName domain = InternetDomainName.from(host); while (domain != null) { Collection<Cookie> subset = hostSubset(domain.toString()); cookieCollection.addComposited(subset); if (domain.hasParent()) { domain = domain.parent(); } else { domain = null; } } } else { Collection<Cookie> subset = hostSubset(host.toString()); cookieCollection.addComposited(subset); } @SuppressWarnings("unchecked") List<Cookie> cookieList = new RestrictedCollectionWrappedList<Cookie>(cookieCollection); LimitedCookieStoreFacade store = new LimitedCookieStoreFacade(cookieList); return store; }
From source file:google.registry.flows.domain.DomainFlowUtils.java
/** * Check that if there's a claims notice it's on the claims list, and that if there's not one it's * not on the claims list and is a sunrise application. */// www.j av a 2 s.co m static void verifyClaimsNoticeIfAndOnlyIfNeeded(InternetDomainName domainName, boolean hasSignedMarks, boolean hasClaimsNotice) throws EppException { boolean isInClaimsList = ClaimsListShard.get().getClaimKey(domainName.parts().get(0)) != null; if (hasClaimsNotice && !isInClaimsList) { throw new UnexpectedClaimsNoticeException(domainName.toString()); } if (!hasClaimsNotice && isInClaimsList && !hasSignedMarks) { throw new MissingClaimsNoticeException(domainName.toString()); } }
From source file:com.addthis.hydra.data.filter.bundle.BundleFilterURL.java
@Override public boolean filter(Bundle bundle) { String pv = ValueUtil.asNativeString(field.getValue(bundle)); if (!asFile) { if (pv == null || pv.length() < 7) { return invalidExit; }//ww w.j a v a 2s. c o m String lpv = pv.trim().toLowerCase(); if (!(lpv.startsWith("http"))) { if (fixProto) { if (clean && lpv.indexOf("%2f") >= 0) { pv = LessBytes.urldecode(pv); } pv = "http://".concat(pv); } else { return invalidExit; } } if (clean && (lpv.startsWith("http%") || lpv.startsWith("https%"))) { pv = LessBytes.urldecode(pv); } } // up to two 'decoding' passes on the url to try and find a valid one for (int i = 0; i < 2; i++) { if (pv == null) { return invalidExit; } try { URL urec = asFile ? new URL("file://".concat(pv)) : new URL(pv); String urlhost = urec.getHost(); String returnhost = null; if (resolveIP) { synchronized (iphost) { returnhost = iphost.get(urlhost).toLowerCase(); if (returnhost == null) { returnhost = resolveDottedIP(urlhost); iphost.put(urlhost, returnhost); if (iphost.size() > maxhostcache) { iphost.removeEldest(); } } } } else { returnhost = urlhost.toLowerCase(); } // store cleaned up (url decoded) version back to packet if (clean) { if (urec != null && urec.getPath().isEmpty()) { // if the path element is null, append the slash pv = pv.concat("/"); } field.setValue(bundle, ValueFactory.create(pv)); } if (setHost != null) { if (toBaseDomain) { returnhost = NetUtil.getBaseDomain(returnhost); } else if (toTopPrivateDomain) { if (returnhost != null && InternetDomainName.isValid(returnhost)) { InternetDomainName domain = InternetDomainName.from(returnhost); if (domain.hasPublicSuffix() && domain.isUnderPublicSuffix()) { InternetDomainName topPrivateDomain = domain.topPrivateDomain(); returnhost = topPrivateDomain.toString(); } } } setHost.setValue(bundle, ValueFactory.create(returnhost)); } if (setPath != null) { setPath.setValue(bundle, ValueFactory.create(urec.getPath())); } if (setParams != null) { setParams.setValue(bundle, ValueFactory.create(urec.getQuery())); } if (setAnchor != null) { setAnchor.setValue(bundle, ValueFactory.create(urec.getRef())); } if (setHostNormal != null) { Matcher m = hostNormalPattern.matcher(returnhost); if (m.find()) { returnhost = m.group(1); } setHostNormal.setValue(bundle, ValueFactory.create(returnhost)); } if (setTopPrivateDomain != null) { String topDomain = returnhost; if (InternetDomainName.isValid(returnhost)) { InternetDomainName domainName = InternetDomainName.from(returnhost); if (domainName.isTopPrivateDomain() || domainName.isUnderPublicSuffix()) { topDomain = DOT_JOINER.join(domainName.topPrivateDomain().parts()); } } setTopPrivateDomain.setValue(bundle, ValueFactory.create(topDomain)); } } catch (MalformedURLException e) { if (pv.indexOf("%3") > 0 && pv.indexOf("%2") > 0) { pv = LessBytes.urldecode(pv); } else { if (debugMalformed) { System.err.println("malformed(" + i + ") " + pv); } return invalidExit; } } } return true; }
From source file:google.registry.flows.domain.DomainFlowUtils.java
/** * Validates a {@link FeeQueryCommandExtensionItem} and sets the appropriate fields on a {@link * FeeQueryResponseExtensionItem} builder. *//*from w w w . j a v a2s. c o m*/ static void handleFeeRequest(FeeQueryCommandExtensionItem feeRequest, FeeQueryResponseExtensionItem.Builder<?, ?> builder, InternetDomainName domain, @Nullable CurrencyUnit topLevelCurrency, DateTime currentDate, DomainPricingLogic pricingLogic) throws EppException { DateTime now = currentDate; // Use the custom effective date specified in the fee check request, if there is one. if (feeRequest.getEffectiveDate().isPresent()) { now = feeRequest.getEffectiveDate().get(); builder.setEffectiveDateIfSupported(now); } String domainNameString = domain.toString(); Registry registry = Registry.get(domain.parent().toString()); int years = verifyUnitIsYears(feeRequest.getPeriod()).getValue(); boolean isSunrise = registry.getTldState(now).equals(TldState.SUNRISE); if (feeRequest.getPhase() != null || feeRequest.getSubphase() != null) { throw new FeeChecksDontSupportPhasesException(); } CurrencyUnit currency = feeRequest.getCurrency() != null ? feeRequest.getCurrency() : topLevelCurrency; if ((currency != null) && !currency.equals(registry.getCurrency())) { throw new CurrencyUnitMismatchException(); } builder.setCommand(feeRequest.getCommandName(), feeRequest.getPhase(), feeRequest.getSubphase()) .setCurrencyIfSupported(registry.getCurrency()).setPeriod(feeRequest.getPeriod()) .setClass(pricingLogic.getFeeClass(domainNameString, now).orNull()); ImmutableList<Fee> fees = ImmutableList.of(); switch (feeRequest.getCommandName()) { case CREATE: if (isReserved(domain, isSunrise)) { // Don't return a create price for reserved names. builder.setClass("reserved"); // Override whatever class we've set above. builder.setAvailIfSupported(false); builder.setReasonIfSupported("reserved"); } else { builder.setAvailIfSupported(true); fees = pricingLogic.getCreatePrice(registry, domainNameString, now, years).getFees(); } break; case RENEW: builder.setAvailIfSupported(true); fees = pricingLogic.getRenewPrice(registry, domainNameString, now, years).getFees(); break; case RESTORE: if (years != 1) { throw new RestoresAreAlwaysForOneYearException(); } builder.setAvailIfSupported(true); fees = pricingLogic.getRestorePrice(registry, domainNameString, now).getFees(); break; case TRANSFER: builder.setAvailIfSupported(true); fees = pricingLogic.getTransferPrice(registry, domainNameString, now, years).getFees(); break; case UPDATE: builder.setAvailIfSupported(true); fees = pricingLogic.getUpdatePrice(registry, domainNameString, now).getFees(); break; default: throw new UnknownFeeCommandException(feeRequest.getUnparsedCommandName()); } // Set the fees, and based on the validDateRange of the fees, set the notAfterDate. if (!fees.isEmpty()) { builder.setFees(fees); DateTime notAfterDate = null; for (Fee fee : fees) { if (fee.hasValidDateRange()) { DateTime endDate = fee.getValidDateRange().upperEndpoint(); if (notAfterDate == null || notAfterDate.isAfter(endDate)) { notAfterDate = endDate; } } } if (notAfterDate != null && !notAfterDate.equals(END_OF_TIME)) { builder.setNotAfterDateIfSupported(notAfterDate); } } }