Don't allow non-active registrars to create domains or applications

Specifically, this prevents suspended registrars from creating domains or applications. Pending registrars already can't perform these actions because they get an error message when attempting to log in.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170481338
This commit is contained in:
mcilwain 2017-09-29 07:42:40 -07:00 committed by Ben McIlwain
parent d09bd89629
commit 1c4e79f99e
14 changed files with 89 additions and 21 deletions

View file

@ -102,6 +102,7 @@ import google.registry.model.eppoutput.EppResponse.ResponseExtension;
import google.registry.model.host.HostResource;
import google.registry.model.poll.PollMessage;
import google.registry.model.registrar.Registrar;
import google.registry.model.registrar.Registrar.State;
import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState;
import google.registry.model.registry.label.ReservationType;
@ -753,6 +754,19 @@ public class DomainFlowUtils {
}
}
/**
* Check that the registrar with the given client ID is active.
*
* <p>Non-active registrars are not allowed to create domain applications or domain resources.
*/
static void verifyRegistrarIsActive(String clientId)
throws RegistrarMustBeActiveToCreateDomainsException {
Registrar registrar = Registrar.loadByClientIdCached(clientId).get();
if (registrar.getState() != State.ACTIVE) {
throw new RegistrarMustBeActiveToCreateDomainsException();
}
}
/** Check that the registry phase is not incompatible with launch extension flows. */
static void verifyRegistryStateAllowsLaunchFlows(Registry registry, DateTime now)
throws BadCommandForRegistryPhaseException {
@ -1426,4 +1440,12 @@ public class DomainFlowUtils {
MAX_REGISTRATION_YEARS));
}
}
/** Registrar must be active in order to create domains or applications. */
static class RegistrarMustBeActiveToCreateDomainsException extends AuthorizationErrorException {
public RegistrarMustBeActiveToCreateDomainsException() {
super("Registrar must be active in order to create domains or applications");
}
}
}