mirror of
https://github.com/google/nomulus.git
synced 2025-06-27 06:44:51 +02:00
Add extensibility framework for allocation tokens
This uses an extensibility mechanism similar to that of WhoisCommandFactory and CustomLogicFactory, namely, that a fully qualified Java class is specified in the YAML file for each environment with the allocation token custom logic to be used. By default, this points to a no-op base class that does nothing. Users that wish to add their own allocation token custom logic can simply create a new class that extends AllocationTokenCustomLogic and then configure it in their .yaml config files. This also renames the existing *FlowCustomLogic *Flow instance variables from customLogic to flowCustomLogic, to avoid the potential confusion with the new AllocationTokenCustomLogic class that also now exists. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=183003112
This commit is contained in:
parent
e6a097a590
commit
9d532cb507
17 changed files with 320 additions and 61 deletions
|
@ -14,9 +14,9 @@
|
|||
|
||||
package google.registry.flows.domain;
|
||||
|
||||
import static com.google.common.base.Strings.emptyToNull;
|
||||
import static google.registry.flows.FlowUtils.validateClientIsLoggedIn;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyTargetIdCount;
|
||||
import static google.registry.flows.domain.AllocationTokenFlowUtils.checkDomainsWithToken;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.checkAllowedAccessToTld;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.getReservationTypes;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.handleFeeRequest;
|
||||
|
@ -44,6 +44,7 @@ import google.registry.flows.annotations.ReportingSpec;
|
|||
import google.registry.flows.custom.DomainCheckFlowCustomLogic;
|
||||
import google.registry.flows.custom.DomainCheckFlowCustomLogic.BeforeResponseParameters;
|
||||
import google.registry.flows.custom.DomainCheckFlowCustomLogic.BeforeResponseReturnData;
|
||||
import google.registry.flows.domain.token.AllocationTokenFlowUtils;
|
||||
import google.registry.model.domain.DomainCommand.Check;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.fee.FeeCheckCommandExtension;
|
||||
|
@ -114,7 +115,8 @@ public final class DomainCheckFlow implements Flow {
|
|||
@Inject @Superuser boolean isSuperuser;
|
||||
@Inject Clock clock;
|
||||
@Inject EppResponse.Builder responseBuilder;
|
||||
@Inject DomainCheckFlowCustomLogic customLogic;
|
||||
@Inject AllocationTokenFlowUtils allocationTokenFlowUtils;
|
||||
@Inject DomainCheckFlowCustomLogic flowCustomLogic;
|
||||
@Inject DomainPricingLogic pricingLogic;
|
||||
@Inject DomainCheckFlow() {}
|
||||
|
||||
|
@ -122,7 +124,7 @@ public final class DomainCheckFlow implements Flow {
|
|||
public EppResponse run() throws EppException {
|
||||
extensionManager.register(
|
||||
FeeCheckCommandExtension.class, LaunchCheckExtension.class, AllocationTokenExtension.class);
|
||||
customLogic.beforeValidation();
|
||||
flowCustomLogic.beforeValidation();
|
||||
extensionManager.validate();
|
||||
validateClientIsLoggedIn(clientId);
|
||||
List<String> targetIds = ((Check) resourceCommand).getTargetIds();
|
||||
|
@ -144,7 +146,7 @@ public final class DomainCheckFlow implements Flow {
|
|||
}
|
||||
}
|
||||
ImmutableMap<String, InternetDomainName> domainNames = domains.build();
|
||||
customLogic.afterValidation(
|
||||
flowCustomLogic.afterValidation(
|
||||
DomainCheckFlowCustomLogic.AfterValidationParameters.newBuilder()
|
||||
.setDomainNames(domainNames)
|
||||
// TODO: Use as of date from fee extension v0.12 instead of now, if specified.
|
||||
|
@ -155,7 +157,7 @@ public final class DomainCheckFlow implements Flow {
|
|||
eppInput.getSingleExtension(AllocationTokenExtension.class);
|
||||
ImmutableMap<String, String> tokenCheckResults =
|
||||
allocationTokenExtension.isPresent()
|
||||
? checkDomainsWithToken(
|
||||
? allocationTokenFlowUtils.checkDomainsWithToken(
|
||||
targetIds, allocationTokenExtension.get().getAllocationToken(), clientId)
|
||||
: ImmutableMap.of();
|
||||
ImmutableList.Builder<DomainCheck> checks = new ImmutableList.Builder<>();
|
||||
|
@ -165,7 +167,7 @@ public final class DomainCheckFlow implements Flow {
|
|||
checks.add(DomainCheck.create(!message.isPresent(), targetId, message.orElse(null)));
|
||||
}
|
||||
BeforeResponseReturnData responseData =
|
||||
customLogic.beforeResponse(
|
||||
flowCustomLogic.beforeResponse(
|
||||
BeforeResponseParameters.newBuilder()
|
||||
.setDomainChecks(checks.build())
|
||||
.setResponseExtensions(getResponseExtensions(domainNames, now))
|
||||
|
@ -202,9 +204,7 @@ public final class DomainCheckFlow implements Flow {
|
|||
if (!reservationTypes.isEmpty()) {
|
||||
return Optional.of(getTypeOfHighestSeverity(reservationTypes).getMessageForCheck());
|
||||
}
|
||||
return tokenCheckResults.containsKey(domainName.toString())
|
||||
? Optional.of(tokenCheckResults.get(domainName.toString()))
|
||||
: Optional.empty();
|
||||
return Optional.ofNullable(emptyToNull(tokenCheckResults.get(domainName.toString())));
|
||||
}
|
||||
|
||||
/** Handle the fee check extension. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue