Change redacted output for domain whois query

The redacted text for the email field displays a longer prompt to
contact the registrar, per the request filed at b/123573370.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=232716133
This commit is contained in:
jianglai 2019-02-06 11:50:37 -08:00
parent 6a6c7e3b09
commit 7fe16689d8
18 changed files with 81 additions and 38 deletions

View file

@ -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.
*

View file

@ -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;

View file

@ -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,

View file

@ -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<WhoisResponse> 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));
}
}

View file

@ -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;
}

View file

@ -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);
}
/**

View file

@ -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.