| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace SpomkyLabs\Pki\X509\Certificate\Extension\Target; |
| 6 |
|
| 7 |
use SpomkyLabs\Pki\ASN1\Element; |
| 8 |
use SpomkyLabs\Pki\ASN1\Type\Tagged\ExplicitlyTaggedType; |
| 9 |
use SpomkyLabs\Pki\ASN1\Type\TaggedType; |
| 10 |
use SpomkyLabs\Pki\X509\GeneralName\GeneralName; |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
final class TargetName extends Target |
| 18 |
{ |
| 19 |
private function __construct( |
| 20 |
private readonly GeneralName $name |
| 21 |
) { |
| 22 |
parent::__construct(self::TYPE_NAME); |
| 23 |
} |
| 24 |
|
| 25 |
public static function create(GeneralName $name): self |
| 26 |
{ |
| 27 |
return new self($name); |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public static function fromChosenASN1(TaggedType $el): Target |
| 34 |
{ |
| 35 |
return self::create(GeneralName::fromASN1($el)); |
| 36 |
} |
| 37 |
|
| 38 |
public function string(): string |
| 39 |
{ |
| 40 |
return $this->name->string(); |
| 41 |
} |
| 42 |
|
| 43 |
public function name(): GeneralName |
| 44 |
{ |
| 45 |
return $this->name; |
| 46 |
} |
| 47 |
|
| 48 |
public function toASN1(): Element |
| 49 |
{ |
| 50 |
return ExplicitlyTaggedType::create($this->type, $this->name->toASN1()); |
| 51 |
} |
| 52 |
} |