. */ declare(strict_types=1); namespace App\Entity\UserSystem; use App\Entity\Base\TimestampTrait; use Doctrine\ORM\Mapping as ORM; use Jbtronics\TFAWebauthn\Model\LegacyU2FKeyInterface; #[ORM\Entity] #[ORM\HasLifecycleCallbacks] #[ORM\Table(name: 'u2f_keys')] #[ORM\UniqueConstraint(name: 'user_unique', columns: ['user_id', 'key_handle'])] class U2FKey implements LegacyU2FKeyInterface { use TimestampTrait; /** * We have to restrict the length here, as InnoDB only supports key index with max. 767 Bytes. * Max length of keyhandles should be 128. (According to U2F_MAX_KH_SIZE in FIDO example C code). * * * @var string **/ #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 128)] public string $keyHandle; /** * @var string **/ #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] public string $publicKey; /** * @var string **/ #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] public string $certificate; /** * @var int **/ #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] public int $counter; #[ORM\Id] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] #[ORM\GeneratedValue] protected int $id; /** * @var string **/ #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING)] protected string $name; #[ORM\ManyToOne(targetEntity: 'App\Entity\UserSystem\User', inversedBy: 'u2fKeys')] protected ?User $user = null; public function getKeyHandle(): string { return $this->keyHandle; } public function setKeyHandle($keyHandle): self { $this->keyHandle = $keyHandle; return $this; } public function getPublicKey(): string { return $this->publicKey; } public function setPublicKey($publicKey): self { $this->publicKey = $publicKey; return $this; } public function getCertificate(): string { return $this->certificate; } public function setCertificate($certificate): self { $this->certificate = $certificate; return $this; } public function getCounter(): int { return $this->counter; } public function setCounter($counter): self { $this->counter = $counter; return $this; } public function getName(): string { return $this->name; } public function setName($name): self { $this->name = $name; return $this; } /** * Gets the user, this U2F key belongs to. */ public function getUser(): User { return $this->user; } /** * The primary key ID of this key. */ public function getID(): int { return $this->id; } /** * Sets the user this U2F key belongs to. * * @return $this */ public function setUser(User $new_user): self { $this->user = $new_user; return $this; } }