diff --git a/java/google/registry/config/RegistryConfig.java b/java/google/registry/config/RegistryConfig.java index ae5805994..afc6b4516 100644 --- a/java/google/registry/config/RegistryConfig.java +++ b/java/google/registry/config/RegistryConfig.java @@ -980,6 +980,17 @@ public final class RegistryConfig { return null; } + /** + * Redaction text for email address in WHOIS + * + * @see google.registry.whois.WhoisResponse + */ + @Provides + @Config("whoisRedactedEmailText") + public static String provideWhoisRedactedEmailText(RegistryConfigSettings config) { + return config.registryPolicy.whoisRedactedEmailText; + } + /** * Disclaimer displayed at the end of WHOIS query results. * diff --git a/java/google/registry/config/RegistryConfigSettings.java b/java/google/registry/config/RegistryConfigSettings.java index dbbf4ffc4..c7b7c1c8e 100644 --- a/java/google/registry/config/RegistryConfigSettings.java +++ b/java/google/registry/config/RegistryConfigSettings.java @@ -89,6 +89,7 @@ public class RegistryConfigSettings { public String registryAdminClientId; public String premiumTermsExportDisclaimer; public String reservedTermsExportDisclaimer; + public String whoisRedactedEmailText; public String whoisDisclaimer; public String rdapTos; public String rdapTosStaticUrl; diff --git a/java/google/registry/config/files/default-config.yaml b/java/google/registry/config/files/default-config.yaml index 8062689a5..e6a4c0f8b 100644 --- a/java/google/registry/config/files/default-config.yaml +++ b/java/google/registry/config/files/default-config.yaml @@ -104,6 +104,12 @@ registryPolicy: to publish. This list is subject to change. The most up-to-date source is always the registry itself, by sending domain check EPP commands. + # Redaction text for email address in WHOIS + whoisRedactedEmailText: | + Please query the WHOIS server of the owning registrar identified in this + output for information on how to contact the Registrant, Admin, or Tech + contact of the queried domain name. + # Disclaimer at the top of WHOIS results. whoisDisclaimer: | WHOIS information is provided by the registry solely for query-based, diff --git a/java/google/registry/whois/DomainLookupCommand.java b/java/google/registry/whois/DomainLookupCommand.java index 3aafb405b..57e2a5680 100644 --- a/java/google/registry/whois/DomainLookupCommand.java +++ b/java/google/registry/whois/DomainLookupCommand.java @@ -25,15 +25,20 @@ import org.joda.time.DateTime; public class DomainLookupCommand extends DomainOrHostLookupCommand { private final boolean fullOutput; + private final String whoisRedactedEmailText; - public DomainLookupCommand(InternetDomainName domainName, boolean fullOutput) { + public DomainLookupCommand( + InternetDomainName domainName, + boolean fullOutput, + String whoisRedactedEmailText) { super(domainName, "Domain"); this.fullOutput = fullOutput; + this.whoisRedactedEmailText = whoisRedactedEmailText; } @Override protected Optional getResponse(InternetDomainName domainName, DateTime now) { return loadByForeignKeyCached(DomainBase.class, domainName.toString(), now) - .map(domain -> new DomainWhoisResponse(domain, fullOutput, now)); + .map(domain -> new DomainWhoisResponse(domain, fullOutput, whoisRedactedEmailText, now)); } } diff --git a/java/google/registry/whois/DomainWhoisResponse.java b/java/google/registry/whois/DomainWhoisResponse.java index a0b4663fd..99023fb68 100644 --- a/java/google/registry/whois/DomainWhoisResponse.java +++ b/java/google/registry/whois/DomainWhoisResponse.java @@ -59,11 +59,16 @@ final class DomainWhoisResponse extends WhoisResponseImpl { /** Whether the full WHOIS output is to be displayed. */ private final boolean fullOutput; - /** Creates new WHOIS domain response on the given domain. */ - DomainWhoisResponse(DomainBase domain, boolean fullOutput, DateTime timestamp) { + /** When fullOutput is false, the text to display for the registrant's email fields. */ + private final String whoisRedactedEmailText; + + /** Creates new WHOIS domain response on the given domain. */ + DomainWhoisResponse( + DomainBase domain, boolean fullOutput, String whoisRedactedEmailText, DateTime timestamp) { super(timestamp); this.domain = checkNotNull(domain, "domain"); this.fullOutput = fullOutput; + this.whoisRedactedEmailText = whoisRedactedEmailText; } @Override @@ -176,8 +181,9 @@ final class DomainWhoisResponse extends WhoisResponseImpl { } emitPhone(contactType, "Phone", contactResource.getVoiceNumber()); emitPhone(contactType, "Fax", contactResource.getFaxNumber()); - emitField( - ImmutableList.of(contactType, "Email"), contactResource.getEmailAddress(), fullOutput); + String emailFieldContent = + fullOutput ? contactResource.getEmailAddress() : whoisRedactedEmailText; + emitField(ImmutableList.of(contactType, "Email"), emailFieldContent); return this; } diff --git a/java/google/registry/whois/WhoisCommandFactory.java b/java/google/registry/whois/WhoisCommandFactory.java index b5085396b..f511a72e3 100644 --- a/java/google/registry/whois/WhoisCommandFactory.java +++ b/java/google/registry/whois/WhoisCommandFactory.java @@ -27,8 +27,9 @@ import java.net.InetAddress; public class WhoisCommandFactory { /** Returns a new {@link WhoisCommand} to perform a domain lookup on the specified domain name. */ - public WhoisCommand domainLookup(InternetDomainName domainName, boolean fullOutput) { - return new DomainLookupCommand(domainName, fullOutput); + public WhoisCommand domainLookup( + InternetDomainName domainName, boolean fullOutput, String whoisRedactedEmailText) { + return new DomainLookupCommand(domainName, fullOutput, whoisRedactedEmailText); } /** diff --git a/java/google/registry/whois/WhoisReader.java b/java/google/registry/whois/WhoisReader.java index 62c05b3e6..218d60891 100644 --- a/java/google/registry/whois/WhoisReader.java +++ b/java/google/registry/whois/WhoisReader.java @@ -74,11 +74,15 @@ class WhoisReader { static final String REGISTRAR_LOOKUP_COMMAND = "registrar"; private final WhoisCommandFactory commandFactory; + private final String whoisRedactedEmailText; /** Creates a new WhoisReader that extracts its command from the specified Reader. */ @Inject - WhoisReader(@Config("whoisCommandFactory") WhoisCommandFactory commandFactory) { + WhoisReader( + @Config("whoisCommandFactory") WhoisCommandFactory commandFactory, + @Config("whoisRedactedEmailText") String whoisRedactedEmailText) { this.commandFactory = commandFactory; + this.whoisRedactedEmailText = whoisRedactedEmailText; } /** @@ -117,7 +121,9 @@ class WhoisReader { try { logger.atInfo().log("Attempting domain lookup command using domain name %s", tokens.get(1)); return commandFactory.domainLookup( - InternetDomainName.from(canonicalizeDomainName(tokens.get(1))), fullOutput); + InternetDomainName.from(canonicalizeDomainName(tokens.get(1))), + fullOutput, + whoisRedactedEmailText); } catch (IllegalArgumentException iae) { // If we can't interpret the argument as a host name, then return an error. throw new WhoisException(now, SC_BAD_REQUEST, String.format( @@ -195,7 +201,7 @@ class WhoisReader { // (SLD) and we should do a domain lookup on it. if (targetName.parent().equals(tld.get())) { logger.atInfo().log("Attempting domain lookup using %s as a domain name", targetName); - return commandFactory.domainLookup(targetName, fullOutput); + return commandFactory.domainLookup(targetName, fullOutput, whoisRedactedEmailText); } // The target is more than one level above the TLD, so we'll assume it's a nameserver. diff --git a/javatests/google/registry/whois/DomainWhoisResponseTest.java b/javatests/google/registry/whois/DomainWhoisResponseTest.java index bbf08984a..a8fca922b 100644 --- a/javatests/google/registry/whois/DomainWhoisResponseTest.java +++ b/javatests/google/registry/whois/DomainWhoisResponseTest.java @@ -256,7 +256,7 @@ public class DomainWhoisResponseTest { @Test public void getPlainTextOutputTest() { DomainWhoisResponse domainWhoisResponse = - new DomainWhoisResponse(domainBase, false, clock.nowUtc()); + new DomainWhoisResponse(domainBase, false, "Please contact registrar", clock.nowUtc()); assertThat( domainWhoisResponse.getResponse( false, @@ -268,8 +268,9 @@ public class DomainWhoisResponseTest { public void getPlainTextOutputTest_registrarAbuseInfoMissing() { persistResource(abuseContact.asBuilder().setVisibleInDomainWhoisAsAbuse(false).build()); DomainWhoisResponse domainWhoisResponse = - new DomainWhoisResponse(domainBase, false, clock.nowUtc()); - assertThat(domainWhoisResponse.getResponse(false, "Footer")) + new DomainWhoisResponse(domainBase, false, "Please contact registrar", clock.nowUtc()); + assertThat( + domainWhoisResponse.getResponse(false, "Footer")) .isEqualTo( WhoisResponseResults.create( loadFile("whois_domain_registrar_abuse_info_missing.txt"), 1)); @@ -278,7 +279,7 @@ public class DomainWhoisResponseTest { @Test public void getPlainTextOutputTest_fullOutput() { DomainWhoisResponse domainWhoisResponse = - new DomainWhoisResponse(domainBase, true, clock.nowUtc()); + new DomainWhoisResponse(domainBase, true, "Please contact registrar", clock.nowUtc()); assertThat( domainWhoisResponse.getResponse( false, @@ -290,7 +291,10 @@ public class DomainWhoisResponseTest { public void addImplicitOkStatusTest() { DomainWhoisResponse domainWhoisResponse = new DomainWhoisResponse( - domainBase.asBuilder().setStatusValues(null).build(), false, clock.nowUtc()); + domainBase.asBuilder().setStatusValues(null).build(), + false, + "Contact the registrar", + clock.nowUtc()); assertThat( domainWhoisResponse .getResponse( diff --git a/javatests/google/registry/whois/RegistrarWhoisResponseTest.java b/javatests/google/registry/whois/RegistrarWhoisResponseTest.java index 96ca97574..c5931df2a 100644 --- a/javatests/google/registry/whois/RegistrarWhoisResponseTest.java +++ b/javatests/google/registry/whois/RegistrarWhoisResponseTest.java @@ -131,6 +131,7 @@ public class RegistrarWhoisResponseTest { new RegistrarWhoisResponse(registrar, clock.nowUtc()); // Just make sure this doesn't NPE. registrarWhoisResponse.getResponse( - false, "Doodle Disclaimer\nI exist so that carriage return\nin disclaimer can be tested."); + false, + "Doodle Disclaimer\nI exist so that carriage return\nin disclaimer can be tested."); } } diff --git a/javatests/google/registry/whois/WhoisActionTest.java b/javatests/google/registry/whois/WhoisActionTest.java index 007634d86..fc5df1eae 100644 --- a/javatests/google/registry/whois/WhoisActionTest.java +++ b/javatests/google/registry/whois/WhoisActionTest.java @@ -95,7 +95,8 @@ public class WhoisActionTest { whoisAction.clock = clock; whoisAction.input = new StringReader(input); whoisAction.response = response; - whoisAction.whoisReader = new WhoisReader(new WhoisCommandFactory()); + whoisAction.whoisReader = + new WhoisReader(new WhoisCommandFactory(), "Please contact registrar"); whoisAction.whoisMetrics = new WhoisMetrics(); whoisAction.metricBuilder = WhoisMetric.builderForRequest(clock); whoisAction.disclaimer = diff --git a/javatests/google/registry/whois/WhoisHttpActionTest.java b/javatests/google/registry/whois/WhoisHttpActionTest.java index c6ed75c00..801e87ace 100644 --- a/javatests/google/registry/whois/WhoisHttpActionTest.java +++ b/javatests/google/registry/whois/WhoisHttpActionTest.java @@ -77,7 +77,8 @@ public class WhoisHttpActionTest { whoisAction.expires = Duration.standardHours(1); whoisAction.requestPath = WhoisHttpAction.PATH + pathInfo; whoisAction.response = response; - whoisAction.whoisReader = new WhoisReader(new WhoisCommandFactory()); + whoisAction.whoisReader = + new WhoisReader(new WhoisCommandFactory(), "Please contact registrar"); whoisAction.whoisMetrics = new WhoisMetrics(); whoisAction.metricBuilder = WhoisMetric.builderForRequest(clock); whoisAction.disclaimer = diff --git a/javatests/google/registry/whois/WhoisReaderTest.java b/javatests/google/registry/whois/WhoisReaderTest.java index 22ef11ea7..751cbfda8 100644 --- a/javatests/google/registry/whois/WhoisReaderTest.java +++ b/javatests/google/registry/whois/WhoisReaderTest.java @@ -48,7 +48,7 @@ public class WhoisReaderTest { @SuppressWarnings({"TypeParameterUnusedInFormals", "unchecked"}) T readCommand(String commandStr) throws Exception { return (T) - new WhoisReader(new WhoisCommandFactory()) + new WhoisReader(new WhoisCommandFactory(), "Please contact registrar") .readCommand(new StringReader(commandStr), false, clock.nowUtc()); } diff --git a/javatests/google/registry/whois/testdata/whois_action_domain.txt b/javatests/google/registry/whois/testdata/whois_action_domain.txt index 5304f7c79..af0f70a73 100644 --- a/javatests/google/registry/whois/testdata/whois_action_domain.txt +++ b/javatests/google/registry/whois/testdata/whois_action_domain.txt @@ -23,7 +23,7 @@ Registrant Postal Code: REDACTED FOR PRIVACY Registrant Country: US Registrant Phone: REDACTED FOR PRIVACY Registrant Fax: REDACTED FOR PRIVACY -Registrant Email: REDACTED FOR PRIVACY +Registrant Email: Please contact registrar Registry Admin ID: REDACTED FOR PRIVACY Admin Name: REDACTED FOR PRIVACY Admin Organization: REDACTED FOR PRIVACY @@ -34,7 +34,7 @@ Admin Postal Code: REDACTED FOR PRIVACY Admin Country: REDACTED FOR PRIVACY Admin Phone: REDACTED FOR PRIVACY Admin Fax: REDACTED FOR PRIVACY -Admin Email: REDACTED FOR PRIVACY +Admin Email: Please contact registrar Registry Tech ID: REDACTED FOR PRIVACY Tech Name: REDACTED FOR PRIVACY Tech Organization: REDACTED FOR PRIVACY @@ -45,7 +45,7 @@ Tech Postal Code: REDACTED FOR PRIVACY Tech Country: REDACTED FOR PRIVACY Tech Phone: REDACTED FOR PRIVACY Tech Fax: REDACTED FOR PRIVACY -Tech Email: REDACTED FOR PRIVACY +Tech Email: Please contact registrar 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 d149ea2d4..050e89aee 100644 --- a/javatests/google/registry/whois/testdata/whois_action_idn_punycode.txt +++ b/javatests/google/registry/whois/testdata/whois_action_idn_punycode.txt @@ -23,7 +23,7 @@ Registrant Postal Code: REDACTED FOR PRIVACY Registrant Country: US Registrant Phone: REDACTED FOR PRIVACY Registrant Fax: REDACTED FOR PRIVACY -Registrant Email: REDACTED FOR PRIVACY +Registrant Email: Please contact registrar Registry Admin ID: REDACTED FOR PRIVACY Admin Name: REDACTED FOR PRIVACY Admin Organization: REDACTED FOR PRIVACY @@ -34,7 +34,7 @@ Admin Postal Code: REDACTED FOR PRIVACY Admin Country: REDACTED FOR PRIVACY Admin Phone: REDACTED FOR PRIVACY Admin Fax: REDACTED FOR PRIVACY -Admin Email: REDACTED FOR PRIVACY +Admin Email: Please contact registrar Registry Tech ID: REDACTED FOR PRIVACY Tech Name: REDACTED FOR PRIVACY Tech Organization: REDACTED FOR PRIVACY @@ -45,7 +45,7 @@ Tech Postal Code: REDACTED FOR PRIVACY Tech Country: REDACTED FOR PRIVACY Tech Phone: REDACTED FOR PRIVACY Tech Fax: REDACTED FOR PRIVACY -Tech Email: REDACTED FOR PRIVACY +Tech Email: Please contact registrar 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 940449b9f..eae7e3935 100644 --- a/javatests/google/registry/whois/testdata/whois_action_idn_utf8.txt +++ b/javatests/google/registry/whois/testdata/whois_action_idn_utf8.txt @@ -23,7 +23,7 @@ Registrant Postal Code: REDACTED FOR PRIVACY Registrant Country: US Registrant Phone: REDACTED FOR PRIVACY Registrant Fax: REDACTED FOR PRIVACY -Registrant Email: REDACTED FOR PRIVACY +Registrant Email: Please contact registrar Registry Admin ID: REDACTED FOR PRIVACY Admin Name: REDACTED FOR PRIVACY Admin Organization: REDACTED FOR PRIVACY @@ -34,7 +34,7 @@ Admin Postal Code: REDACTED FOR PRIVACY Admin Country: REDACTED FOR PRIVACY Admin Phone: REDACTED FOR PRIVACY Admin Fax: REDACTED FOR PRIVACY -Admin Email: REDACTED FOR PRIVACY +Admin Email: Please contact registrar Registry Tech ID: REDACTED FOR PRIVACY Tech Name: REDACTED FOR PRIVACY Tech Organization: REDACTED FOR PRIVACY @@ -45,7 +45,7 @@ Tech Postal Code: REDACTED FOR PRIVACY Tech Country: REDACTED FOR PRIVACY Tech Phone: REDACTED FOR PRIVACY Tech Fax: REDACTED FOR PRIVACY -Tech Email: REDACTED FOR PRIVACY +Tech Email: Please contact registrar Name Server: ns1.cat.みんな Name Server: ns2.cat.みんな DNSSEC: signedDelegation diff --git a/javatests/google/registry/whois/testdata/whois_action_transferred_domain.txt b/javatests/google/registry/whois/testdata/whois_action_transferred_domain.txt index ab86d749b..5fea610e1 100644 --- a/javatests/google/registry/whois/testdata/whois_action_transferred_domain.txt +++ b/javatests/google/registry/whois/testdata/whois_action_transferred_domain.txt @@ -23,7 +23,7 @@ Registrant Postal Code: REDACTED FOR PRIVACY Registrant Country: US Registrant Phone: REDACTED FOR PRIVACY Registrant Fax: REDACTED FOR PRIVACY -Registrant Email: REDACTED FOR PRIVACY +Registrant Email: Please contact registrar Registry Admin ID: REDACTED FOR PRIVACY Admin Name: REDACTED FOR PRIVACY Admin Organization: REDACTED FOR PRIVACY @@ -34,7 +34,7 @@ Admin Postal Code: REDACTED FOR PRIVACY Admin Country: REDACTED FOR PRIVACY Admin Phone: REDACTED FOR PRIVACY Admin Fax: REDACTED FOR PRIVACY -Admin Email: REDACTED FOR PRIVACY +Admin Email: Please contact registrar Registry Tech ID: REDACTED FOR PRIVACY Tech Name: REDACTED FOR PRIVACY Tech Organization: REDACTED FOR PRIVACY @@ -45,7 +45,7 @@ Tech Postal Code: REDACTED FOR PRIVACY Tech Country: REDACTED FOR PRIVACY Tech Phone: REDACTED FOR PRIVACY Tech Fax: REDACTED FOR PRIVACY -Tech Email: REDACTED FOR PRIVACY +Tech Email: Please contact registrar Name Server: ns1.cat.lol Name Server: ns2.cat.lol DNSSEC: signedDelegation diff --git a/javatests/google/registry/whois/testdata/whois_domain.txt b/javatests/google/registry/whois/testdata/whois_domain.txt index 688605547..53a48b82b 100644 --- a/javatests/google/registry/whois/testdata/whois_domain.txt +++ b/javatests/google/registry/whois/testdata/whois_domain.txt @@ -27,7 +27,7 @@ Registrant Phone: REDACTED FOR PRIVACY Registrant Phone Ext: REDACTED FOR PRIVACY Registrant Fax: REDACTED FOR PRIVACY Registrant Fax Ext: REDACTED FOR PRIVACY -Registrant Email: REDACTED FOR PRIVACY +Registrant Email: Please contact registrar Registry Admin ID: REDACTED FOR PRIVACY Admin Name: REDACTED FOR PRIVACY Admin Organization: REDACTED FOR PRIVACY @@ -39,7 +39,7 @@ Admin Country: REDACTED FOR PRIVACY Admin Phone: REDACTED FOR PRIVACY Admin Phone Ext: REDACTED FOR PRIVACY Admin Fax: REDACTED FOR PRIVACY -Admin Email: REDACTED FOR PRIVACY +Admin Email: Please contact registrar Registry Tech ID: REDACTED FOR PRIVACY Tech Name: REDACTED FOR PRIVACY Tech Organization: REDACTED FOR PRIVACY @@ -52,7 +52,7 @@ Tech Phone: REDACTED FOR PRIVACY Tech Phone Ext: REDACTED FOR PRIVACY Tech Fax: REDACTED FOR PRIVACY Tech Fax Ext: REDACTED FOR PRIVACY -Tech Email: REDACTED FOR PRIVACY +Tech Email: Please contact registrar Name Server: ns01.exampleregistrar.tld Name Server: ns02.exampleregistrar.tld DNSSEC: signedDelegation diff --git a/javatests/google/registry/whois/testdata/whois_domain_registrar_abuse_info_missing.txt b/javatests/google/registry/whois/testdata/whois_domain_registrar_abuse_info_missing.txt index 4537d3048..71abbf50e 100644 --- a/javatests/google/registry/whois/testdata/whois_domain_registrar_abuse_info_missing.txt +++ b/javatests/google/registry/whois/testdata/whois_domain_registrar_abuse_info_missing.txt @@ -27,7 +27,7 @@ Registrant Phone: REDACTED FOR PRIVACY Registrant Phone Ext: REDACTED FOR PRIVACY Registrant Fax: REDACTED FOR PRIVACY Registrant Fax Ext: REDACTED FOR PRIVACY -Registrant Email: REDACTED FOR PRIVACY +Registrant Email: Please contact registrar Registry Admin ID: REDACTED FOR PRIVACY Admin Name: REDACTED FOR PRIVACY Admin Organization: REDACTED FOR PRIVACY @@ -39,7 +39,7 @@ Admin Country: REDACTED FOR PRIVACY Admin Phone: REDACTED FOR PRIVACY Admin Phone Ext: REDACTED FOR PRIVACY Admin Fax: REDACTED FOR PRIVACY -Admin Email: REDACTED FOR PRIVACY +Admin Email: Please contact registrar Registry Tech ID: REDACTED FOR PRIVACY Tech Name: REDACTED FOR PRIVACY Tech Organization: REDACTED FOR PRIVACY @@ -52,7 +52,7 @@ Tech Phone: REDACTED FOR PRIVACY Tech Phone Ext: REDACTED FOR PRIVACY Tech Fax: REDACTED FOR PRIVACY Tech Fax Ext: REDACTED FOR PRIVACY -Tech Email: REDACTED FOR PRIVACY +Tech Email: Please contact registrar Name Server: ns01.exampleregistrar.tld Name Server: ns02.exampleregistrar.tld DNSSEC: signedDelegation