Class DomainFlowUtils

java.lang.Object
google.registry.flows.domain.DomainFlowUtils

public class DomainFlowUtils extends Object
Static utility functions for domain flows.
  • Field Details

    • TYPES_ALLOWED_FOR_CREATE_ONLY_IN_SUNRISE

      public static final com.google.common.collect.ImmutableSet<ReservationType> TYPES_ALLOWED_FOR_CREATE_ONLY_IN_SUNRISE
      Reservation types that are only allowed in sunrise by policy.
    • COLLISION_MESSAGE

      public static final String COLLISION_MESSAGE
      Warning message for allocation of collision domains in sunrise.
      See Also:
  • Constructor Details

    • DomainFlowUtils

      public DomainFlowUtils()
  • Method Details

    • validateDomainName

      public static com.google.common.net.InternetDomainName validateDomainName(String name) throws EppException
      Returns parsed version of name if domain name label follows our naming rules and is under one of the given allowed TLDs.

      Note: This method does not perform language validation with IDN tables.

      Throws:
      EppException
      See Also:
    • validateDomainNameWithIdnTables

      public static String validateDomainNameWithIdnTables(com.google.common.net.InternetDomainName domainName) throws DomainFlowUtils.InvalidIdnDomainLabelException
      Returns name of first matching IDN table for domain label.
      Throws:
      DomainFlowUtils.InvalidIdnDomainLabelException - if IDN table or language validation failed
      See Also:
    • verifyNotBlockedByBsa

      public static void verifyNotBlockedByBsa(com.google.common.net.InternetDomainName domainName, Tld tld, org.joda.time.DateTime now, Optional<AllocationToken> allocationToken) throws google.registry.flows.domain.DomainFlowUtils.DomainLabelBlockedByBsaException
      Verifies that the domainLabel is not blocked by any BSA block label for the given tld at the specified time.
      Throws:
      google.registry.flows.domain.DomainFlowUtils.DomainLabelBlockedByBsaException
    • isBlockedByBsa

      public static boolean isBlockedByBsa(String domainLabel, Tld tld, org.joda.time.DateTime now)
    • isAnchorTenant

      public static boolean isAnchorTenant(com.google.common.net.InternetDomainName domainName, Optional<AllocationToken> token, Optional<MetadataExtension> metadataExtension)
      Returns whether a given domain create request is for a valid anchor tenant.
    • isValidReservedCreate

      public static boolean isValidReservedCreate(com.google.common.net.InternetDomainName domainName, Optional<AllocationToken> token)
      Returns whether a given domain create request is for a valid reserved domain.
    • isRegisterBsaCreate

      public static boolean isRegisterBsaCreate(com.google.common.net.InternetDomainName domainName, Optional<AllocationToken> token)
      Returns whether a given domain create request may bypass the BSA block check.
    • checkAllowedAccessToTld

      public static void checkAllowedAccessToTld(String registrarId, String tld) throws EppException
      Check if the registrar running the flow has access to the TLD in question.
      Throws:
      EppException
    • checkHasBillingAccount

      public static void checkHasBillingAccount(String registrarId, String tldStr) throws EppException
      Check if the registrar has the correct billing account map configured.
      Throws:
      EppException
    • validateAlgorithm

      public static boolean validateAlgorithm(int alg)
    • isReserved

      public static boolean isReserved(com.google.common.net.InternetDomainName domainName, boolean isSunrise)
    • newAutorenewBillingEvent

      public static BillingRecurrence.Builder newAutorenewBillingEvent(Domain domain)
      Fills in a builder with the data needed for an autorenew billing event for this domain. This does not copy over the id of the current autorenew billing event.
    • newAutorenewPollMessage

      public static PollMessage.Autorenew.Builder newAutorenewPollMessage(Domain domain)
      Fills in a builder with the data needed for an autorenew poll message for this domain. This does not copy over the id of the current autorenew poll message.
    • updateAutorenewRecurrenceEndTime

      public static BillingRecurrence updateAutorenewRecurrenceEndTime(Domain domain, BillingRecurrence existingBillingRecurrence, org.joda.time.DateTime newEndTime, @Nullable HistoryEntry.HistoryEntryId historyId)
      Re-saves the current autorenew billing event and poll message with a new end time.

      This may end up deleting the poll message (if closing the message interval) or recreating it (if opening the message interval). This may cause an autorenew billing event to have an end time earlier than its event time (i.e. if it's being ended before it was ever triggered).

      Returns the new autorenew recurrence billing event.

    • validateFeeChallenge

      public static void validateFeeChallenge(Optional<? extends FeeTransformCommandExtension> feeCommand, FeesAndCredits feesAndCredits, boolean defaultTokenUsed) throws EppException
      Validates that fees are acked and match if they are required (typically for premium domains).

      This is used by domain operations that have an implicit cost, e.g. domain create or renew (both of which add one or more years' worth of registration). Depending on registry and/or registrar settings, explicit price acking using the fee extension may be required for premium domain names.

      Throws:
      EppException
    • validateFeesAckedIfPresent

      public static void validateFeesAckedIfPresent(Optional<? extends FeeTransformCommandExtension> feeCommand, FeesAndCredits feesAndCredits, boolean defaultTokenUsed) throws EppException
      Validates that non-zero fees are acked (i.e. they are specified and the amount matches).

      This is used directly by update operations, i.e. those that otherwise don't have implicit costs, and is also used as a helper method to validate if fees are required for operations that do have implicit costs, e.g. creates and renews.

      Throws:
      EppException
    • validateRegistrationPeriod

      public static void validateRegistrationPeriod(org.joda.time.DateTime now, org.joda.time.DateTime newExpirationTime) throws EppException
      Check whether a new expiration time (via a renew) does not extend beyond a maximum number of years (e.g. DomainBase.MAX_REGISTRATION_YEARS) from "now".
      Throws:
      google.registry.flows.domain.DomainFlowUtils.ExceedsMaxRegistrationYearsException - if the new registration period is too long
      EppException
    • validateRegistrationPeriod

      public static void validateRegistrationPeriod(int years) throws EppException
      Check that a new registration period (via a create) does not extend beyond a maximum number of years (e.g. DomainBase.MAX_REGISTRATION_YEARS).
      Throws:
      google.registry.flows.domain.DomainFlowUtils.ExceedsMaxRegistrationYearsException - if the new registration period is too long
      EppException
    • verifyNotInPredelegation

      public static void verifyNotInPredelegation(Tld registry, org.joda.time.DateTime now) throws DomainFlowUtils.BadCommandForRegistryPhaseException
      Check that the registry phase is not predelegation, during which some flows are forbidden.
      Throws:
      DomainFlowUtils.BadCommandForRegistryPhaseException
    • createCancelingRecords

      public static com.google.common.collect.ImmutableSet<DomainTransactionRecord> createCancelingRecords(Domain domain, org.joda.time.DateTime now, org.joda.time.Duration maxSearchPeriod, com.google.common.collect.ImmutableSet<DomainTransactionRecord.TransactionReportField> cancelableFields)
      Returns a set of DomainTransactionRecords which negate the most recent HistoryEntry's records.

      Domain deletes and transfers use this function to account for previous records negated by their flow. For example, if a grace period delete occurs, we must add -1 counters for the associated NET_ADDS_#_YRS field, if it exists.

      The steps are as follows: 1. Find all HistoryEntries under the domain modified in the past, up to the maxSearchPeriod. 2. Only keep HistoryEntries with a DomainTransactionRecord that a) hasn't been reported yet and b) matches the predicate 3. Return the transactionRecords under the most recent HistoryEntry that fits the above criteria, with negated reportAmounts.

    • checkForDefaultToken

      public static Optional<AllocationToken> checkForDefaultToken(Tld tld, String domainName, FeeQueryCommandExtensionItem.CommandName commandName, String registrarId, org.joda.time.DateTime now) throws EppException
      Checks if there is a valid default token to be used for a domain create command.

      If there is more than one valid default token for the registration, only the first valid token found on the TLD's default token list will be returned.

      Throws:
      EppException