mirror of
https://github.com/google/nomulus.git
synced 2025-05-28 16:30:12 +02:00
Handle LRP tokens in flows
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=130679951
This commit is contained in:
parent
5ff8b9377c
commit
1894b2308b
9 changed files with 256 additions and 5 deletions
|
@ -41,6 +41,7 @@ import static google.registry.util.CollectionUtils.nullToEmpty;
|
|||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Work;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.ParameterValuePolicyErrorException;
|
||||
|
@ -49,10 +50,12 @@ import google.registry.flows.EppException.ParameterValueSyntaxErrorException;
|
|||
import google.registry.flows.EppException.StatusProhibitsOperationException;
|
||||
import google.registry.flows.EppException.UnimplementedOptionException;
|
||||
import google.registry.flows.ResourceCreateFlow;
|
||||
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.DomainBase.Builder;
|
||||
import google.registry.model.domain.DomainCommand.Create;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.LrpToken;
|
||||
import google.registry.model.domain.fee.FeeTransformCommandExtension;
|
||||
import google.registry.model.domain.launch.LaunchCreateExtension;
|
||||
import google.registry.model.domain.launch.LaunchNotice;
|
||||
|
@ -90,6 +93,7 @@ public abstract class BaseDomainCreateFlow<R extends DomainBase, B extends Build
|
|||
protected SignedMark signedMark;
|
||||
protected boolean isAnchorTenantViaReservation;
|
||||
protected TldState tldState;
|
||||
protected Optional<LrpToken> lrpToken;
|
||||
|
||||
@Override
|
||||
public final void initResourceCreateOrMutateFlow() throws EppException {
|
||||
|
@ -183,6 +187,13 @@ public abstract class BaseDomainCreateFlow<R extends DomainBase, B extends Build
|
|||
// The TLD should always be the parent of the requested domain name.
|
||||
isAnchorTenantViaReservation = matchesAnchorTenantReservation(
|
||||
domainLabel, tld, command.getAuthInfo().getPw().getValue());
|
||||
boolean isLrpApplication =
|
||||
registry.getLrpTldStates().contains(tldState)
|
||||
&& !command.getAuthInfo().getPw().getValue().isEmpty()
|
||||
&& !isAnchorTenantViaReservation;
|
||||
lrpToken = isLrpApplication
|
||||
? TldSpecificLogicProxy.getMatchingLrpToken(command)
|
||||
: Optional.<LrpToken>absent();
|
||||
// Superusers can create reserved domains, force creations on domains that require a claims
|
||||
// notice without specifying a claims key, and override blocks on registering premium domains.
|
||||
if (!isSuperuser) {
|
||||
|
@ -191,6 +202,9 @@ public abstract class BaseDomainCreateFlow<R extends DomainBase, B extends Build
|
|||
if (!isAnchorTenantViaReservation) {
|
||||
verifyNotReserved(domainName, isSunriseApplication);
|
||||
}
|
||||
if (isLrpApplication && !lrpToken.isPresent()) {
|
||||
throw new BadAuthInfoForResourceException();
|
||||
}
|
||||
boolean isClaimsPeriod = now.isBefore(registry.getClaimsPeriodEnd());
|
||||
boolean isClaimsCreate = launchCreate != null && launchCreate.getNotice() != null;
|
||||
if (isClaimsPeriod) {
|
||||
|
@ -231,6 +245,15 @@ public abstract class BaseDomainCreateFlow<R extends DomainBase, B extends Build
|
|||
verifyDomainCreateIsAllowed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void modifyCreateRelatedResources() {
|
||||
if (lrpToken.isPresent()) {
|
||||
ofy().save().entity(lrpToken.get().asBuilder()
|
||||
.setRedemptionHistoryEntry(Key.create(historyEntry))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
/** Validate the secDNS extension, if present. */
|
||||
private void validateSecDnsExtension() throws EppException {
|
||||
if (secDnsCreate != null) {
|
||||
|
|
|
@ -52,9 +52,10 @@ import javax.inject.Inject;
|
|||
* An EPP flow that creates a new application for a domain resource.
|
||||
*
|
||||
* @error {@link google.registry.flows.EppException.UnimplementedExtensionException}
|
||||
* @error {@link google.registry.flows.ResourceFlow.BadCommandForRegistryPhaseException}
|
||||
* @error {@link google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException}
|
||||
* @error {@link google.registry.flows.ResourceCreateFlow.ResourceAlreadyExistsException}
|
||||
* @error {@link google.registry.flows.ResourceFlow.BadCommandForRegistryPhaseException}
|
||||
* @error {@link google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException}
|
||||
* @error {@link google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException}
|
||||
* @error {@link BaseDomainCreateFlow.AcceptedTooLongAgoException}
|
||||
* @error {@link BaseDomainCreateFlow.ClaimsPeriodEndedException}
|
||||
* @error {@link BaseDomainCreateFlow.ExpiredClaimException}
|
||||
|
|
|
@ -40,8 +40,8 @@ public class LrpToken extends BackupGroupRoot implements Buildable {
|
|||
String token;
|
||||
|
||||
/**
|
||||
* The token's assignee (additional metadata for identifying the owner of the token, which may
|
||||
* vary from TLD to TLD).
|
||||
* The token's assignee (additional metadata for identifying the owner of the token, the details
|
||||
* of which might differ from TLD to TLD).
|
||||
*/
|
||||
@Index
|
||||
String assignee;
|
||||
|
|
|
@ -16,12 +16,16 @@ package google.registry.pricing;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.pricing.PricingEngineProxy.getPricesForDomainName;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.domain.DomainCommand.Create;
|
||||
import google.registry.model.domain.LrpToken;
|
||||
import google.registry.model.domain.fee.EapFee;
|
||||
import google.registry.model.domain.fee.Fee;
|
||||
import google.registry.model.pricing.PremiumPricingEngine.DomainPrices;
|
||||
|
@ -146,4 +150,26 @@ public final class TldSpecificLogicProxy {
|
|||
public static Optional<String> getFeeClass(String domainName, DateTime date) {
|
||||
return getPricesForDomainName(domainName, date).getFeeClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a {@link Create} command has a valid {@link LrpToken} for a particular TLD, and
|
||||
* return that token (wrapped in an {@link Optional}) if one exists.
|
||||
*
|
||||
* <p>This method has no knowledge of whether or not an auth code (interpreted here as an LRP
|
||||
* token) has already been checked against the reserved list for QLP (anchor tenant), as auth
|
||||
* codes are used for both types of registrations.
|
||||
*/
|
||||
public static Optional<LrpToken> getMatchingLrpToken(Create createCommand) {
|
||||
// Note that until the actual per-TLD logic is built out, what's being done here is a basic
|
||||
// domain-name-to-assignee match.
|
||||
String lrpToken = createCommand.getAuthInfo().getPw().getValue();
|
||||
LrpToken token = ofy().load().key(Key.create(LrpToken.class, lrpToken)).now();
|
||||
if (token != null) {
|
||||
if (token.getAssignee().equalsIgnoreCase(createCommand.getFullyQualifiedDomainName())
|
||||
&& token.getRedemptionHistoryEntry() == null) {
|
||||
return Optional.of(token);
|
||||
}
|
||||
}
|
||||
return Optional.<LrpToken>absent();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue