Standardize usage of some transfer flow verification helpers

We were using verifyHasPendingTransfer() only in the domain transfer flows; now we use it in both.  I also added a helper verifyTransferInitiator() even though it's only used in two places (the transfer cancel flows), because I think it streamlines the flow and makes it more consistent with the whole section of verification checking.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=150324823
This commit is contained in:
nickfelt 2017-03-16 08:54:04 -07:00 committed by Ben McIlwain
parent 7622e71dcf
commit d8349aa0ee
5 changed files with 21 additions and 29 deletions

View file

@ -41,6 +41,7 @@ import google.registry.flows.EppException.ParameterValuePolicyErrorException;
import google.registry.flows.EppException.ParameterValueRangeErrorException;
import google.registry.flows.exceptions.MissingTransferRequestAuthInfoException;
import google.registry.flows.exceptions.NotPendingTransferException;
import google.registry.flows.exceptions.NotTransferInitiatorException;
import google.registry.flows.exceptions.ResourceAlreadyExistsException;
import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException;
import google.registry.flows.exceptions.ResourceToDeleteIsReferencedException;
@ -288,6 +289,13 @@ public final class ResourceFlowUtils {
}
}
public static <R extends EppResource & ResourceWithTransferData> void verifyTransferInitiator(
String clientId, R resource) throws NotTransferInitiatorException {
if (!resource.getTransferData().getGainingClientId().equals(clientId)) {
throw new NotTransferInitiatorException();
}
}
public static <R extends EppResource & ForeignKeyedEppResource> R loadAndVerifyExistence(
Class<R> clazz, String targetId, DateTime now)
throws ResourceDoesNotExistException {