diff --git a/java/google/registry/whois/DomainWhoisResponse.java b/java/google/registry/whois/DomainWhoisResponse.java index 35821cabb..3f4cb659b 100644 --- a/java/google/registry/whois/DomainWhoisResponse.java +++ b/java/google/registry/whois/DomainWhoisResponse.java @@ -26,8 +26,6 @@ import com.googlecode.objectify.Key; import google.registry.model.contact.ContactPhoneNumber; import google.registry.model.contact.ContactResource; import google.registry.model.contact.PostalInfo; -import google.registry.model.domain.DesignatedContact; -import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.DomainResource; import google.registry.model.domain.GracePeriod; import google.registry.model.eppcommon.StatusValue; @@ -101,9 +99,6 @@ final class DomainWhoisResponse extends WhoisResponseImpl { abuseContact.map(RegistrarContact::getPhoneNumber).orElse(null)) .emitStatusValues(domain.getStatusValues(), domain.getGracePeriods()) .emitContact("Registrant", domain.getRegistrant(), preferUnicode) - .emitContact("Admin", getContactReference(Type.ADMIN), preferUnicode) - .emitContact("Tech", getContactReference(Type.TECH), preferUnicode) - .emitContact("Billing", getContactReference(Type.BILLING), preferUnicode) .emitSet( "Name Server", domain.loadNameserverFullyQualifiedHostNames(), @@ -118,14 +113,6 @@ final class DomainWhoisResponse extends WhoisResponseImpl { return WhoisResponseResults.create(plaintext, 1); } - /** Returns the contact of the given type, or null if it does not exist. */ - @Nullable - private Key getContactReference(final Type type) { - Optional contactOfType = - domain.getContacts().stream().filter(d -> d.getType() == type).findFirst(); - return contactOfType.map(DesignatedContact::getContactKey).orElse(null); - } - /** Output emitter with logic for domains. */ class DomainEmitter extends Emitter { DomainEmitter emitPhone( @@ -140,9 +127,7 @@ final class DomainWhoisResponse extends WhoisResponseImpl { /** Emit the contact entry of the given type. */ DomainEmitter emitContact( - String contactType, - @Nullable Key contact, - boolean preferUnicode) { + String contactType, @Nullable Key contact, boolean preferUnicode) { if (contact == null) { return this; } @@ -151,24 +136,21 @@ final class DomainWhoisResponse extends WhoisResponseImpl { // someone's attention. ContactResource contactResource = ofy().load().key(contact).now(); if (contactResource == null) { - logger.severefmt("(BUG) Broken reference found from domain %s to contact %s", + logger.severefmt( + "(BUG) Broken reference found from domain %s to contact %s", domain.getFullyQualifiedDomainName(), contact); return this; } - // ICANN Consistent Labeling & Display policy requires that this be the ROID. - emitField(ImmutableList.of("Registry", contactType, "ID"), contactResource.getRepoId()); - PostalInfo postalInfo = chooseByUnicodePreference( - preferUnicode, - contactResource.getLocalizedPostalInfo(), - contactResource.getInternationalizedPostalInfo()); + PostalInfo postalInfo = + chooseByUnicodePreference( + preferUnicode, + contactResource.getLocalizedPostalInfo(), + contactResource.getInternationalizedPostalInfo()); if (postalInfo != null) { - emitFieldIfDefined(ImmutableList.of(contactType, "Name"), postalInfo.getName()); emitFieldIfDefined(ImmutableList.of(contactType, "Organization"), postalInfo.getOrg()); - emitAddress(contactType, postalInfo.getAddress()); + emitRegistrantAddress(contactType, postalInfo.getAddress()); } - return emitPhone(contactType, "Phone", contactResource.getVoiceNumber()) - .emitPhone(contactType, "Fax", contactResource.getFaxNumber()) - .emitField(ImmutableList.of(contactType, "Email"), contactResource.getEmailAddress()); + return this; } /** Emits status values and grace periods as a set, in the AWIP format. */ diff --git a/java/google/registry/whois/RegistrarWhoisResponse.java b/java/google/registry/whois/RegistrarWhoisResponse.java index 25f953e2a..4191ba84c 100644 --- a/java/google/registry/whois/RegistrarWhoisResponse.java +++ b/java/google/registry/whois/RegistrarWhoisResponse.java @@ -48,7 +48,7 @@ class RegistrarWhoisResponse extends WhoisResponseImpl { String plaintext = new RegistrarEmitter() .emitField("Registrar", registrar.getRegistrarName()) - .emitAddress( + .emitRegistrarAddress( null, chooseByUnicodePreference( preferUnicode, diff --git a/java/google/registry/whois/WhoisResponseImpl.java b/java/google/registry/whois/WhoisResponseImpl.java index 8e5e39878..f31b23ab0 100644 --- a/java/google/registry/whois/WhoisResponseImpl.java +++ b/java/google/registry/whois/WhoisResponseImpl.java @@ -135,8 +135,8 @@ abstract class WhoisResponseImpl implements WhoisResponse { return emitField(Joiner.on(' ').join(nameParts), value); } - /** Emit a contact address. */ - E emitAddress(@Nullable String prefix, @Nullable Address address) { + /** Emit registrar address. */ + E emitRegistrarAddress(@Nullable String prefix, @Nullable Address address) { prefix = isNullOrEmpty(prefix) ? "" : prefix + " "; if (address != null) { emitList(prefix + "Street", address.getStreet()); @@ -148,6 +148,16 @@ abstract class WhoisResponseImpl implements WhoisResponse { return thisCastToDerived(); } + /** Emit registrant address. */ + E emitRegistrantAddress(@Nullable String prefix, @Nullable Address address) { + prefix = isNullOrEmpty(prefix) ? "" : prefix + " "; + if (address != null) { + emitField(prefix + "State/Province", address.getState()); + emitField(prefix + "Country", address.getCountryCode()); + } + return thisCastToDerived(); + } + /** Emit Whois Inaccuracy Complaint Form link. Only used for domain queries. */ E emitWicfLink() { emitField(ICANN_REPORTING_URL_FIELD, ICANN_REPORTING_URL); diff --git a/javatests/google/registry/whois/WhoisActionTest.java b/javatests/google/registry/whois/WhoisActionTest.java index d226529f4..636e496e2 100644 --- a/javatests/google/registry/whois/WhoisActionTest.java +++ b/javatests/google/registry/whois/WhoisActionTest.java @@ -237,7 +237,6 @@ public class WhoisActionTest { assertThat(domain1.getRepoId()).isNotEqualTo(domain2.getRepoId()); newWhoisAction("domain cat.lol\r\n").run(); assertThat(response.getStatus()).isEqualTo(200); - assertThat(response.getPayload()).contains("Dr. Pablo"); assertThat(response.getPayload()).contains("ns1.google.lol"); } diff --git a/javatests/google/registry/whois/WhoisHttpActionTest.java b/javatests/google/registry/whois/WhoisHttpActionTest.java index 7c743256d..8fd3911b6 100644 --- a/javatests/google/registry/whois/WhoisHttpActionTest.java +++ b/javatests/google/registry/whois/WhoisHttpActionTest.java @@ -163,9 +163,16 @@ public class WhoisHttpActionTest { @Test public void testRun_wickedLineFeedForgeryInDatastore_crlfSubstitutedWithSpace() throws Exception { - String evilName = "Eric\r\nSchmidt"; - ContactResource trl = persistResource( - makeContactResource("5372808-TRL", evilName, "bog@cat.みんな")); + ContactResource trl = makeContactResource("5372808-TRL", "Eric Schmidt", "bog@cat.みんな"); + trl = + persistResource( + trl.asBuilder() + .setInternationalizedPostalInfo( + trl.getInternationalizedPostalInfo() + .asBuilder() + .setOrg("Galactic\r\nEmpire") + .build()) + .build()); persistResource(makeDomainResource( "cat.みんな", trl, trl, @@ -174,7 +181,7 @@ public class WhoisHttpActionTest { persistResource(makeHostResource("ns2.cat.みんな", "bad:f00d:cafe::15:beef")), persistResource(makeRegistrar("example", "Example Registrar", Registrar.State.ACTIVE)))); newWhoisHttpAction("/domain/cat.みんな").run(); - assertThat(response.getPayload()).contains("Eric Schmidt"); + assertThat(response.getPayload()).contains("Galactic Empire"); } @Test diff --git a/javatests/google/registry/whois/testdata/whois_action_domain.txt b/javatests/google/registry/whois/testdata/whois_action_domain.txt index 1f8f5b9b5..3fee4d008 100644 --- a/javatests/google/registry/whois/testdata/whois_action_domain.txt +++ b/javatests/google/registry/whois/testdata/whois_action_domain.txt @@ -13,39 +13,9 @@ Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibit Domain Status: clientRenewProhibited https://icann.org/epp#clientRenewProhibited Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited -Registry Registrant ID: 4-ROID -Registrant Name: Goblin Market Registrant Organization: GOOGLE INCORPORATED <script> -Registrant Street: 123 Example Boulevard <script> -Registrant City: KOKOMO Registrant State/Province: BM -Registrant Postal Code: 31337 Registrant Country: US -Registrant Phone: +1.2126660420 -Registrant Fax: +1.2126660420 -Registrant Email: lol@cat.lol -Registry Admin ID: 5-ROID -Admin Name: Santa Claus -Admin Organization: GOOGLE INCORPORATED <script> -Admin Street: 123 Example Boulevard <script> -Admin City: KOKOMO -Admin State/Province: BM -Admin Postal Code: 31337 -Admin Country: US -Admin Phone: +1.2126660420 -Admin Fax: +1.2126660420 -Admin Email: BOFH@cat.lol -Registry Tech ID: 6-ROID -Tech Name: The Raven -Tech Organization: GOOGLE INCORPORATED <script> -Tech Street: 123 Example Boulevard <script> -Tech City: KOKOMO -Tech State/Province: BM -Tech Postal Code: 31337 -Tech Country: US -Tech Phone: +1.2126660420 -Tech Fax: +1.2126660420 -Tech Email: bog@cat.lol Name Server: ns1.cat.lol Name Server: ns2.cat.lol DNSSEC: signedDelegation diff --git a/javatests/google/registry/whois/testdata/whois_action_idn_punycode.txt b/javatests/google/registry/whois/testdata/whois_action_idn_punycode.txt index 29b4cf955..9af150e05 100644 --- a/javatests/google/registry/whois/testdata/whois_action_idn_punycode.txt +++ b/javatests/google/registry/whois/testdata/whois_action_idn_punycode.txt @@ -13,39 +13,9 @@ Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibit Domain Status: clientRenewProhibited https://icann.org/epp#clientRenewProhibited Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited -Registry Registrant ID: 4-ROID -Registrant Name: (◕‿◕) Registrant Organization: GOOGLE INCORPORATED <script> -Registrant Street: 123 Example Boulevard <script> -Registrant City: KOKOMO Registrant State/Province: BM -Registrant Postal Code: 31337 Registrant Country: US -Registrant Phone: +1.2126660420 -Registrant Fax: +1.2126660420 -Registrant Email: lol@cat.みんな -Registry Admin ID: 5-ROID -Admin Name: Santa Claus -Admin Organization: GOOGLE INCORPORATED <script> -Admin Street: 123 Example Boulevard <script> -Admin City: KOKOMO -Admin State/Province: BM -Admin Postal Code: 31337 -Admin Country: US -Admin Phone: +1.2126660420 -Admin Fax: +1.2126660420 -Admin Email: BOFH@cat.みんな -Registry Tech ID: 6-ROID -Tech Name: The Raven -Tech Organization: GOOGLE INCORPORATED <script> -Tech Street: 123 Example Boulevard <script> -Tech City: KOKOMO -Tech State/Province: BM -Tech Postal Code: 31337 -Tech Country: US -Tech Phone: +1.2126660420 -Tech Fax: +1.2126660420 -Tech Email: bog@cat.みんな Name Server: ns1.cat.xn--q9jyb4c Name Server: ns2.cat.xn--q9jyb4c DNSSEC: signedDelegation diff --git a/javatests/google/registry/whois/testdata/whois_action_idn_utf8.txt b/javatests/google/registry/whois/testdata/whois_action_idn_utf8.txt index 4107b6f72..ba424d476 100644 --- a/javatests/google/registry/whois/testdata/whois_action_idn_utf8.txt +++ b/javatests/google/registry/whois/testdata/whois_action_idn_utf8.txt @@ -13,39 +13,9 @@ Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibit Domain Status: clientRenewProhibited https://icann.org/epp#clientRenewProhibited Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited -Registry Registrant ID: 4-ROID -Registrant Name: (◕‿◕) Registrant Organization: GOOGLE INCORPORATED <script> -Registrant Street: 123 Example Boulevard <script> -Registrant City: KOKOMO Registrant State/Province: BM -Registrant Postal Code: 31337 Registrant Country: US -Registrant Phone: +1.2126660420 -Registrant Fax: +1.2126660420 -Registrant Email: lol@cat.みんな -Registry Admin ID: 5-ROID -Admin Name: Santa Claus -Admin Organization: GOOGLE INCORPORATED <script> -Admin Street: 123 Example Boulevard <script> -Admin City: KOKOMO -Admin State/Province: BM -Admin Postal Code: 31337 -Admin Country: US -Admin Phone: +1.2126660420 -Admin Fax: +1.2126660420 -Admin Email: BOFH@cat.みんな -Registry Tech ID: 6-ROID -Tech Name: The Raven -Tech Organization: GOOGLE INCORPORATED <script> -Tech Street: 123 Example Boulevard <script> -Tech City: KOKOMO -Tech State/Province: BM -Tech Postal Code: 31337 -Tech Country: US -Tech Phone: +1.2126660420 -Tech Fax: +1.2126660420 -Tech Email: bog@cat.みんな Name Server: ns1.cat.みんな Name Server: ns2.cat.みんな DNSSEC: signedDelegation diff --git a/javatests/google/registry/whois/testdata/whois_domain.txt b/javatests/google/registry/whois/testdata/whois_domain.txt index c9f29be5a..3fc1de59e 100644 --- a/javatests/google/registry/whois/testdata/whois_domain.txt +++ b/javatests/google/registry/whois/testdata/whois_domain.txt @@ -15,44 +15,9 @@ Domain Status: clientRenewProhibited https://icann.org/epp#clientRenewProhibited Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited Domain Status: transferPeriod https://icann.org/epp#transferPeriod -Registry Registrant ID: 4-TLD -Registrant Name: EXAMPLE REGISTRANT Registrant Organization: EXAMPLE ORGANIZATION -Registrant Street: 123 EXAMPLE STREET -Registrant City: ANYTOWN Registrant State/Province: AP -Registrant Postal Code: A1A1A1 Registrant Country: EX -Registrant Phone: +1.5555551212 -Registrant Phone Ext: 1234 -Registrant Fax: +1.5555551213 -Registrant Fax Ext: 4321 -Registrant Email: EMAIL@EXAMPLE.tld -Registry Admin ID: 5-TLD -Admin Name: EXAMPLE REGISTRANT ADMINISTRATIVE -Admin Organization: EXAMPLE REGISTRANT ORGANIZATION -Admin Street: 123 EXAMPLE STREET -Admin City: ANYTOWN -Admin State/Province: AP -Admin Postal Code: A1A1A1 -Admin Country: EX -Admin Phone: +1.5555551212 -Admin Phone Ext: 1234 -Admin Fax: +1.5555551213 -Admin Email: EMAIL@EXAMPLE.tld -Registry Tech ID: 6-TLD -Tech Name: EXAMPLE REGISTRAR TECHNICAL -Tech Organization: EXAMPLE REGISTRAR LLC -Tech Street: 123 EXAMPLE STREET -Tech City: ANYTOWN -Tech State/Province: AP -Tech Postal Code: A1A1A1 -Tech Country: EX -Tech Phone: +1.1235551234 -Tech Phone Ext: 1234 -Tech Fax: +1.5555551213 -Tech Fax Ext: 93 -Tech Email: EMAIL@EXAMPLE.tld Name Server: ns01.exampleregistrar.tld Name Server: ns02.exampleregistrar.tld DNSSEC: signedDelegation