|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Sop\X509\CertificationRequest\Attribute; |
|
6
|
|
|
|
|
7
|
|
|
use Sop\ASN1\Element; |
|
8
|
|
|
use Sop\ASN1\Type\UnspecifiedType; |
|
9
|
|
|
use Sop\X501\ASN1\AttributeValue\AttributeValue; |
|
10
|
|
|
use Sop\X501\MatchingRule\BinaryMatch; |
|
11
|
|
|
use Sop\X501\MatchingRule\MatchingRule; |
|
12
|
|
|
use Sop\X509\Certificate\Extensions; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Implements value for 'Extension request' attribute. |
|
16
|
|
|
* |
|
17
|
|
|
* @see https://tools.ietf.org/html/rfc2985#page-17 |
|
18
|
|
|
*/ |
|
19
|
|
|
class ExtensionRequestValue extends AttributeValue |
|
20
|
|
|
{ |
|
21
|
|
|
const OID = '1.2.840.113549.1.9.14'; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Extensions. |
|
25
|
|
|
* |
|
26
|
|
|
* @var Extensions |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $_extensions; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Constructor. |
|
32
|
|
|
* |
|
33
|
|
|
* @param Extensions $extensions |
|
34
|
|
|
*/ |
|
35
|
11 |
|
public function __construct(Extensions $extensions) |
|
36
|
|
|
{ |
|
37
|
11 |
|
$this->_extensions = $extensions; |
|
38
|
11 |
|
$this->_oid = self::OID; |
|
39
|
11 |
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* {@inheritdoc} |
|
43
|
|
|
* |
|
44
|
|
|
* @return self |
|
45
|
|
|
*/ |
|
46
|
6 |
|
public static function fromASN1(UnspecifiedType $el): AttributeValue |
|
47
|
|
|
{ |
|
48
|
6 |
|
return new self(Extensions::fromASN1($el->asSequence())); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Get requested extensions. |
|
53
|
|
|
* |
|
54
|
|
|
* @return Extensions |
|
55
|
|
|
*/ |
|
56
|
4 |
|
public function extensions(): Extensions |
|
57
|
|
|
{ |
|
58
|
4 |
|
return $this->_extensions; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* {@inheritdoc} |
|
63
|
|
|
*/ |
|
64
|
10 |
|
public function toASN1(): Element |
|
65
|
|
|
{ |
|
66
|
10 |
|
return $this->_extensions->toASN1(); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* {@inheritdoc} |
|
71
|
|
|
*/ |
|
72
|
3 |
|
public function stringValue(): string |
|
73
|
|
|
{ |
|
74
|
3 |
|
return '#' . bin2hex($this->toASN1()->toDER()); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* {@inheritdoc} |
|
79
|
|
|
*/ |
|
80
|
1 |
|
public function equalityMatchingRule(): MatchingRule |
|
81
|
|
|
{ |
|
82
|
1 |
|
return new BinaryMatch(); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* {@inheritdoc} |
|
87
|
|
|
*/ |
|
88
|
1 |
|
public function rfc2253String(): string |
|
89
|
|
|
{ |
|
90
|
1 |
|
return $this->stringValue(); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* {@inheritdoc} |
|
95
|
|
|
*/ |
|
96
|
1 |
|
protected function _transcodedString(): string |
|
97
|
|
|
{ |
|
98
|
1 |
|
return $this->stringValue(); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|