Skip to content

Commit e8a475f

Browse files
authored
Remove Contact objects in RDAP output (#2811)
Note: this still includes "contacts" for registrars, which are actually a different concept that we call RegistrarPoc. That's different from "Contact" objects, e.g. registrant.
1 parent bdaab9d commit e8a475f

File tree

71 files changed

+383
-5977
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+383
-5977
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ && sendNotificationEmail(
275275
*/
276276
@VisibleForTesting
277277
ImmutableSet<InternetAddress> getEmailAddresses(Registrar registrar, Type contactType) {
278-
ImmutableSortedSet<RegistrarPoc> contacts = registrar.getContactsOfType(contactType);
278+
ImmutableSortedSet<RegistrarPoc> contacts = registrar.getPocsOfType(contactType);
279279
ImmutableSet.Builder<InternetAddress> recipientEmails = new ImmutableSet.Builder<>();
280280
for (RegistrarPoc contact : contacts) {
281281
try {

core/src/main/java/google/registry/model/registrar/Registrar.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ public String getDriveFolderId() {
578578
* address.
579579
*/
580580
public ImmutableSortedSet<RegistrarPoc> getContacts() {
581-
return getContactPocs(tm()).stream()
581+
return getPocs(tm()).stream()
582582
.filter(Objects::nonNull)
583583
.collect(toImmutableSortedSet(CONTACT_EMAIL_COMPARATOR));
584584
}
@@ -590,8 +590,8 @@ public ImmutableSortedSet<RegistrarPoc> getContacts() {
590590
* <p>This method queries the replica database. It is reserved for use cases that can tolerate
591591
* slightly stale data.
592592
*/
593-
public ImmutableSortedSet<RegistrarPoc> getContactsFromReplica() {
594-
return getContactPocs(replicaTm()).stream()
593+
public ImmutableSortedSet<RegistrarPoc> getPocsFromReplica() {
594+
return getPocs(replicaTm()).stream()
595595
.filter(Objects::nonNull)
596596
.collect(toImmutableSortedSet(CONTACT_EMAIL_COMPARATOR));
597597
}
@@ -600,8 +600,8 @@ public ImmutableSortedSet<RegistrarPoc> getContactsFromReplica() {
600600
* Returns a list of {@link RegistrarPoc} objects of a given type for this registrar sorted by
601601
* their email address.
602602
*/
603-
public ImmutableSortedSet<RegistrarPoc> getContactsOfType(final RegistrarPoc.Type type) {
604-
return getContactPocs(tm()).stream()
603+
public ImmutableSortedSet<RegistrarPoc> getPocsOfType(final RegistrarPoc.Type type) {
604+
return getPocs(tm()).stream()
605605
.filter(Objects::nonNull)
606606
.filter((@Nullable RegistrarPoc contact) -> contact.getTypes().contains(type))
607607
.collect(toImmutableSortedSet(CONTACT_EMAIL_COMPARATOR));
@@ -615,7 +615,7 @@ public Optional<RegistrarPoc> getWhoisAbuseContact() {
615615
return getContacts().stream().filter(RegistrarPoc::getVisibleInDomainWhoisAsAbuse).findFirst();
616616
}
617617

618-
private ImmutableList<RegistrarPoc> getContactPocs(TransactionManager txnManager) {
618+
private ImmutableList<RegistrarPoc> getPocs(TransactionManager txnManager) {
619619
return txnManager.transact(() -> RegistrarPoc.loadForRegistrar(registrarId));
620620
}
621621

core/src/main/java/google/registry/rdap/RdapEntityAction.java

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@
1414

1515
package google.registry.rdap;
1616

17-
import static google.registry.persistence.transaction.TransactionManagerFactory.replicaTm;
1817
import static google.registry.rdap.RdapUtils.getRegistrarByIanaIdentifier;
1918
import static google.registry.rdap.RdapUtils.getRegistrarByName;
2019
import static google.registry.request.Action.Method.GET;
2120
import static google.registry.request.Action.Method.HEAD;
2221

23-
import com.google.common.collect.ImmutableSet;
2422
import com.google.common.primitives.Longs;
25-
import com.google.re2j.Pattern;
26-
import google.registry.model.contact.Contact;
2723
import google.registry.model.registrar.Registrar;
28-
import google.registry.persistence.VKey;
2924
import google.registry.rdap.RdapJsonFormatter.OutputDataType;
3025
import google.registry.rdap.RdapMetrics.EndpointType;
3126
import google.registry.rdap.RdapObjectClasses.RdapEntity;
@@ -37,8 +32,8 @@
3732
import java.util.Optional;
3833

3934
/**
40-
* RDAP action for entity (contact and registrar) requests. the ICANN operational profile dictates
41-
* that the "handle" for registrars is to be the IANA registrar ID:
35+
* RDAP action for entity (i.e. registrar) requests. the ICANN operational profile dictates that the
36+
* "handle" for registrars is to be the IANA registrar ID:
4237
*
4338
* <p>2.4.1.Registry RDAP servers MUST support Registrar object lookup using an entity path request
4439
* for entities with the registrar role using the handle (as described in 3.1.5 of RFC9082) where
@@ -52,33 +47,13 @@
5247
auth = Auth.AUTH_PUBLIC)
5348
public class RdapEntityAction extends RdapActionBase {
5449

55-
private static final Pattern ROID_PATTERN = Pattern.compile("[-_.a-zA-Z0-9]+");
56-
5750
@Inject public RdapEntityAction() {
5851
super("entity", EndpointType.ENTITY);
5952
}
6053

6154
@Override
6255
public RdapEntity getJsonObjectForResource(
6356
String pathSearchString, boolean isHeadRequest) {
64-
// The query string is not used; the RDAP syntax is /rdap/entity/handle (the handle is the roid
65-
// for contacts and the client identifier/fn for registrars). Since RDAP's concept of an entity
66-
// includes both contacts and registrars, search for one first, then the other.
67-
68-
// RDAP Technical Implementation Guide 2.3.1 - MUST support contact entity lookup using the
69-
// handle
70-
if (ROID_PATTERN.matcher(pathSearchString).matches()) {
71-
VKey<Contact> contactVKey = VKey.create(Contact.class, pathSearchString);
72-
Optional<Contact> contact =
73-
replicaTm().transact(() -> replicaTm().loadByKeyIfPresent(contactVKey));
74-
// As per Andy Newton on the regext mailing list, contacts by themselves have no role, since
75-
// they are global, and might have different roles for different domains.
76-
if (contact.isPresent() && isAuthorized(contact.get())) {
77-
return rdapJsonFormatter.createRdapContactEntity(
78-
contact.get(), ImmutableSet.of(), OutputDataType.FULL);
79-
}
80-
}
81-
8257
// RDAP Technical Implementation Guide 2.4.1 - MUST support registrar entity lookup using the
8358
// IANA ID as handle
8459
Long ianaIdentifier = Longs.tryParse(pathSearchString);
@@ -96,7 +71,7 @@ public RdapEntity getJsonObjectForResource(
9671
return rdapJsonFormatter.createRdapRegistrarEntity(registrar.get(), OutputDataType.FULL);
9772
}
9873

99-
// At this point, we have failed to find either a contact or a registrar.
74+
// At this point, we have failed to find a registrar.
10075
//
10176
// RFC7480 5.3 - if the server wishes to respond that it doesn't have data satisfying the
10277
// query, it MUST reply with 404 response code.

0 commit comments

Comments
 (0)