RDAP: Show registrar entity even if contacts are redacted

Even when the request is not permissioned to see contact information, we should
show information about the owning registrar.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187049833
This commit is contained in:
mountford 2018-02-26 11:08:59 -08:00 committed by jianglai
parent 6a994f320f
commit 247339cfd5
6 changed files with 412 additions and 31 deletions

View file

@ -522,10 +522,13 @@ public class RdapJsonFormatter {
Map<Key<HostResource>, HostResource> loadedHosts = Map<Key<HostResource>, HostResource> loadedHosts =
ofy().load().keys(domainResource.getNameservers()); ofy().load().keys(domainResource.getNameservers());
// Load the registrant and other contacts and add them to the data. // Load the registrant and other contacts and add them to the data.
if (displayContacts) { ImmutableList<ImmutableMap<String, Object>> entities;
if (!displayContacts) {
entities = ImmutableList.of();
} else {
Map<Key<ContactResource>, ContactResource> loadedContacts = Map<Key<ContactResource>, ContactResource> loadedContacts =
ofy().load().keys(domainResource.getReferencedContacts()); ofy().load().keys(domainResource.getReferencedContacts());
ImmutableList<ImmutableMap<String, Object>> entities = entities =
Streams.concat( Streams.concat(
domainResource.getContacts().stream(), domainResource.getContacts().stream(),
Stream.of( Stream.of(
@ -543,17 +546,17 @@ public class RdapJsonFormatter {
outputDataType, outputDataType,
authorization)) authorization))
.collect(toImmutableList()); .collect(toImmutableList());
entities = }
addRegistrarEntity( entities =
entities, addRegistrarEntity(
domainResource.getCurrentSponsorClientId(), entities,
linkBase, domainResource.getCurrentSponsorClientId(),
whoisServer, linkBase,
now, whoisServer,
outputDataType); now,
if (!entities.isEmpty()) { outputDataType);
jsonBuilder.put("entities", entities); if (!entities.isEmpty()) {
} jsonBuilder.put("entities", entities);
} }
// Add the nameservers to the data; the load was kicked off above for efficiency. // Add the nameservers to the data; the load was kicked off above for efficiency.
ImmutableList.Builder<Object> nsBuilder = new ImmutableList.Builder<>(); ImmutableList.Builder<Object> nsBuilder = new ImmutableList.Builder<>();

View file

@ -1022,7 +1022,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase {
"21-EXAMPLE", "21-EXAMPLE",
null, null,
ImmutableList.of("ns1.cat.lol", "ns2.external.tld"), ImmutableList.of("ns1.cat.lol", "ns2.external.tld"),
"Yes Virginia <script>", "St. John Chrysostom",
"rdap_domain_no_contacts_with_remark.json"); "rdap_domain_no_contacts_with_remark.json");
verifyMetrics(SearchType.BY_DOMAIN_NAME, Optional.of(1L)); verifyMetrics(SearchType.BY_DOMAIN_NAME, Optional.of(1L));
} }
@ -1037,7 +1037,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase {
"2D-Q9JYB4C", "2D-Q9JYB4C",
null, null,
ImmutableList.of("ns1.cat.xn--q9jyb4c", "ns2.cat.xn--q9jyb4c"), ImmutableList.of("ns1.cat.xn--q9jyb4c", "ns2.cat.xn--q9jyb4c"),
"Yes Virginia <script>", "みんな",
"rdap_domain_unicode_no_contacts_with_remark.json"); "rdap_domain_unicode_no_contacts_with_remark.json");
// The unicode gets translated to ASCII before getting parsed into a search pattern. // The unicode gets translated to ASCII before getting parsed into a search pattern.
metricPrefixLength = 15; metricPrefixLength = 15;
@ -1054,7 +1054,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase {
"2D-Q9JYB4C", "2D-Q9JYB4C",
null, null,
ImmutableList.of("ns1.cat.xn--q9jyb4c", "ns2.cat.xn--q9jyb4c"), ImmutableList.of("ns1.cat.xn--q9jyb4c", "ns2.cat.xn--q9jyb4c"),
"Yes Virginia <script>", "みんな",
"rdap_domain_unicode_no_contacts_with_remark.json"); "rdap_domain_unicode_no_contacts_with_remark.json");
verifyMetrics(SearchType.BY_DOMAIN_NAME, Optional.of(1L)); verifyMetrics(SearchType.BY_DOMAIN_NAME, Optional.of(1L));
} }
@ -1069,7 +1069,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase {
"39-1_TEST", "39-1_TEST",
ImmutableList.of("4-ROID", "6-ROID", "2-ROID"), ImmutableList.of("4-ROID", "6-ROID", "2-ROID"),
ImmutableList.of("ns1.cat.1.test", "ns2.cat.2.test"), ImmutableList.of("ns1.cat.1.test", "ns2.cat.2.test"),
"Yes Virginia <script>", "1.test",
"rdap_domain_no_contacts_with_remark.json"); "rdap_domain_no_contacts_with_remark.json");
verifyMetrics(SearchType.BY_DOMAIN_NAME, Optional.of(1L)); verifyMetrics(SearchType.BY_DOMAIN_NAME, Optional.of(1L));
} }
@ -1084,7 +1084,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase {
"39-1_TEST", "39-1_TEST",
ImmutableList.of("4-ROID", "6-ROID", "2-ROID"), ImmutableList.of("4-ROID", "6-ROID", "2-ROID"),
ImmutableList.of("ns1.cat.1.test", "ns2.cat.2.test"), ImmutableList.of("ns1.cat.1.test", "ns2.cat.2.test"),
"Yes Virginia <script>", "1.test",
"rdap_domain_no_contacts_with_remark.json"); "rdap_domain_no_contacts_with_remark.json");
verifyMetrics(SearchType.BY_DOMAIN_NAME, Optional.of(1L)); verifyMetrics(SearchType.BY_DOMAIN_NAME, Optional.of(1L));
} }
@ -1611,7 +1611,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase {
"2D-Q9JYB4C", "2D-Q9JYB4C",
null, null,
ImmutableList.of("ns1.cat.xn--q9jyb4c", "ns2.cat.xn--q9jyb4c"), ImmutableList.of("ns1.cat.xn--q9jyb4c", "ns2.cat.xn--q9jyb4c"),
"Yes Virginia <script>", "みんな",
"rdap_domain_unicode_no_contacts_with_remark.json"); "rdap_domain_unicode_no_contacts_with_remark.json");
verifyMetrics(SearchType.BY_NAMESERVER_NAME, 1, 1); verifyMetrics(SearchType.BY_NAMESERVER_NAME, 1, 1);
} }
@ -1626,7 +1626,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase {
"39-1_TEST", "39-1_TEST",
ImmutableList.of("4-ROID", "6-ROID", "2-ROID"), ImmutableList.of("4-ROID", "6-ROID", "2-ROID"),
ImmutableList.of("ns1.cat.1.test", "ns2.cat.2.test"), ImmutableList.of("ns1.cat.1.test", "ns2.cat.2.test"),
"Yes Virginia <script>", "1.test",
"rdap_domain_no_contacts_with_remark.json"); "rdap_domain_no_contacts_with_remark.json");
verifyMetrics(SearchType.BY_NAMESERVER_NAME, 1, 1); verifyMetrics(SearchType.BY_NAMESERVER_NAME, 1, 1);
} }
@ -1641,7 +1641,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase {
"39-1_TEST", "39-1_TEST",
ImmutableList.of("4-ROID", "6-ROID", "2-ROID"), ImmutableList.of("4-ROID", "6-ROID", "2-ROID"),
ImmutableList.of("ns1.cat.1.test", "ns2.cat.2.test"), ImmutableList.of("ns1.cat.1.test", "ns2.cat.2.test"),
"Yes Virginia <script>", "1.test",
"rdap_domain_no_contacts_with_remark.json"); "rdap_domain_no_contacts_with_remark.json");
verifyMetrics(SearchType.BY_NAMESERVER_NAME, 1, 1); verifyMetrics(SearchType.BY_NAMESERVER_NAME, 1, 1);
} }

