RDAP: Add registrar entity for domains

The RDAP Pilot Program operational profile document indicates that domain
responses should list, in addition to their normal contacts, a special entity
for the registrar.

1.5.12.  The domain object in the RDAP response MUST contain an entity with the registrar role (called registrar entity in this section). The handle of the entity MUST be equal to the IANA Registrar ID. A valid fn member MUST be present in the registrar entity. Other members MAY be present in the entity (as specified in RFC6350, the vCard Format Specification and its corresponding JSON mapping RFC7095). Contracted parties MUST include an entity with the abuse role (called Abuse Entity in this section) within the registrar entity. The Abuse Entity MUST include tel and email members, and MAY include other members.
1.5.13.  The entity with the registrar role in the RDAP response MUST contain a publicIDs member [RFC7483] to identify the IANA Registrar ID from the IANA’s Registrar ID registry (https://www.iana.org/assignments/registrar-ids/registrar-ids.xhtml). The type value of the publicID object MUST be equal to IANA Registrar ID.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=186797360
This commit is contained in:
mountford 2018-02-23 11:26:06 -08:00 committed by jianglai
parent a898413c8c
commit 21313bffda
9 changed files with 650 additions and 5 deletions

View file

@ -543,6 +543,14 @@ public class RdapJsonFormatter {
outputDataType,
authorization))
.collect(toImmutableList());
entities =
addRegistrarEntity(
entities,
domainResource.getCurrentSponsorClientId(),
linkBase,
whoisServer,
now,
outputDataType);
if (!entities.isEmpty()) {
jsonBuilder.put("entities", entities);
}
@ -574,6 +582,38 @@ public class RdapJsonFormatter {
return jsonBuilder.build();
}
/**
* Adds a JSON object for the desired registrar to an existing array of JSON objects.
*
* @param clientId the registrar client ID
* @param linkBase the URL base to be used when creating links
* @param whoisServer the fully-qualified domain name of the WHOIS server to be listed in the
* port43 field; if null, port43 is not added to the object
* @param now the as-date
* @param outputDataType whether to generate full or summary data
*/
ImmutableList<ImmutableMap<String, Object>> addRegistrarEntity(
ImmutableList<ImmutableMap<String, Object>> entities,
@Nullable String clientId,
@Nullable String linkBase,
@Nullable String whoisServer,
DateTime now,
OutputDataType outputDataType) {
if (clientId == null) {
return entities;
}
Optional<Registrar> registrar = Registrar.loadByClientIdCached(clientId);
if (!registrar.isPresent()) {
return entities;
}
ImmutableList.Builder<ImmutableMap<String, Object>> builder = new ImmutableList.Builder<>();
builder.addAll(entities);
builder.add(
makeRdapJsonForRegistrar(
registrar.get(), false /* isTopLevel */, linkBase, whoisServer, now, outputDataType));
return builder.build();
}
/**
* Creates a JSON object for a {@link HostResource}.
*