mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
chore: merge master
This commit is contained in:
100
src/Entity/DnsKey.php
Normal file
100
src/Entity/DnsKey.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Config\DnsKey\Algorithm;
|
||||
use App\Config\DnsKey\DigestType;
|
||||
use App\Repository\DnsKeyRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity(repositoryClass: DnsKeyRepository::class)]
|
||||
class DnsKey
|
||||
{
|
||||
#[ORM\Column(nullable: true, enumType: Algorithm::class)]
|
||||
#[Groups(['ds:list'])]
|
||||
#[ORM\Id]
|
||||
private ?Algorithm $algorithm;
|
||||
|
||||
#[ORM\Column(enumType: DigestType::class)]
|
||||
#[Groups(['ds:list'])]
|
||||
#[ORM\Id]
|
||||
private ?DigestType $digestType;
|
||||
|
||||
#[ORM\Column(type: Types::BINARY)]
|
||||
#[Groups(['ds:list'])]
|
||||
#[ORM\Id]
|
||||
private $keyTag;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'dnsKey')]
|
||||
#[ORM\JoinColumn(referencedColumnName: 'ldh_name', nullable: false)]
|
||||
#[Groups(['ds:list', 'ds:item'])]
|
||||
#[ORM\Id]
|
||||
private ?Domain $domain = null;
|
||||
|
||||
#[ORM\Column(type: Types::BLOB)]
|
||||
#[Groups(['ds:list'])]
|
||||
#[ORM\Id]
|
||||
private $digest;
|
||||
|
||||
public function getAlgorithm(): ?Algorithm
|
||||
{
|
||||
return $this->algorithm;
|
||||
}
|
||||
|
||||
public function setAlgorithm(?Algorithm $algorithm): static
|
||||
{
|
||||
$this->algorithm = $algorithm;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDigestType(): ?DigestType
|
||||
{
|
||||
return $this->digestType;
|
||||
}
|
||||
|
||||
public function setDigestType(DigestType $digestType): static
|
||||
{
|
||||
$this->digestType = $digestType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getKeyTag()
|
||||
{
|
||||
return unpack('n', $this->keyTag)[1];
|
||||
}
|
||||
|
||||
public function setKeyTag($keyTag): static
|
||||
{
|
||||
$this->keyTag = $keyTag;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDomain(): ?Domain
|
||||
{
|
||||
return $this->domain;
|
||||
}
|
||||
|
||||
public function setDomain(?Domain $domain): static
|
||||
{
|
||||
$this->domain = $domain;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDigest()
|
||||
{
|
||||
return strtoupper(bin2hex($this->digest));
|
||||
}
|
||||
|
||||
public function setDigest($digest): static
|
||||
{
|
||||
$this->digest = $digest;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||
'nameserver-entity:nameserver',
|
||||
'nameserver-entity:entity',
|
||||
'tld:item',
|
||||
'ds:list',
|
||||
],
|
||||
],
|
||||
read: false
|
||||
@@ -136,6 +137,13 @@ class Domain
|
||||
#[Groups(['domain:item', 'domain:list'])]
|
||||
private ?bool $delegationSigned = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, DnsKey>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: DnsKey::class, mappedBy: 'domain', orphanRemoval: true)]
|
||||
#[Groups(['domain:item'])]
|
||||
private Collection $dnsKey;
|
||||
|
||||
private const IMPORTANT_EVENTS = [EventAction::Deletion->value, EventAction::Expiration->value];
|
||||
private const IMPORTANT_STATUS = [
|
||||
'redemption period',
|
||||
@@ -158,6 +166,7 @@ class Domain
|
||||
$this->createdAt = $this->updatedAt;
|
||||
$this->deleted = false;
|
||||
$this->domainStatuses = new ArrayCollection();
|
||||
$this->dnsKey = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getLdhName(): ?string
|
||||
@@ -607,6 +616,36 @@ class Domain
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, DnsKey>
|
||||
*/
|
||||
public function getDnsKey(): Collection
|
||||
{
|
||||
return $this->dnsKey;
|
||||
}
|
||||
|
||||
public function addDnsKey(DnsKey $dnsKey): static
|
||||
{
|
||||
if (!$this->dnsKey->contains($dnsKey)) {
|
||||
$this->dnsKey->add($dnsKey);
|
||||
$dnsKey->setDomain($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeDnsKey(DnsKey $dnsKey): static
|
||||
{
|
||||
if ($this->dnsKey->removeElement($dnsKey)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($dnsKey->getDomain() === $this) {
|
||||
$dnsKey->setDomain(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Event[]
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user