1414
1515package google .registry .rdap ;
1616
17- import static google .registry .persistence .transaction .TransactionManagerFactory .replicaTm ;
1817import static google .registry .rdap .RdapUtils .getRegistrarByIanaIdentifier ;
1918import static google .registry .rdap .RdapUtils .getRegistrarByName ;
2019import static google .registry .request .Action .Method .GET ;
2120import static google .registry .request .Action .Method .HEAD ;
2221
23- import com .google .common .collect .ImmutableSet ;
2422import com .google .common .primitives .Longs ;
25- import com .google .re2j .Pattern ;
26- import google .registry .model .contact .Contact ;
2723import google .registry .model .registrar .Registrar ;
28- import google .registry .persistence .VKey ;
2924import google .registry .rdap .RdapJsonFormatter .OutputDataType ;
3025import google .registry .rdap .RdapMetrics .EndpointType ;
3126import google .registry .rdap .RdapObjectClasses .RdapEntity ;
3732import java .util .Optional ;
3833
3934/**
40- * RDAP action for entity (contact and registrar) requests. the ICANN operational profile dictates
41- * that the "handle" for registrars is to be the IANA registrar ID:
35+ * RDAP action for entity (i.e. registrar) requests. the ICANN operational profile dictates that the
36+ * "handle" for registrars is to be the IANA registrar ID:
4237 *
4338 * <p>2.4.1.Registry RDAP servers MUST support Registrar object lookup using an entity path request
4439 * for entities with the registrar role using the handle (as described in 3.1.5 of RFC9082) where
5247 auth = Auth .AUTH_PUBLIC )
5348public class RdapEntityAction extends RdapActionBase {
5449
55- private static final Pattern ROID_PATTERN = Pattern .compile ("[-_.a-zA-Z0-9]+" );
56-
5750 @ Inject public RdapEntityAction () {
5851 super ("entity" , EndpointType .ENTITY );
5952 }
6053
6154 @ Override
6255 public RdapEntity getJsonObjectForResource (
6356 String pathSearchString , boolean isHeadRequest ) {
64- // The query string is not used; the RDAP syntax is /rdap/entity/handle (the handle is the roid
65- // for contacts and the client identifier/fn for registrars). Since RDAP's concept of an entity
66- // includes both contacts and registrars, search for one first, then the other.
67-
68- // RDAP Technical Implementation Guide 2.3.1 - MUST support contact entity lookup using the
69- // handle
70- if (ROID_PATTERN .matcher (pathSearchString ).matches ()) {
71- VKey <Contact > contactVKey = VKey .create (Contact .class , pathSearchString );
72- Optional <Contact > contact =
73- replicaTm ().transact (() -> replicaTm ().loadByKeyIfPresent (contactVKey ));
74- // As per Andy Newton on the regext mailing list, contacts by themselves have no role, since
75- // they are global, and might have different roles for different domains.
76- if (contact .isPresent () && isAuthorized (contact .get ())) {
77- return rdapJsonFormatter .createRdapContactEntity (
78- contact .get (), ImmutableSet .of (), OutputDataType .FULL );
79- }
80- }
81-
8257 // RDAP Technical Implementation Guide 2.4.1 - MUST support registrar entity lookup using the
8358 // IANA ID as handle
8459 Long ianaIdentifier = Longs .tryParse (pathSearchString );
@@ -96,7 +71,7 @@ public RdapEntity getJsonObjectForResource(
9671 return rdapJsonFormatter .createRdapRegistrarEntity (registrar .get (), OutputDataType .FULL );
9772 }
9873
99- // At this point, we have failed to find either a contact or a registrar.
74+ // At this point, we have failed to find a registrar.
10075 //
10176 // RFC7480 5.3 - if the server wishes to respond that it doesn't have data satisfying the
10277 // query, it MUST reply with 404 response code.
0 commit comments