Skip to content

Commit 41d26d8

Browse files
authored
Remove references to contacts in domain flows (#2944)
We've moved on from contacts entirely now so the only thing we really need to do is make sure that people don't include contacts in domain creates or updates. This also makes auth code checking easier too, because now the only auth code that you're allowed to provide is the domain auth code (not a contact auth code)
1 parent 71c9407 commit 41d26d8

32 files changed

+95
-773
lines changed

core/src/main/java/google/registry/batch/RemoveAllDomainContactsAction.java

Lines changed: 0 additions & 238 deletions
This file was deleted.

core/src/main/java/google/registry/flows/FlowModule.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import dagger.Module;
2323
import dagger.Provides;
2424
import google.registry.flows.picker.FlowPicker;
25-
import google.registry.model.contact.ContactHistory;
2625
import google.registry.model.domain.DomainHistory;
2726
import google.registry.model.domain.metadata.MetadataExtension;
2827
import google.registry.model.eppcommon.AuthInfo;
@@ -267,23 +266,6 @@ B makeHistoryEntryBuilder(
267266
return builder;
268267
}
269268

270-
/**
271-
* Provides a partially filled in {@link ContactHistory.Builder}
272-
*
273-
* <p>This is not marked with {@link FlowScope} so that each retry gets a fresh one. Otherwise,
274-
* the fact that the builder is one-use would cause NPEs.
275-
*/
276-
@Provides
277-
static ContactHistory.Builder provideContactHistoryBuilder(
278-
Trid trid,
279-
@InputXml byte[] inputXmlBytes,
280-
@Superuser boolean isSuperuser,
281-
@RegistrarId String registrarId,
282-
EppInput eppInput) {
283-
return makeHistoryEntryBuilder(
284-
new ContactHistory.Builder(), trid, inputXmlBytes, isSuperuser, registrarId, eppInput);
285-
}
286-
287269
/**
288270
* Provides a partially filled in {@link HostHistory.Builder}
289271
*

core/src/main/java/google/registry/flows/ResourceFlowUtils.java

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import static com.google.common.collect.Sets.intersection;
1818
import static google.registry.model.EppResourceUtils.isLinked;
19-
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
2019

2120
import com.google.common.collect.ImmutableSet;
2221
import com.google.common.collect.Sets;
@@ -37,7 +36,6 @@
3736
import google.registry.model.EppResource.ForeignKeyedEppResource;
3837
import google.registry.model.EppResource.ResourceWithTransferData;
3938
import google.registry.model.ForeignKeyUtils;
40-
import google.registry.model.contact.Contact;
4139
import google.registry.model.domain.Domain;
4240
import google.registry.model.domain.DomainBase;
4341
import google.registry.model.domain.Period;
@@ -124,14 +122,6 @@ public static void verifyAuthInfoPresentForResourceTransfer(Optional<AuthInfo> a
124122
}
125123
}
126124

127-
/** Check that the given AuthInfo is either missing or else is valid for the given resource. */
128-
public static void verifyOptionalAuthInfo(Optional<AuthInfo> authInfo, Contact contact)
129-
throws EppException {
130-
if (authInfo.isPresent()) {
131-
verifyAuthInfo(authInfo.get(), contact);
132-
}
133-
}
134-
135125
/** Check that the given AuthInfo is either missing or else is valid for the given resource. */
136126
public static void verifyOptionalAuthInfo(Optional<AuthInfo> authInfo, Domain domain)
137127
throws EppException {
@@ -142,37 +132,14 @@ public static void verifyOptionalAuthInfo(Optional<AuthInfo> authInfo, Domain do
142132

143133
/** Check that the given {@link AuthInfo} is valid for the given domain. */
144134
public static void verifyAuthInfo(AuthInfo authInfo, Domain domain) throws EppException {
145-
final String authRepoId = authInfo.getPw().getRepoId();
146-
String authPassword = authInfo.getPw().getValue();
147-
if (authRepoId == null) {
148-
// If no roid is specified, check the password against the domain's password.
149-
String domainPassword = domain.getAuthInfo().getPw().getValue();
150-
if (!domainPassword.equals(authPassword)) {
151-
throw new BadAuthInfoForResourceException();
152-
}
153-
return;
154-
}
155-
// The roid should match one of the contacts.
156-
Optional<VKey<Contact>> foundContact =
157-
domain.getReferencedContacts().stream()
158-
.filter(key -> key.getKey().equals(authRepoId))
159-
.findFirst();
160-
if (foundContact.isEmpty()) {
135+
String authRepoId = authInfo.getPw().getRepoId();
136+
// Previously one could auth against a contact, but we no longer hold any contact info
137+
if (authRepoId != null) {
161138
throw new BadAuthInfoForResourceException();
162139
}
163-
// Check the authInfo against the contact.
164-
verifyAuthInfo(authInfo, tm().loadByKey(foundContact.get()));
165-
}
166-
167-
/** Check that the given {@link AuthInfo} is valid for the given contact. */
168-
public static void verifyAuthInfo(AuthInfo authInfo, Contact contact) throws EppException {
169-
String authRepoId = authInfo.getPw().getRepoId();
170140
String authPassword = authInfo.getPw().getValue();
171-
String contactPassword = contact.getAuthInfo().getPw().getValue();
172-
if (!contactPassword.equals(authPassword)
173-
// It's unnecessary to specify a repoId on a contact auth info, but if it's there validate
174-
// it. The usual case of this is validating a domain's auth using this method.
175-
|| (authRepoId != null && !authRepoId.equals(contact.getRepoId()))) {
141+
String domainPassword = domain.getAuthInfo().getPw().getValue();
142+
if (!domainPassword.equals(authPassword)) {
176143
throw new BadAuthInfoForResourceException();
177144
}
178145
}

core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@
167167
* @error {@link DomainFlowUtils.DomainLabelBlockedByBsaException}
168168
* @error {@link DomainFlowUtils.DomainLabelTooLongException}
169169
* @error {@link DomainFlowUtils.DomainReservedException}
170-
* @error {@link DomainFlowUtils.DuplicateContactForRoleException}
171170
* @error {@link DomainFlowUtils.EmptyDomainNamePartException}
172171
* @error {@link DomainFlowUtils.ExceedsMaxRegistrationYearsException}
173172
* @error {@link DomainFlowUtils.ExpiredClaimException}
@@ -188,7 +187,6 @@
188187
* @error {@link DomainFlowUtils.MaxSigLifeNotSupportedException}
189188
* @error {@link DomainFlowUtils.MissingBillingAccountMapException}
190189
* @error {@link DomainFlowUtils.MissingClaimsNoticeException}
191-
* @error {@link DomainFlowUtils.MissingContactTypeException}
192190
* @error {@link DomainFlowUtils.NameserversNotAllowedForTldException}
193191
* @error {@link DomainFlowUtils.NameserversNotSpecifiedForTldWithNameserverAllowListException}
194192
* @error {@link DomainFlowUtils.PremiumNameBlockedException}
@@ -221,7 +219,8 @@ public final class DomainCreateFlow implements MutatingFlow {
221219
@Inject DomainPricingLogic pricingLogic;
222220
@Inject DomainDeletionTimeCache domainDeletionTimeCache;
223221

224-
@Inject DomainCreateFlow() {}
222+
@Inject
223+
DomainCreateFlow() {}
225224

226225
@Override
227226
public EppResponse run() throws EppException {
@@ -378,12 +377,10 @@ public EppResponse run() throws EppException {
378377
.setLaunchNotice(hasClaimsNotice ? launchCreate.get().getNotice() : null)
379378
.setSmdId(signedMarkId)
380379
.setDsData(secDnsCreate.map(SecDnsCreateExtension::getDsData).orElse(null))
381-
.setRegistrant(command.getRegistrant())
382380
.setAuthInfo(command.getAuthInfo())
383381
.setDomainName(targetId)
384382
.setNameservers(command.getNameservers().stream().collect(toImmutableSet()))
385383
.setStatusValues(statuses)
386-
.setContacts(command.getContacts())
387384
.addGracePeriod(
388385
GracePeriod.forBillingEvent(GracePeriodStatus.ADD, repoId, createBillingEvent))
389386
.setLordnPhase(

core/src/main/java/google/registry/flows/domain/DomainFlowTmchUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ public Base64RequiredForEncodedSignedMarksException() {
157157
}
158158

159159
/** The provided mark does not match the desired domain label. */
160-
static class NoMarksFoundMatchingDomainException extends RequiredParameterMissingException {
160+
public static class NoMarksFoundMatchingDomainException
161+
extends RequiredParameterMissingException {
161162
public NoMarksFoundMatchingDomainException() {
162163
super("The provided mark does not match the desired domain label");
163164
}

0 commit comments

Comments
 (0)