1 | <?php |
||
24 | class CertificationPath implements \Countable, \IteratorAggregate |
||
25 | { |
||
26 | /** |
||
27 | * Certification path. |
||
28 | * |
||
29 | * @var Certificate[] $_certificates |
||
30 | */ |
||
31 | protected $_certificates; |
||
32 | |||
33 | /** |
||
34 | * Constructor. |
||
35 | * |
||
36 | * @param Certificate ...$certificates Certificates from the trust anchor |
||
37 | * to the target end-entity certificate |
||
38 | */ |
||
39 | 28 | public function __construct(Certificate ...$certificates) { |
|
42 | |||
43 | /** |
||
44 | * Build certification path to given target. |
||
45 | * |
||
46 | * @param Certificate $target Target end-entity certificate |
||
47 | * @param CertificateBundle $trust_anchors List of trust anchors |
||
48 | * @param CertificateBundle|null $intermediate Optional intermediate |
||
49 | * certificates |
||
50 | * @return self |
||
51 | */ |
||
52 | 2 | public static function toTarget(Certificate $target, |
|
58 | |||
59 | /** |
||
60 | * Build certification path from given trust anchor to target certificate, |
||
61 | * using intermediate certificates from given bundle. |
||
62 | * |
||
63 | * @param Certificate $trust_anchor Trust anchor certificate |
||
64 | * @param Certificate $target Target end-entity certificate |
||
65 | * @param CertificateBundle|null $intermediate Optional intermediate |
||
66 | * certificates |
||
67 | * @return self |
||
68 | */ |
||
69 | 2 | public static function fromTrustAnchorToTarget(Certificate $trust_anchor, |
|
74 | |||
75 | /** |
||
76 | * Get certificates. |
||
77 | * |
||
78 | * @return Certificate[] |
||
79 | */ |
||
80 | 5 | public function certificates() { |
|
83 | |||
84 | /** |
||
85 | * Get the trust anchor certificate from the path. |
||
86 | * |
||
87 | * @throws \LogicException If path is empty |
||
88 | * @return Certificate |
||
89 | */ |
||
90 | 2 | public function trustAnchorCertificate() { |
|
96 | |||
97 | /** |
||
98 | * Get the end-entity certificate from the path. |
||
99 | * |
||
100 | * @throws \LogicException If path is empty |
||
101 | * @return Certificate |
||
102 | */ |
||
103 | 2 | public function endEntityCertificate() { |
|
109 | |||
110 | /** |
||
111 | * Check whether certification path starts with one ore more given |
||
112 | * certificates in parameter order. |
||
113 | * |
||
114 | * @param Certificate ...$certs Certificates |
||
115 | * @return true |
||
116 | */ |
||
117 | 5 | public function startsWith(Certificate ...$certs) { |
|
129 | |||
130 | /** |
||
131 | * Validate certification path. |
||
132 | * |
||
133 | * @param Crypto $crypto |
||
134 | * @param PathValidationConfig $config |
||
135 | * @throws PathValidationException |
||
136 | * @return PathValidationResult |
||
137 | */ |
||
138 | 35 | public function validate(Crypto $crypto, PathValidationConfig $config) { |
|
142 | |||
143 | /** |
||
144 | * |
||
145 | * @see Countable::count() |
||
146 | * @return int |
||
147 | */ |
||
148 | 18 | public function count() { |
|
151 | |||
152 | /** |
||
153 | * Get iterator for certificates. |
||
154 | * |
||
155 | * @see IteratorAggregate::getIterator() |
||
156 | * @return \ArrayIterator |
||
157 | */ |
||
158 | 1 | public function getIterator() { |
|
161 | } |
||
162 |