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 | 26 | 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 | * Check whether certification path starts with one ore more given |
||
86 | * certificates in parameter order. |
||
87 | * |
||
88 | * @param Certificate ...$certs Certificates |
||
89 | * @return true |
||
90 | */ |
||
91 | 5 | public function startsWith(Certificate ...$certs) { |
|
103 | |||
104 | /** |
||
105 | * Validate certification path. |
||
106 | * |
||
107 | * @param Crypto $crypto |
||
108 | * @param PathValidationConfig $config |
||
109 | * @throws PathValidationException |
||
110 | * @return PathValidationResult |
||
111 | */ |
||
112 | 35 | public function validate(Crypto $crypto, PathValidationConfig $config) { |
|
116 | |||
117 | /** |
||
118 | * |
||
119 | * @see Countable::count() |
||
120 | * @return int |
||
121 | */ |
||
122 | 18 | public function count() { |
|
125 | |||
126 | /** |
||
127 | * Get iterator for certificates. |
||
128 | * |
||
129 | * @see IteratorAggregate::getIterator() |
||
130 | * @return \ArrayIterator |
||
131 | */ |
||
132 | 1 | public function getIterator() { |
|
135 | } |
||
136 |