View file

@ -1,11 +1,13 @@
{ {
"objectClassName": "domain",
"handle": "%HANDLE%",
"ldhName": "%NAME%",
"status": [ "status": [
"client delete prohibited", "client delete prohibited",
"client renew prohibited", "client renew prohibited",
"client transfer prohibited", "client transfer prohibited",
"server update prohibited" "server update prohibited"
], ],
"handle": "%HANDLE%",
"links": [ "links": [
{ {
"href": "https://example.com/rdap/domain/%NAME%", "href": "https://example.com/rdap/domain/%NAME%",
@ -101,6 +103,94 @@
"objectClassName": "nameserver" "objectClassName": "nameserver"
} }
], ],
"ldhName": "%NAME%", "entities": [
"objectClassName": "domain" {
"objectClassName" : "entity",
"handle" : "1",
"status" : ["active"],
"roles" : ["registrar"],
"links" :
[
{
"value" : "https://example.com/rdap/entity/1",
"rel" : "self",
"href" : "https://example.com/rdap/entity/1",
"type" : "application/rdap+json"
}
],
"events" :
[
{
"eventAction": "registration",
"eventActor": "1",
"eventDate": "2000-01-01T00:00:00.000Z"
},
{
"eventAction": "last update of RDAP database",
"eventDate": "2000-01-01T00:00:00.000Z"
}
],
"publicIds" :
[
{
"type" : "IANA Registrar ID",
"identifier" : "1"
}
],
"vcardArray" :
[
"vcard",
[
["version", {}, "text", "4.0"],
["fn", {}, "text", "%REGISTRARNAME%"],
["adr", {}, "text", [
"",
"",
"123 Example Boulevard <script>",
"Williamsburg <script>",
"NY",
"11211",
"United States"]],
["tel", {"type" : ["voice"]}, "uri", "tel:+1.2125551212"],
["tel", {"type" : ["fax"]}, "uri", "tel:+1.2125551213"],
["email", {}, "text", "contact-us@example.com"]
]
],
"entities" :
[
{
"objectClassName" : "entity",
"status" : ["active"],
"roles" : ["administrative"],
"vcardArray" :
[
"vcard",
[
["version", {}, "text", "4.0"],
["fn", {}, "text", "Jane Doe"],
["tel", {"type" : ["voice"]}, "uri", "tel:+1.2125551215"],
["tel", {"type" : ["fax"]}, "uri", "tel:+1.2125551216"],
["email", {}, "text", "janedoe@example.com"]
]
]
},
{
"objectClassName" : "entity",
"status" : ["active"],
"roles" : ["technical"],
"vcardArray" :
[
"vcard",
[
["version", {}, "text", "4.0"],
["fn", {}, "text", "John Doe"],
["tel", {"type" : ["voice"]}, "uri", "tel:+1.2125551213"],
["tel", {"type" : ["fax"]}, "uri", "tel:+1.2125551213"],
["email", {}, "text", "johndoe@example.com"]
]
]
}
]
}
]
} }

