fix: some registries create IANA identifiers and return them in the RDAP response...

This commit is contained in:
Maël Gangloff
2025-09-13 01:56:05 +02:00
parent 0be609cc9d
commit 7e79b9c3a9

View File

@@ -35,7 +35,6 @@ use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpClient\Exception\ClientException; use Symfony\Component\HttpClient\Exception\ClientException;
use Symfony\Component\HttpFoundation\Exception\BadRequestException; use Symfony\Component\HttpFoundation\Exception\BadRequestException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Yaml;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
@@ -519,6 +518,8 @@ class RDAPService
*/ */
private function registerEntity(array $rdapEntity, array $roles, string $domain, Tld $tld): Entity private function registerEntity(array $rdapEntity, array $roles, string $domain, Tld $tld): Entity
{ {
$entity = null;
/** /**
* If the RDAP server transmits the entity's IANA number, it is used as a priority to identify the entity. * If the RDAP server transmits the entity's IANA number, it is used as a priority to identify the entity.
* *
@@ -528,9 +529,16 @@ class RDAPService
if (isset($rdapEntity['publicIds'])) { if (isset($rdapEntity['publicIds'])) {
foreach ($rdapEntity['publicIds'] as $publicId) { foreach ($rdapEntity['publicIds'] as $publicId) {
if ('IANA Registrar ID' === $publicId['type'] && isset($publicId['identifier']) && '' !== $publicId['identifier']) { if ('IANA Registrar ID' === $publicId['type'] && isset($publicId['identifier']) && '' !== $publicId['identifier']) {
$rdapEntity['handle'] = $publicId['identifier']; $entity = $this->entityRepository->findOneBy([
$isIANAid = true; 'handle' => $rdapEntity['handle'],
break; 'tld' => null,
]);
if (null !== $entity) {
$rdapEntity['handle'] = $publicId['identifier'];
$isIANAid = true;
break;
}
} }
} }
} }
@@ -547,19 +555,17 @@ class RDAPService
]); ]);
} }
$entity = $this->entityRepository->findOneBy([ if (null === $entity) {
'handle' => $rdapEntity['handle'], $entity = $this->entityRepository->findOneBy([
'tld' => $isIANAid ? null : $tld, 'handle' => $rdapEntity['handle'],
]); 'tld' => $tld,
]);
}
if ($isIANAid && null !== $entity) { if ($isIANAid && null !== $entity) {
return $entity; return $entity;
} }
if ($isIANAid && null === $entity) {
throw new ServiceUnavailableHttpException('The server does not know the IANA identifier of this registrar ('.$rdapEntity['handle'].')');
}
if (null === $entity) { if (null === $entity) {
$entity = (new Entity())->setTld($tld); $entity = (new Entity())->setTld($tld);