| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace SpomkyLabs\Pki\X509\GeneralName; |
| 6 |
|
| 7 |
use SpomkyLabs\Pki\ASN1\Type\Tagged\ExplicitlyTaggedType; |
| 8 |
use SpomkyLabs\Pki\ASN1\Type\TaggedType; |
| 9 |
use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType; |
| 10 |
use SpomkyLabs\Pki\X501\ASN1\Name; |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
final class DirectoryName extends GeneralName |
| 18 |
{ |
| 19 |
private function __construct( |
| 20 |
private readonly Name $directoryName |
| 21 |
) { |
| 22 |
parent::__construct(self::TAG_DIRECTORY_NAME); |
| 23 |
} |
| 24 |
|
| 25 |
public static function create(Name $directoryName): self |
| 26 |
{ |
| 27 |
return new self($directoryName); |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
| 34 |
{ |
| 35 |
return self::create(Name::fromASN1($el->asSequence())); |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
public static function fromDNString(string $str): self |
| 42 |
{ |
| 43 |
return self::create(Name::fromString($str)); |
| 44 |
} |
| 45 |
|
| 46 |
public function string(): string |
| 47 |
{ |
| 48 |
return $this->directoryName->toString(); |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
public function dn(): Name |
| 55 |
{ |
| 56 |
return $this->directoryName; |
| 57 |
} |
| 58 |
|
| 59 |
protected function choiceASN1(): TaggedType |
| 60 |
{ |
| 61 |
|
| 62 |
|
| 63 |
return ExplicitlyTaggedType::create($this->tag, $this->directoryName->toASN1()); |
| 64 |
} |
| 65 |
} |