View file

@ -1,11 +1,13 @@
{ {
"objectClassName": "domain",
"handle": "%HANDLE%",
"ldhName": "%NAME%",
"status": [ "status": [
"client delete prohibited", "client delete prohibited",
"client renew prohibited", "client renew prohibited",
"client transfer prohibited", "client transfer prohibited",
"server update prohibited" "server update prohibited"
], ],
"handle": "%HANDLE%",
"links": [ "links": [
{ {
"href": "https://example.com/rdap/domain/%NAME%", "href": "https://example.com/rdap/domain/%NAME%",
@ -101,8 +103,96 @@
"objectClassName": "nameserver" "objectClassName": "nameserver"
} }
], ],
"ldhName": "%NAME%", "entities": [
"objectClassName": "domain", {
"objectClassName" : "entity",
"handle" : "1",
"status" : ["active"],
"roles" : ["registrar"],
"links" :
[
{
"value" : "https://example.com/rdap/entity/1",
"rel" : "self",
"href" : "https://example.com/rdap/entity/1",
"type" : "application/rdap+json"
}
],
"events" :
[
{
"eventAction": "registration",
"eventActor": "1",
"eventDate": "2000-01-01T00:00:00.000Z"
},
{
"eventAction": "last update of RDAP database",
"eventDate": "2000-01-01T00:00:00.000Z"
}
],
"publicIds" :
[
{
"type" : "IANA Registrar ID",
"identifier" : "1"
}
],
"vcardArray" :
[
"vcard",
[
["version", {}, "text", "4.0"],
["fn", {}, "text", "%REGISTRARNAME%"],
["adr", {}, "text", [
"",
"",
"123 Example Boulevard <script>",
"Williamsburg <script>",
"NY",
"11211",
"United States"]],
["tel", {"type" : ["voice"]}, "uri", "tel:+1.2125551212"],
["tel", {"type" : ["fax"]}, "uri", "tel:+1.2125551213"],
["email", {}, "text", "contact-us@example.com"]
]
],
"entities" :
[
{
"objectClassName" : "entity",
"status" : ["active"],
"roles" : ["administrative"],
"vcardArray" :
[
"vcard",
[
["version", {}, "text", "4.0"],
["fn", {}, "text", "Jane Doe"],
["tel", {"type" : ["voice"]}, "uri", "tel:+1.2125551215"],
["tel", {"type" : ["fax"]}, "uri", "tel:+1.2125551216"],
["email", {}, "text", "janedoe@example.com"]
]
]
},
{
"objectClassName" : "entity",
"status" : ["active"],
"roles" : ["technical"],
"vcardArray" :
[
"vcard",
[
["version", {}, "text", "4.0"],
["fn", {}, "text", "John Doe"],
["tel", {"type" : ["voice"]}, "uri", "tel:+1.2125551213"],
["tel", {"type" : ["fax"]}, "uri", "tel:+1.2125551213"],
["email", {}, "text", "johndoe@example.com"]
]
]
}
]
}
],
"remarks": [ "remarks": [
{ {
"title": "Contacts Hidden", "title": "Contacts Hidden",

View file

@ -1,11 +1,14 @@
{ {
"objectClassName": "domain",
"handle": "%HANDLE%",
"ldhName": "%PUNYCODENAME%",
"unicodeName": "%NAME%",
"status": [ "status": [
"client delete prohibited", "client delete prohibited",
"client renew prohibited", "client renew prohibited",
"client transfer prohibited", "client transfer prohibited",
"server update prohibited" "server update prohibited"
], ],
"handle": "%HANDLE%",
"links": [ "links": [
{ {
"href": "https://example.com/rdap/domain/%PUNYCODENAME%", "href": "https://example.com/rdap/domain/%PUNYCODENAME%",
@ -103,9 +106,96 @@
"objectClassName": "nameserver" "objectClassName": "nameserver"
} }
], ],
"ldhName": "%PUNYCODENAME%", "entities": [
"unicodeName": "%NAME%", {
"objectClassName": "domain", "objectClassName" : "entity",
"handle" : "1",
"status" : ["active"],
"roles" : ["registrar"],
"links" :
[
{
"value" : "https://example.com/rdap/entity/1",
"rel" : "self",
"href" : "https://example.com/rdap/entity/1",
"type" : "application/rdap+json"
}
],
"events" :
[
{
"eventAction": "registration",
"eventActor": "1",
"eventDate": "2000-01-01T00:00:00.000Z"
},
{
"eventAction": "last update of RDAP database",
"eventDate": "2000-01-01T00:00:00.000Z"
}
],
"publicIds" :
[
{
"type" : "IANA Registrar ID",
"identifier" : "1"
}
],
"vcardArray" :
[
"vcard",
[
["version", {}, "text", "4.0"],
["fn", {}, "text", "%REGISTRARNAME%"],
["adr", {}, "text", [
"",
"",
"123 Example Boulevard <script>",
"Williamsburg <script>",
"NY",
"11211",
"United States"]],
["tel", {"type" : ["voice"]}, "uri", "tel:+1.2125551212"],
["tel", {"type" : ["fax"]}, "uri", "tel:+1.2125551213"],
["email", {}, "text", "contact-us@example.com"]
]
],
"entities" :
[
{
"objectClassName" : "entity",
"status" : ["active"],
"roles" : ["administrative"],
"vcardArray" :
[
"vcard",
[
["version", {}, "text", "4.0"],
["fn", {}, "text", "Jane Doe"],
["tel", {"type" : ["voice"]}, "uri", "tel:+1.2125551215"],
["tel", {"type" : ["fax"]}, "uri", "tel:+1.2125551216"],
["email", {}, "text", "janedoe@example.com"]
]
]
},
{
"objectClassName" : "entity",
"status" : ["active"],
"roles" : ["technical"],
"vcardArray" :
[
"vcard",
[
["version", {}, "text", "4.0"],
["fn", {}, "text", "John Doe"],
["tel", {"type" : ["voice"]}, "uri", "tel:+1.2125551213"],
["tel", {"type" : ["fax"]}, "uri", "tel:+1.2125551213"],
["email", {}, "text", "johndoe@example.com"]
]
]
}
]
}
],
"remarks": [ "remarks": [
{ {
"title": "Contacts Hidden", "title": "Contacts Hidden",

View file

@ -103,6 +103,114 @@
} }
} }
], ],
"entities": [
{
"objectClassName" : "entity",
"handle" : "1",
"status" : ["active"],
"roles" : ["registrar"],
"links" :
[
{
"value" : "http://myserver.example.com/entity/1",
"rel" : "self",
"href" : "http://myserver.example.com/entity/1",
"type" : "application/rdap+json"
}
],
"events" :
[
{
"eventAction": "registration",
"eventActor": "1",
"eventDate": "1999-01-01T00:00:00.000Z"
},
{
"eventAction": "last changed",
"eventDate": "2000-01-01T00:00:00.000Z"
},
{
"eventAction": "last update of RDAP database",
"eventDate": "2000-01-01T00:00:00.000Z"
}
],
"publicIds" :
[
{
"type" : "IANA Registrar ID",
"identifier" : "1"
}
],
"vcardArray" :
[
"vcard",
[
["version", {}, "text", "4.0"],
["fn", {}, "text", "みんな"],
["adr", {}, "text", [
"",
"",
"123 Example Boulevard <script>",
"Williamsburg <script>",
"NY",
"11211",
"United States"]],
["tel", {"type" : ["voice"]}, "uri", "tel:+1.2125551212"],
["tel", {"type" : ["fax"]}, "uri", "tel:+1.2125551213"],
["email", {}, "text", "contact-us@example.com"]
]
],
"entities" :
[
{
"objectClassName" : "entity",
"status" : ["active"],
"roles" : ["administrative"],
"vcardArray" :
[
"vcard",
[
["version", {}, "text", "4.0"],
["fn", {}, "text", "Jane Doe"],
["tel", {"type" : ["voice"]}, "uri", "tel:+1.2125551215"],
["email", {}, "text", "janedoe@example.com"]
]
]
},
{
"objectClassName" : "entity",
"status" : ["active"],
"roles" : ["technical"],
"vcardArray" :
[
"vcard",
[
["version", {}, "text", "4.0"],
["fn", {}, "text", "John Doe"],
["tel", {"type" : ["fax"]}, "uri", "tel:+1.2125551213"],
["email", {}, "text", "johndoe@example.com"]
]
]
},
{
"objectClassName" : "entity",
"status" : ["active"],
"roles" : ["administrative", "technical"],
"vcardArray" :
[
"vcard",
[
["version", {}, "text", "4.0"],
["fn", {}, "text", "Play Doe"],
["tel", {"type" : ["voice"]}, "uri", "tel:+1.2125551217"],
["tel", {"type" : ["fax"]}, "uri", "tel:+1.2125551218"],
["email", {}, "text", "playdoe@example.com"]
]
]
}
]
}
],
"remarks": [ "remarks": [
{ {
"title": "Contacts Hidden", "title": "Contacts Hidden",