| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace SpomkyLabs\Pki\X509\CertificationRequest\Attribute; |
| 6 |
|
| 7 |
use SpomkyLabs\Pki\ASN1\Element; |
| 8 |
use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType; |
| 9 |
use SpomkyLabs\Pki\X501\ASN1\AttributeValue\AttributeValue; |
| 10 |
use SpomkyLabs\Pki\X501\MatchingRule\BinaryMatch; |
| 11 |
use SpomkyLabs\Pki\X501\MatchingRule\MatchingRule; |
| 12 |
use SpomkyLabs\Pki\X509\Certificate\Extensions; |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
final class ExtensionRequestValue extends AttributeValue |
| 20 |
{ |
| 21 |
final public const OID = '1.2.840.113549.1.9.14'; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
private function __construct( |
| 27 |
protected Extensions $extensions |
| 28 |
) { |
| 29 |
parent::__construct(self::OID); |
| 30 |
} |
| 31 |
|
| 32 |
public static function create(Extensions $extensions): self |
| 33 |
{ |
| 34 |
return new self($extensions); |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
public static function fromASN1(UnspecifiedType $el): AttributeValue |
| 41 |
{ |
| 42 |
return self::create(Extensions::fromASN1($el->asSequence())); |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
public function extensions(): Extensions |
| 49 |
{ |
| 50 |
return $this->extensions; |
| 51 |
} |
| 52 |
|
| 53 |
public function toASN1(): Element |
| 54 |
{ |
| 55 |
return $this->extensions->toASN1(); |
| 56 |
} |
| 57 |
|
| 58 |
public function stringValue(): string |
| 59 |
{ |
| 60 |
return '#' . bin2hex($this->toASN1()->toDER()); |
| 61 |
} |
| 62 |
|
| 63 |
public function equalityMatchingRule(): MatchingRule |
| 64 |
{ |
| 65 |
return new BinaryMatch(); |
| 66 |
} |
| 67 |
|
| 68 |
public function rfc2253String(): string |
| 69 |
{ |
| 70 |
return $this->stringValue(); |
| 71 |
} |
| 72 |
|
| 73 |
protected function _transcodedString(): string |
| 74 |
{ |
| 75 |
return $this->stringValue(); |
| 76 |
} |
| 77 |
} |