mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Link the Registrar's RDAP server from RDAP domain replies
To do this we add a field of "rdapServers" in the Registrar object. Currently, we can only set this field manually, but a subsequent CL will add a cron-job to read these values from the ICANN servers. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=252438618
This commit is contained in:
parent
7c64992c73
commit
4110cae814
14 changed files with 186 additions and 30 deletions
|
@ -66,7 +66,6 @@ import google.registry.rdap.RdapObjectClasses.SecureDns;
|
|||
import google.registry.rdap.RdapObjectClasses.Vcard;
|
||||
import google.registry.rdap.RdapObjectClasses.VcardArray;
|
||||
import google.registry.request.FullServletPath;
|
||||
import google.registry.request.HttpException.InternalServerErrorException;
|
||||
import google.registry.util.Clock;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.Inet6Address;
|
||||
|
@ -301,11 +300,25 @@ public class RdapJsonFormatter {
|
|||
// The domain object in the RDAP response MUST contain an entity with the Registrar role.
|
||||
//
|
||||
// See {@link createRdapRegistrarEntity} for details of section 2.4 conformance
|
||||
builder
|
||||
.entitiesBuilder()
|
||||
.add(
|
||||
createRdapRegistrarEntity(
|
||||
domainBase.getCurrentSponsorClientId(), OutputDataType.INTERNAL));
|
||||
Registrar registrar =
|
||||
Registrar.loadRequiredRegistrarCached(domainBase.getCurrentSponsorClientId());
|
||||
builder.entitiesBuilder().add(createRdapRegistrarEntity(registrar, OutputDataType.INTERNAL));
|
||||
// RDAP Technical Implementation Guide 3.2: must have link to the registrar's RDAP URL for this
|
||||
// domain, with rel=related.
|
||||
for (String registrarRdapBase : registrar.getRdapBaseUrls()) {
|
||||
String href =
|
||||
makeServerRelativeUrl(
|
||||
registrarRdapBase, "domain", domainBase.getFullyQualifiedDomainName());
|
||||
builder
|
||||
.linksBuilder()
|
||||
.add(
|
||||
Link.builder()
|
||||
.setHref(href)
|
||||
.setValue(href)
|
||||
.setRel("related")
|
||||
.setType("application/rdap+json")
|
||||
.build());
|
||||
}
|
||||
// RDAP Response Profile 2.6.1: must have at least one status member
|
||||
// makeStatusValueList should in theory always contain one of either "active" or "inactive".
|
||||
ImmutableSet<RdapStatus> status =
|
||||
|
@ -443,11 +456,9 @@ public class RdapJsonFormatter {
|
|||
|
||||
// RDAP Response Profile 4.3 - Registrar member is optional, so we only set it for FULL
|
||||
if (outputDataType == OutputDataType.FULL) {
|
||||
builder
|
||||
.entitiesBuilder()
|
||||
.add(
|
||||
createRdapRegistrarEntity(
|
||||
hostResource.getPersistedCurrentSponsorClientId(), OutputDataType.INTERNAL));
|
||||
Registrar registrar =
|
||||
Registrar.loadRequiredRegistrarCached(hostResource.getPersistedCurrentSponsorClientId());
|
||||
builder.entitiesBuilder().add(createRdapRegistrarEntity(registrar, OutputDataType.INTERNAL));
|
||||
}
|
||||
if (outputDataType != OutputDataType.INTERNAL) {
|
||||
// Rdap Response Profile 4.4, must have "last update of RDAP database" response. But this is
|
||||
|
@ -747,21 +758,6 @@ public class RdapJsonFormatter {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a JSON object for the desired registrar to an existing list of JSON objects.
|
||||
*
|
||||
* @param clientId the registrar client ID
|
||||
* @param outputDataType whether to generate FULL, SUMMARY, or INTERNAL data.
|
||||
*/
|
||||
RdapRegistrarEntity createRdapRegistrarEntity(String clientId, OutputDataType outputDataType) {
|
||||
Optional<Registrar> registrar = Registrar.loadByClientIdCached(clientId);
|
||||
if (!registrar.isPresent()) {
|
||||
throw new InternalServerErrorException(
|
||||
String.format("Couldn't find registrar '%s'", clientId));
|
||||
}
|
||||
return createRdapRegistrarEntity(registrar.get(), outputDataType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a JSON object for a {@link RegistrarContact}.
|
||||
*
|
||||
|
@ -1059,11 +1055,18 @@ public class RdapJsonFormatter {
|
|||
* Create a link relative to the RDAP server endpoint.
|
||||
*/
|
||||
String makeRdapServletRelativeUrl(String part, String... moreParts) {
|
||||
return makeServerRelativeUrl(fullServletPath, part, moreParts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a link relative to some base server
|
||||
*/
|
||||
static String makeServerRelativeUrl(String baseServer, String part, String... moreParts) {
|
||||
String relativePath = Paths.get(part, moreParts).toString();
|
||||
if (fullServletPath.endsWith("/")) {
|
||||
return fullServletPath + relativePath;
|
||||
if (baseServer.endsWith("/")) {
|
||||
return baseServer + relativePath;
|
||||
}
|
||||
return fullServletPath + "/" + relativePath;
|
||||
return baseServer + "/" + relativePath;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue