@@ -9,16 +9,16 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class ChargingIdentityAttributeValue extends IetfAttrSyntax |
| 11 | 11 | { |
| 12 | - const OID = "1.3.6.1.5.5.7.10.3"; |
|
| 12 | + const OID = "1.3.6.1.5.5.7.10.3"; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Constructor. |
|
| 16 | - * |
|
| 17 | - * @param IetfAttrValue ...$values |
|
| 18 | - */ |
|
| 19 | - public function __construct(IetfAttrValue ...$values) |
|
| 20 | - { |
|
| 21 | - parent::__construct(...$values); |
|
| 22 | - $this->_oid = self::OID; |
|
| 23 | - } |
|
| 14 | + /** |
|
| 15 | + * Constructor. |
|
| 16 | + * |
|
| 17 | + * @param IetfAttrValue ...$values |
|
| 18 | + */ |
|
| 19 | + public function __construct(IetfAttrValue ...$values) |
|
| 20 | + { |
|
| 21 | + parent::__construct(...$values); |
|
| 22 | + $this->_oid = self::OID; |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -9,16 +9,16 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class GroupAttributeValue extends IetfAttrSyntax |
| 11 | 11 | { |
| 12 | - const OID = "1.3.6.1.5.5.7.10.4"; |
|
| 12 | + const OID = "1.3.6.1.5.5.7.10.4"; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Constructor. |
|
| 16 | - * |
|
| 17 | - * @param IetfAttrValue ...$values |
|
| 18 | - */ |
|
| 19 | - public function __construct(IetfAttrValue ...$values) |
|
| 20 | - { |
|
| 21 | - parent::__construct(...$values); |
|
| 22 | - $this->_oid = self::OID; |
|
| 23 | - } |
|
| 14 | + /** |
|
| 15 | + * Constructor. |
|
| 16 | + * |
|
| 17 | + * @param IetfAttrValue ...$values |
|
| 18 | + */ |
|
| 19 | + public function __construct(IetfAttrValue ...$values) |
|
| 20 | + { |
|
| 21 | + parent::__construct(...$values); |
|
| 22 | + $this->_oid = self::OID; |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -15,87 +15,87 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class GeneralSubtrees implements \Countable, \IteratorAggregate |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * Subtrees. |
|
| 20 | - * |
|
| 21 | - * @var GeneralSubtree[] $_subtrees |
|
| 22 | - */ |
|
| 23 | - protected $_subtrees; |
|
| 18 | + /** |
|
| 19 | + * Subtrees. |
|
| 20 | + * |
|
| 21 | + * @var GeneralSubtree[] $_subtrees |
|
| 22 | + */ |
|
| 23 | + protected $_subtrees; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Constructor. |
|
| 27 | - * |
|
| 28 | - * @param GeneralSubtree ...$subtrees |
|
| 29 | - */ |
|
| 30 | - public function __construct(GeneralSubtree ...$subtrees) |
|
| 31 | - { |
|
| 32 | - $this->_subtrees = $subtrees; |
|
| 33 | - } |
|
| 25 | + /** |
|
| 26 | + * Constructor. |
|
| 27 | + * |
|
| 28 | + * @param GeneralSubtree ...$subtrees |
|
| 29 | + */ |
|
| 30 | + public function __construct(GeneralSubtree ...$subtrees) |
|
| 31 | + { |
|
| 32 | + $this->_subtrees = $subtrees; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Initialize from ASN.1. |
|
| 37 | - * |
|
| 38 | - * @param Sequence $seq |
|
| 39 | - * @return self |
|
| 40 | - */ |
|
| 41 | - public static function fromASN1(Sequence $seq): self |
|
| 42 | - { |
|
| 43 | - $subtrees = array_map( |
|
| 44 | - function (UnspecifiedType $el) { |
|
| 45 | - return GeneralSubtree::fromASN1($el->asSequence()); |
|
| 46 | - }, $seq->elements()); |
|
| 47 | - if (!count($subtrees)) { |
|
| 48 | - throw new \UnexpectedValueException( |
|
| 49 | - "GeneralSubtrees must contain at least one GeneralSubtree."); |
|
| 50 | - } |
|
| 51 | - return new self(...$subtrees); |
|
| 52 | - } |
|
| 35 | + /** |
|
| 36 | + * Initialize from ASN.1. |
|
| 37 | + * |
|
| 38 | + * @param Sequence $seq |
|
| 39 | + * @return self |
|
| 40 | + */ |
|
| 41 | + public static function fromASN1(Sequence $seq): self |
|
| 42 | + { |
|
| 43 | + $subtrees = array_map( |
|
| 44 | + function (UnspecifiedType $el) { |
|
| 45 | + return GeneralSubtree::fromASN1($el->asSequence()); |
|
| 46 | + }, $seq->elements()); |
|
| 47 | + if (!count($subtrees)) { |
|
| 48 | + throw new \UnexpectedValueException( |
|
| 49 | + "GeneralSubtrees must contain at least one GeneralSubtree."); |
|
| 50 | + } |
|
| 51 | + return new self(...$subtrees); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Get all subtrees. |
|
| 56 | - * |
|
| 57 | - * @return GeneralSubtree[] |
|
| 58 | - */ |
|
| 59 | - public function all(): array |
|
| 60 | - { |
|
| 61 | - return $this->_subtrees; |
|
| 62 | - } |
|
| 54 | + /** |
|
| 55 | + * Get all subtrees. |
|
| 56 | + * |
|
| 57 | + * @return GeneralSubtree[] |
|
| 58 | + */ |
|
| 59 | + public function all(): array |
|
| 60 | + { |
|
| 61 | + return $this->_subtrees; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Generate ASN.1 structure. |
|
| 66 | - * |
|
| 67 | - * @return Sequence |
|
| 68 | - */ |
|
| 69 | - public function toASN1(): Sequence |
|
| 70 | - { |
|
| 71 | - if (!count($this->_subtrees)) { |
|
| 72 | - throw new \LogicException("No subtrees."); |
|
| 73 | - } |
|
| 74 | - $elements = array_map( |
|
| 75 | - function (GeneralSubtree $gs) { |
|
| 76 | - return $gs->toASN1(); |
|
| 77 | - }, $this->_subtrees); |
|
| 78 | - return new Sequence(...$elements); |
|
| 79 | - } |
|
| 64 | + /** |
|
| 65 | + * Generate ASN.1 structure. |
|
| 66 | + * |
|
| 67 | + * @return Sequence |
|
| 68 | + */ |
|
| 69 | + public function toASN1(): Sequence |
|
| 70 | + { |
|
| 71 | + if (!count($this->_subtrees)) { |
|
| 72 | + throw new \LogicException("No subtrees."); |
|
| 73 | + } |
|
| 74 | + $elements = array_map( |
|
| 75 | + function (GeneralSubtree $gs) { |
|
| 76 | + return $gs->toASN1(); |
|
| 77 | + }, $this->_subtrees); |
|
| 78 | + return new Sequence(...$elements); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * |
|
| 83 | - * @see \Countable::count() |
|
| 84 | - * @return int |
|
| 85 | - */ |
|
| 86 | - public function count(): int |
|
| 87 | - { |
|
| 88 | - return count($this->_subtrees); |
|
| 89 | - } |
|
| 81 | + /** |
|
| 82 | + * |
|
| 83 | + * @see \Countable::count() |
|
| 84 | + * @return int |
|
| 85 | + */ |
|
| 86 | + public function count(): int |
|
| 87 | + { |
|
| 88 | + return count($this->_subtrees); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Get iterator for subtrees. |
|
| 93 | - * |
|
| 94 | - * @see \IteratorAggregate::getIterator() |
|
| 95 | - * @return \ArrayIterator |
|
| 96 | - */ |
|
| 97 | - public function getIterator(): \ArrayIterator |
|
| 98 | - { |
|
| 99 | - return new \ArrayIterator($this->_subtrees); |
|
| 100 | - } |
|
| 91 | + /** |
|
| 92 | + * Get iterator for subtrees. |
|
| 93 | + * |
|
| 94 | + * @see \IteratorAggregate::getIterator() |
|
| 95 | + * @return \ArrayIterator |
|
| 96 | + */ |
|
| 97 | + public function getIterator(): \ArrayIterator |
|
| 98 | + { |
|
| 99 | + return new \ArrayIterator($this->_subtrees); |
|
| 100 | + } |
|
| 101 | 101 | } |
@@ -14,95 +14,95 @@ |
||
| 14 | 14 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.13 |
| 15 | 15 | */ |
| 16 | 16 | class CRLDistributionPointsExtension extends Extension implements |
| 17 | - \Countable, |
|
| 18 | - \IteratorAggregate |
|
| 17 | + \Countable, |
|
| 18 | + \IteratorAggregate |
|
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Distribution points. |
|
| 22 | - * |
|
| 23 | - * @var DistributionPoint[] $_distributionPoints |
|
| 24 | - */ |
|
| 25 | - protected $_distributionPoints; |
|
| 20 | + /** |
|
| 21 | + * Distribution points. |
|
| 22 | + * |
|
| 23 | + * @var DistributionPoint[] $_distributionPoints |
|
| 24 | + */ |
|
| 25 | + protected $_distributionPoints; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Constructor. |
|
| 29 | - * |
|
| 30 | - * @param bool $critical |
|
| 31 | - * @param DistributionPoint ...$distribution_points |
|
| 32 | - */ |
|
| 33 | - public function __construct(bool $critical, |
|
| 34 | - DistributionPoint ...$distribution_points) |
|
| 35 | - { |
|
| 36 | - parent::__construct(self::OID_CRL_DISTRIBUTION_POINTS, $critical); |
|
| 37 | - $this->_distributionPoints = $distribution_points; |
|
| 38 | - } |
|
| 27 | + /** |
|
| 28 | + * Constructor. |
|
| 29 | + * |
|
| 30 | + * @param bool $critical |
|
| 31 | + * @param DistributionPoint ...$distribution_points |
|
| 32 | + */ |
|
| 33 | + public function __construct(bool $critical, |
|
| 34 | + DistributionPoint ...$distribution_points) |
|
| 35 | + { |
|
| 36 | + parent::__construct(self::OID_CRL_DISTRIBUTION_POINTS, $critical); |
|
| 37 | + $this->_distributionPoints = $distribution_points; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * |
|
| 42 | - * {@inheritdoc} |
|
| 43 | - * @return self |
|
| 44 | - */ |
|
| 45 | - protected static function _fromDER(string $data, bool $critical): self |
|
| 46 | - { |
|
| 47 | - $dps = array_map( |
|
| 48 | - function (UnspecifiedType $el) { |
|
| 49 | - return DistributionPoint::fromASN1($el->asSequence()); |
|
| 50 | - }, Sequence::fromDER($data)->elements()); |
|
| 51 | - if (!count($dps)) { |
|
| 52 | - throw new \UnexpectedValueException( |
|
| 53 | - "CRLDistributionPoints must have" . |
|
| 54 | - " at least one DistributionPoint."); |
|
| 55 | - } |
|
| 56 | - // late static bound, extended by Freshest CRL extension |
|
| 57 | - return new static($critical, ...$dps); |
|
| 58 | - } |
|
| 40 | + /** |
|
| 41 | + * |
|
| 42 | + * {@inheritdoc} |
|
| 43 | + * @return self |
|
| 44 | + */ |
|
| 45 | + protected static function _fromDER(string $data, bool $critical): self |
|
| 46 | + { |
|
| 47 | + $dps = array_map( |
|
| 48 | + function (UnspecifiedType $el) { |
|
| 49 | + return DistributionPoint::fromASN1($el->asSequence()); |
|
| 50 | + }, Sequence::fromDER($data)->elements()); |
|
| 51 | + if (!count($dps)) { |
|
| 52 | + throw new \UnexpectedValueException( |
|
| 53 | + "CRLDistributionPoints must have" . |
|
| 54 | + " at least one DistributionPoint."); |
|
| 55 | + } |
|
| 56 | + // late static bound, extended by Freshest CRL extension |
|
| 57 | + return new static($critical, ...$dps); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * |
|
| 62 | - * {@inheritdoc} |
|
| 63 | - * @return Sequence |
|
| 64 | - */ |
|
| 65 | - protected function _valueASN1(): Sequence |
|
| 66 | - { |
|
| 67 | - if (!count($this->_distributionPoints)) { |
|
| 68 | - throw new \LogicException("No distribution points."); |
|
| 69 | - } |
|
| 70 | - $elements = array_map( |
|
| 71 | - function (DistributionPoint $dp) { |
|
| 72 | - return $dp->toASN1(); |
|
| 73 | - }, $this->_distributionPoints); |
|
| 74 | - return new Sequence(...$elements); |
|
| 75 | - } |
|
| 60 | + /** |
|
| 61 | + * |
|
| 62 | + * {@inheritdoc} |
|
| 63 | + * @return Sequence |
|
| 64 | + */ |
|
| 65 | + protected function _valueASN1(): Sequence |
|
| 66 | + { |
|
| 67 | + if (!count($this->_distributionPoints)) { |
|
| 68 | + throw new \LogicException("No distribution points."); |
|
| 69 | + } |
|
| 70 | + $elements = array_map( |
|
| 71 | + function (DistributionPoint $dp) { |
|
| 72 | + return $dp->toASN1(); |
|
| 73 | + }, $this->_distributionPoints); |
|
| 74 | + return new Sequence(...$elements); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Get distribution points. |
|
| 79 | - * |
|
| 80 | - * @return DistributionPoint[] |
|
| 81 | - */ |
|
| 82 | - public function distributionPoints(): array |
|
| 83 | - { |
|
| 84 | - return $this->_distributionPoints; |
|
| 85 | - } |
|
| 77 | + /** |
|
| 78 | + * Get distribution points. |
|
| 79 | + * |
|
| 80 | + * @return DistributionPoint[] |
|
| 81 | + */ |
|
| 82 | + public function distributionPoints(): array |
|
| 83 | + { |
|
| 84 | + return $this->_distributionPoints; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * Get the number of distribution points. |
|
| 89 | - * |
|
| 90 | - * @see \Countable::count() |
|
| 91 | - * @return int |
|
| 92 | - */ |
|
| 93 | - public function count(): int |
|
| 94 | - { |
|
| 95 | - return count($this->_distributionPoints); |
|
| 96 | - } |
|
| 87 | + /** |
|
| 88 | + * Get the number of distribution points. |
|
| 89 | + * |
|
| 90 | + * @see \Countable::count() |
|
| 91 | + * @return int |
|
| 92 | + */ |
|
| 93 | + public function count(): int |
|
| 94 | + { |
|
| 95 | + return count($this->_distributionPoints); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Get iterator for distribution points. |
|
| 100 | - * |
|
| 101 | - * @see \IteratorAggregate::getIterator() |
|
| 102 | - * @return \ArrayIterator |
|
| 103 | - */ |
|
| 104 | - public function getIterator(): \ArrayIterator |
|
| 105 | - { |
|
| 106 | - return new \ArrayIterator($this->_distributionPoints); |
|
| 107 | - } |
|
| 98 | + /** |
|
| 99 | + * Get iterator for distribution points. |
|
| 100 | + * |
|
| 101 | + * @see \IteratorAggregate::getIterator() |
|
| 102 | + * @return \ArrayIterator |
|
| 103 | + */ |
|
| 104 | + public function getIterator(): \ArrayIterator |
|
| 105 | + { |
|
| 106 | + return new \ArrayIterator($this->_distributionPoints); |
|
| 107 | + } |
|
| 108 | 108 | } |
@@ -19,139 +19,139 @@ |
||
| 19 | 19 | * @link https://tools.ietf.org/html/rfc5755#section-4.3.2 |
| 20 | 20 | */ |
| 21 | 21 | class TargetInformationExtension extends Extension implements |
| 22 | - \Countable, |
|
| 23 | - \IteratorAggregate |
|
| 22 | + \Countable, |
|
| 23 | + \IteratorAggregate |
|
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * Targets elements. |
|
| 27 | - * |
|
| 28 | - * @var Targets[] $_targets |
|
| 29 | - */ |
|
| 30 | - protected $_targets; |
|
| 25 | + /** |
|
| 26 | + * Targets elements. |
|
| 27 | + * |
|
| 28 | + * @var Targets[] $_targets |
|
| 29 | + */ |
|
| 30 | + protected $_targets; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Targets[] merged to single Targets. |
|
| 34 | - * |
|
| 35 | - * @var Targets|null |
|
| 36 | - */ |
|
| 37 | - private $_merged; |
|
| 32 | + /** |
|
| 33 | + * Targets[] merged to single Targets. |
|
| 34 | + * |
|
| 35 | + * @var Targets|null |
|
| 36 | + */ |
|
| 37 | + private $_merged; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Constructor. |
|
| 41 | - * |
|
| 42 | - * @param bool $critical |
|
| 43 | - * @param Targets ...$targets |
|
| 44 | - */ |
|
| 45 | - public function __construct(bool $critical, Targets ...$targets) |
|
| 46 | - { |
|
| 47 | - parent::__construct(self::OID_TARGET_INFORMATION, $critical); |
|
| 48 | - $this->_targets = $targets; |
|
| 49 | - } |
|
| 39 | + /** |
|
| 40 | + * Constructor. |
|
| 41 | + * |
|
| 42 | + * @param bool $critical |
|
| 43 | + * @param Targets ...$targets |
|
| 44 | + */ |
|
| 45 | + public function __construct(bool $critical, Targets ...$targets) |
|
| 46 | + { |
|
| 47 | + parent::__construct(self::OID_TARGET_INFORMATION, $critical); |
|
| 48 | + $this->_targets = $targets; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Initialize from one or more Target objects. |
|
| 53 | - * |
|
| 54 | - * Extension criticality shall be set to true as specified by RFC 5755. |
|
| 55 | - * |
|
| 56 | - * @param Target ...$target |
|
| 57 | - * @return TargetInformationExtension |
|
| 58 | - */ |
|
| 59 | - public static function fromTargets(Target ...$target): self |
|
| 60 | - { |
|
| 61 | - return new self(true, new Targets(...$target)); |
|
| 62 | - } |
|
| 51 | + /** |
|
| 52 | + * Initialize from one or more Target objects. |
|
| 53 | + * |
|
| 54 | + * Extension criticality shall be set to true as specified by RFC 5755. |
|
| 55 | + * |
|
| 56 | + * @param Target ...$target |
|
| 57 | + * @return TargetInformationExtension |
|
| 58 | + */ |
|
| 59 | + public static function fromTargets(Target ...$target): self |
|
| 60 | + { |
|
| 61 | + return new self(true, new Targets(...$target)); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Reset internal state on clone. |
|
| 66 | - */ |
|
| 67 | - public function __clone() |
|
| 68 | - { |
|
| 69 | - $this->_merged = null; |
|
| 70 | - } |
|
| 64 | + /** |
|
| 65 | + * Reset internal state on clone. |
|
| 66 | + */ |
|
| 67 | + public function __clone() |
|
| 68 | + { |
|
| 69 | + $this->_merged = null; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * |
|
| 74 | - * {@inheritdoc} |
|
| 75 | - * @return self |
|
| 76 | - */ |
|
| 77 | - protected static function _fromDER(string $data, bool $critical): self |
|
| 78 | - { |
|
| 79 | - $targets = array_map( |
|
| 80 | - function (UnspecifiedType $el) { |
|
| 81 | - return Targets::fromASN1($el->asSequence()); |
|
| 82 | - }, Sequence::fromDER($data)->elements()); |
|
| 83 | - return new self($critical, ...$targets); |
|
| 84 | - } |
|
| 72 | + /** |
|
| 73 | + * |
|
| 74 | + * {@inheritdoc} |
|
| 75 | + * @return self |
|
| 76 | + */ |
|
| 77 | + protected static function _fromDER(string $data, bool $critical): self |
|
| 78 | + { |
|
| 79 | + $targets = array_map( |
|
| 80 | + function (UnspecifiedType $el) { |
|
| 81 | + return Targets::fromASN1($el->asSequence()); |
|
| 82 | + }, Sequence::fromDER($data)->elements()); |
|
| 83 | + return new self($critical, ...$targets); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Get all targets. |
|
| 88 | - * |
|
| 89 | - * @return Targets |
|
| 90 | - */ |
|
| 91 | - public function targets(): Targets |
|
| 92 | - { |
|
| 93 | - if (!isset($this->_merged)) { |
|
| 94 | - $a = array(); |
|
| 95 | - foreach ($this->_targets as $targets) { |
|
| 96 | - $a = array_merge($a, $targets->all()); |
|
| 97 | - } |
|
| 98 | - $this->_merged = new Targets(...$a); |
|
| 99 | - } |
|
| 100 | - return $this->_merged; |
|
| 101 | - } |
|
| 86 | + /** |
|
| 87 | + * Get all targets. |
|
| 88 | + * |
|
| 89 | + * @return Targets |
|
| 90 | + */ |
|
| 91 | + public function targets(): Targets |
|
| 92 | + { |
|
| 93 | + if (!isset($this->_merged)) { |
|
| 94 | + $a = array(); |
|
| 95 | + foreach ($this->_targets as $targets) { |
|
| 96 | + $a = array_merge($a, $targets->all()); |
|
| 97 | + } |
|
| 98 | + $this->_merged = new Targets(...$a); |
|
| 99 | + } |
|
| 100 | + return $this->_merged; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Get all name targets. |
|
| 105 | - * |
|
| 106 | - * @return Target[] |
|
| 107 | - */ |
|
| 108 | - public function names(): array |
|
| 109 | - { |
|
| 110 | - return $this->targets()->nameTargets(); |
|
| 111 | - } |
|
| 103 | + /** |
|
| 104 | + * Get all name targets. |
|
| 105 | + * |
|
| 106 | + * @return Target[] |
|
| 107 | + */ |
|
| 108 | + public function names(): array |
|
| 109 | + { |
|
| 110 | + return $this->targets()->nameTargets(); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * Get all group targets. |
|
| 115 | - * |
|
| 116 | - * @return Target[] |
|
| 117 | - */ |
|
| 118 | - public function groups(): array |
|
| 119 | - { |
|
| 120 | - return $this->targets()->groupTargets(); |
|
| 121 | - } |
|
| 113 | + /** |
|
| 114 | + * Get all group targets. |
|
| 115 | + * |
|
| 116 | + * @return Target[] |
|
| 117 | + */ |
|
| 118 | + public function groups(): array |
|
| 119 | + { |
|
| 120 | + return $this->targets()->groupTargets(); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * |
|
| 125 | - * @see \X509\Certificate\Extension\Extension::_valueASN1() |
|
| 126 | - * @return Sequence |
|
| 127 | - */ |
|
| 128 | - protected function _valueASN1(): Sequence |
|
| 129 | - { |
|
| 130 | - $elements = array_map( |
|
| 131 | - function (Targets $targets) { |
|
| 132 | - return $targets->toASN1(); |
|
| 133 | - }, $this->_targets); |
|
| 134 | - return new Sequence(...$elements); |
|
| 135 | - } |
|
| 123 | + /** |
|
| 124 | + * |
|
| 125 | + * @see \X509\Certificate\Extension\Extension::_valueASN1() |
|
| 126 | + * @return Sequence |
|
| 127 | + */ |
|
| 128 | + protected function _valueASN1(): Sequence |
|
| 129 | + { |
|
| 130 | + $elements = array_map( |
|
| 131 | + function (Targets $targets) { |
|
| 132 | + return $targets->toASN1(); |
|
| 133 | + }, $this->_targets); |
|
| 134 | + return new Sequence(...$elements); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * |
|
| 139 | - * @see \Countable::count() |
|
| 140 | - * @return int |
|
| 141 | - */ |
|
| 142 | - public function count(): int |
|
| 143 | - { |
|
| 144 | - return count($this->targets()); |
|
| 145 | - } |
|
| 137 | + /** |
|
| 138 | + * |
|
| 139 | + * @see \Countable::count() |
|
| 140 | + * @return int |
|
| 141 | + */ |
|
| 142 | + public function count(): int |
|
| 143 | + { |
|
| 144 | + return count($this->targets()); |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Get iterator for targets. |
|
| 149 | - * |
|
| 150 | - * @see \IteratorAggregate::getIterator() |
|
| 151 | - * @return \ArrayIterator |
|
| 152 | - */ |
|
| 153 | - public function getIterator(): \ArrayIterator |
|
| 154 | - { |
|
| 155 | - return new \ArrayIterator($this->targets()->all()); |
|
| 156 | - } |
|
| 147 | + /** |
|
| 148 | + * Get iterator for targets. |
|
| 149 | + * |
|
| 150 | + * @see \IteratorAggregate::getIterator() |
|
| 151 | + * @return \ArrayIterator |
|
| 152 | + */ |
|
| 153 | + public function getIterator(): \ArrayIterator |
|
| 154 | + { |
|
| 155 | + return new \ArrayIterator($this->targets()->all()); |
|
| 156 | + } |
|
| 157 | 157 | } |
@@ -16,207 +16,207 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class PolicyInformation implements \Countable, \IteratorAggregate |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Wildcard policy. |
|
| 21 | - * |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - const OID_ANY_POLICY = "2.5.29.32.0"; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Policy identifier. |
|
| 28 | - * |
|
| 29 | - * @var string $_oid |
|
| 30 | - */ |
|
| 31 | - protected $_oid; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Policy qualifiers. |
|
| 35 | - * |
|
| 36 | - * @var PolicyQualifierInfo[] $_qualifiers |
|
| 37 | - */ |
|
| 38 | - protected $_qualifiers; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Constructor. |
|
| 42 | - * |
|
| 43 | - * @param string $oid |
|
| 44 | - * @param PolicyQualifierInfo ...$qualifiers |
|
| 45 | - */ |
|
| 46 | - public function __construct(string $oid, PolicyQualifierInfo ...$qualifiers) |
|
| 47 | - { |
|
| 48 | - $this->_oid = $oid; |
|
| 49 | - $this->_qualifiers = array(); |
|
| 50 | - foreach ($qualifiers as $qual) { |
|
| 51 | - $this->_qualifiers[$qual->oid()] = $qual; |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Initialize from ASN.1. |
|
| 57 | - * |
|
| 58 | - * @param Sequence $seq |
|
| 59 | - * @return self |
|
| 60 | - */ |
|
| 61 | - public static function fromASN1(Sequence $seq): self |
|
| 62 | - { |
|
| 63 | - $oid = $seq->at(0) |
|
| 64 | - ->asObjectIdentifier() |
|
| 65 | - ->oid(); |
|
| 66 | - $qualifiers = array(); |
|
| 67 | - if (count($seq) > 1) { |
|
| 68 | - $qualifiers = array_map( |
|
| 69 | - function (UnspecifiedType $el) { |
|
| 70 | - return PolicyQualifierInfo::fromASN1($el->asSequence()); |
|
| 71 | - }, |
|
| 72 | - $seq->at(1) |
|
| 73 | - ->asSequence() |
|
| 74 | - ->elements()); |
|
| 75 | - } |
|
| 76 | - return new self($oid, ...$qualifiers); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Get policy identifier. |
|
| 81 | - * |
|
| 82 | - * @return string |
|
| 83 | - */ |
|
| 84 | - public function oid(): string |
|
| 85 | - { |
|
| 86 | - return $this->_oid; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Check whether this policy is anyPolicy. |
|
| 91 | - * |
|
| 92 | - * @return bool |
|
| 93 | - */ |
|
| 94 | - public function isAnyPolicy(): bool |
|
| 95 | - { |
|
| 96 | - return self::OID_ANY_POLICY === $this->_oid; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Get policy qualifiers. |
|
| 101 | - * |
|
| 102 | - * @return PolicyQualifierInfo[] |
|
| 103 | - */ |
|
| 104 | - public function qualifiers(): array |
|
| 105 | - { |
|
| 106 | - return array_values($this->_qualifiers); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * Check whether qualifier is present. |
|
| 111 | - * |
|
| 112 | - * @param string $oid |
|
| 113 | - * @return boolean |
|
| 114 | - */ |
|
| 115 | - public function has(string $oid): bool |
|
| 116 | - { |
|
| 117 | - return isset($this->_qualifiers[$oid]); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Get qualifier by OID. |
|
| 122 | - * |
|
| 123 | - * @param string $oid |
|
| 124 | - * @throws \OutOfBoundsException |
|
| 125 | - * @return PolicyQualifierInfo |
|
| 126 | - */ |
|
| 127 | - public function get(string $oid): PolicyQualifierInfo |
|
| 128 | - { |
|
| 129 | - if (!$this->has($oid)) { |
|
| 130 | - throw new \LogicException("No $oid qualifier."); |
|
| 131 | - } |
|
| 132 | - return $this->_qualifiers[$oid]; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Check whether CPS qualifier is present. |
|
| 137 | - * |
|
| 138 | - * @return bool |
|
| 139 | - */ |
|
| 140 | - public function hasCPSQualifier(): bool |
|
| 141 | - { |
|
| 142 | - return $this->has(PolicyQualifierInfo::OID_CPS); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * Get CPS qualifier. |
|
| 147 | - * |
|
| 148 | - * @throws \LogicException |
|
| 149 | - * @return CPSQualifier |
|
| 150 | - */ |
|
| 151 | - public function CPSQualifier(): CPSQualifier |
|
| 152 | - { |
|
| 153 | - if (!$this->hasCPSQualifier()) { |
|
| 154 | - throw new \LogicException("CPS qualifier not set."); |
|
| 155 | - } |
|
| 156 | - return $this->get(PolicyQualifierInfo::OID_CPS); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * Check whether user notice qualifier is present. |
|
| 161 | - * |
|
| 162 | - * @return bool |
|
| 163 | - */ |
|
| 164 | - public function hasUserNoticeQualifier(): bool |
|
| 165 | - { |
|
| 166 | - return $this->has(PolicyQualifierInfo::OID_UNOTICE); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * Get user notice qualifier. |
|
| 171 | - * |
|
| 172 | - * @throws \LogicException |
|
| 173 | - * @return UserNoticeQualifier |
|
| 174 | - */ |
|
| 175 | - public function userNoticeQualifier(): UserNoticeQualifier |
|
| 176 | - { |
|
| 177 | - if (!$this->hasUserNoticeQualifier()) { |
|
| 178 | - throw new \LogicException("User notice qualifier not set."); |
|
| 179 | - } |
|
| 180 | - return $this->get(PolicyQualifierInfo::OID_UNOTICE); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * Get ASN.1 structure. |
|
| 185 | - * |
|
| 186 | - * @return Sequence |
|
| 187 | - */ |
|
| 188 | - public function toASN1(): Sequence |
|
| 189 | - { |
|
| 190 | - $elements = array(new ObjectIdentifier($this->_oid)); |
|
| 191 | - if (count($this->_qualifiers)) { |
|
| 192 | - $qualifiers = array_map( |
|
| 193 | - function (PolicyQualifierInfo $pqi) { |
|
| 194 | - return $pqi->toASN1(); |
|
| 195 | - }, array_values($this->_qualifiers)); |
|
| 196 | - $elements[] = new Sequence(...$qualifiers); |
|
| 197 | - } |
|
| 198 | - return new Sequence(...$elements); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Get number of qualifiers. |
|
| 203 | - * |
|
| 204 | - * @see \Countable::count() |
|
| 205 | - * @return int |
|
| 206 | - */ |
|
| 207 | - public function count(): int |
|
| 208 | - { |
|
| 209 | - return count($this->_qualifiers); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * Get iterator for qualifiers. |
|
| 214 | - * |
|
| 215 | - * @see \IteratorAggregate::getIterator() |
|
| 216 | - * @return \ArrayIterator |
|
| 217 | - */ |
|
| 218 | - public function getIterator(): \ArrayIterator |
|
| 219 | - { |
|
| 220 | - return new \ArrayIterator($this->_qualifiers); |
|
| 221 | - } |
|
| 19 | + /** |
|
| 20 | + * Wildcard policy. |
|
| 21 | + * |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + const OID_ANY_POLICY = "2.5.29.32.0"; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Policy identifier. |
|
| 28 | + * |
|
| 29 | + * @var string $_oid |
|
| 30 | + */ |
|
| 31 | + protected $_oid; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Policy qualifiers. |
|
| 35 | + * |
|
| 36 | + * @var PolicyQualifierInfo[] $_qualifiers |
|
| 37 | + */ |
|
| 38 | + protected $_qualifiers; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Constructor. |
|
| 42 | + * |
|
| 43 | + * @param string $oid |
|
| 44 | + * @param PolicyQualifierInfo ...$qualifiers |
|
| 45 | + */ |
|
| 46 | + public function __construct(string $oid, PolicyQualifierInfo ...$qualifiers) |
|
| 47 | + { |
|
| 48 | + $this->_oid = $oid; |
|
| 49 | + $this->_qualifiers = array(); |
|
| 50 | + foreach ($qualifiers as $qual) { |
|
| 51 | + $this->_qualifiers[$qual->oid()] = $qual; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Initialize from ASN.1. |
|
| 57 | + * |
|
| 58 | + * @param Sequence $seq |
|
| 59 | + * @return self |
|
| 60 | + */ |
|
| 61 | + public static function fromASN1(Sequence $seq): self |
|
| 62 | + { |
|
| 63 | + $oid = $seq->at(0) |
|
| 64 | + ->asObjectIdentifier() |
|
| 65 | + ->oid(); |
|
| 66 | + $qualifiers = array(); |
|
| 67 | + if (count($seq) > 1) { |
|
| 68 | + $qualifiers = array_map( |
|
| 69 | + function (UnspecifiedType $el) { |
|
| 70 | + return PolicyQualifierInfo::fromASN1($el->asSequence()); |
|
| 71 | + }, |
|
| 72 | + $seq->at(1) |
|
| 73 | + ->asSequence() |
|
| 74 | + ->elements()); |
|
| 75 | + } |
|
| 76 | + return new self($oid, ...$qualifiers); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Get policy identifier. |
|
| 81 | + * |
|
| 82 | + * @return string |
|
| 83 | + */ |
|
| 84 | + public function oid(): string |
|
| 85 | + { |
|
| 86 | + return $this->_oid; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Check whether this policy is anyPolicy. |
|
| 91 | + * |
|
| 92 | + * @return bool |
|
| 93 | + */ |
|
| 94 | + public function isAnyPolicy(): bool |
|
| 95 | + { |
|
| 96 | + return self::OID_ANY_POLICY === $this->_oid; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Get policy qualifiers. |
|
| 101 | + * |
|
| 102 | + * @return PolicyQualifierInfo[] |
|
| 103 | + */ |
|
| 104 | + public function qualifiers(): array |
|
| 105 | + { |
|
| 106 | + return array_values($this->_qualifiers); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * Check whether qualifier is present. |
|
| 111 | + * |
|
| 112 | + * @param string $oid |
|
| 113 | + * @return boolean |
|
| 114 | + */ |
|
| 115 | + public function has(string $oid): bool |
|
| 116 | + { |
|
| 117 | + return isset($this->_qualifiers[$oid]); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Get qualifier by OID. |
|
| 122 | + * |
|
| 123 | + * @param string $oid |
|
| 124 | + * @throws \OutOfBoundsException |
|
| 125 | + * @return PolicyQualifierInfo |
|
| 126 | + */ |
|
| 127 | + public function get(string $oid): PolicyQualifierInfo |
|
| 128 | + { |
|
| 129 | + if (!$this->has($oid)) { |
|
| 130 | + throw new \LogicException("No $oid qualifier."); |
|
| 131 | + } |
|
| 132 | + return $this->_qualifiers[$oid]; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Check whether CPS qualifier is present. |
|
| 137 | + * |
|
| 138 | + * @return bool |
|
| 139 | + */ |
|
| 140 | + public function hasCPSQualifier(): bool |
|
| 141 | + { |
|
| 142 | + return $this->has(PolicyQualifierInfo::OID_CPS); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * Get CPS qualifier. |
|
| 147 | + * |
|
| 148 | + * @throws \LogicException |
|
| 149 | + * @return CPSQualifier |
|
| 150 | + */ |
|
| 151 | + public function CPSQualifier(): CPSQualifier |
|
| 152 | + { |
|
| 153 | + if (!$this->hasCPSQualifier()) { |
|
| 154 | + throw new \LogicException("CPS qualifier not set."); |
|
| 155 | + } |
|
| 156 | + return $this->get(PolicyQualifierInfo::OID_CPS); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * Check whether user notice qualifier is present. |
|
| 161 | + * |
|
| 162 | + * @return bool |
|
| 163 | + */ |
|
| 164 | + public function hasUserNoticeQualifier(): bool |
|
| 165 | + { |
|
| 166 | + return $this->has(PolicyQualifierInfo::OID_UNOTICE); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * Get user notice qualifier. |
|
| 171 | + * |
|
| 172 | + * @throws \LogicException |
|
| 173 | + * @return UserNoticeQualifier |
|
| 174 | + */ |
|
| 175 | + public function userNoticeQualifier(): UserNoticeQualifier |
|
| 176 | + { |
|
| 177 | + if (!$this->hasUserNoticeQualifier()) { |
|
| 178 | + throw new \LogicException("User notice qualifier not set."); |
|
| 179 | + } |
|
| 180 | + return $this->get(PolicyQualifierInfo::OID_UNOTICE); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * Get ASN.1 structure. |
|
| 185 | + * |
|
| 186 | + * @return Sequence |
|
| 187 | + */ |
|
| 188 | + public function toASN1(): Sequence |
|
| 189 | + { |
|
| 190 | + $elements = array(new ObjectIdentifier($this->_oid)); |
|
| 191 | + if (count($this->_qualifiers)) { |
|
| 192 | + $qualifiers = array_map( |
|
| 193 | + function (PolicyQualifierInfo $pqi) { |
|
| 194 | + return $pqi->toASN1(); |
|
| 195 | + }, array_values($this->_qualifiers)); |
|
| 196 | + $elements[] = new Sequence(...$qualifiers); |
|
| 197 | + } |
|
| 198 | + return new Sequence(...$elements); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * Get number of qualifiers. |
|
| 203 | + * |
|
| 204 | + * @see \Countable::count() |
|
| 205 | + * @return int |
|
| 206 | + */ |
|
| 207 | + public function count(): int |
|
| 208 | + { |
|
| 209 | + return count($this->_qualifiers); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * Get iterator for qualifiers. |
|
| 214 | + * |
|
| 215 | + * @see \IteratorAggregate::getIterator() |
|
| 216 | + * @return \ArrayIterator |
|
| 217 | + */ |
|
| 218 | + public function getIterator(): \ArrayIterator |
|
| 219 | + { |
|
| 220 | + return new \ArrayIterator($this->_qualifiers); |
|
| 221 | + } |
|
| 222 | 222 | } |
@@ -16,83 +16,83 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class NoticeReference |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Organization. |
|
| 21 | - * |
|
| 22 | - * @var DisplayText $_organization |
|
| 23 | - */ |
|
| 24 | - protected $_organization; |
|
| 19 | + /** |
|
| 20 | + * Organization. |
|
| 21 | + * |
|
| 22 | + * @var DisplayText $_organization |
|
| 23 | + */ |
|
| 24 | + protected $_organization; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Notification reference numbers. |
|
| 28 | - * |
|
| 29 | - * @var int[] $_numbers |
|
| 30 | - */ |
|
| 31 | - protected $_numbers; |
|
| 26 | + /** |
|
| 27 | + * Notification reference numbers. |
|
| 28 | + * |
|
| 29 | + * @var int[] $_numbers |
|
| 30 | + */ |
|
| 31 | + protected $_numbers; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Constructor. |
|
| 35 | - * |
|
| 36 | - * @param DisplayText $organization |
|
| 37 | - * @param int ...$numbers |
|
| 38 | - */ |
|
| 39 | - public function __construct(DisplayText $organization, int ...$numbers) |
|
| 40 | - { |
|
| 41 | - $this->_organization = $organization; |
|
| 42 | - $this->_numbers = $numbers; |
|
| 43 | - } |
|
| 33 | + /** |
|
| 34 | + * Constructor. |
|
| 35 | + * |
|
| 36 | + * @param DisplayText $organization |
|
| 37 | + * @param int ...$numbers |
|
| 38 | + */ |
|
| 39 | + public function __construct(DisplayText $organization, int ...$numbers) |
|
| 40 | + { |
|
| 41 | + $this->_organization = $organization; |
|
| 42 | + $this->_numbers = $numbers; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Initialize from ASN.1. |
|
| 47 | - * |
|
| 48 | - * @param Sequence $seq |
|
| 49 | - * @return self |
|
| 50 | - */ |
|
| 51 | - public static function fromASN1(Sequence $seq): self |
|
| 52 | - { |
|
| 53 | - $org = DisplayText::fromASN1($seq->at(0)->asString()); |
|
| 54 | - $numbers = array_map( |
|
| 55 | - function (UnspecifiedType $el) { |
|
| 56 | - return $el->asInteger()->intNumber(); |
|
| 57 | - }, |
|
| 58 | - $seq->at(1) |
|
| 59 | - ->asSequence() |
|
| 60 | - ->elements()); |
|
| 61 | - return new self($org, ...$numbers); |
|
| 62 | - } |
|
| 45 | + /** |
|
| 46 | + * Initialize from ASN.1. |
|
| 47 | + * |
|
| 48 | + * @param Sequence $seq |
|
| 49 | + * @return self |
|
| 50 | + */ |
|
| 51 | + public static function fromASN1(Sequence $seq): self |
|
| 52 | + { |
|
| 53 | + $org = DisplayText::fromASN1($seq->at(0)->asString()); |
|
| 54 | + $numbers = array_map( |
|
| 55 | + function (UnspecifiedType $el) { |
|
| 56 | + return $el->asInteger()->intNumber(); |
|
| 57 | + }, |
|
| 58 | + $seq->at(1) |
|
| 59 | + ->asSequence() |
|
| 60 | + ->elements()); |
|
| 61 | + return new self($org, ...$numbers); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Get reference organization. |
|
| 66 | - * |
|
| 67 | - * @return DisplayText |
|
| 68 | - */ |
|
| 69 | - public function organization(): DisplayText |
|
| 70 | - { |
|
| 71 | - return $this->_organization; |
|
| 72 | - } |
|
| 64 | + /** |
|
| 65 | + * Get reference organization. |
|
| 66 | + * |
|
| 67 | + * @return DisplayText |
|
| 68 | + */ |
|
| 69 | + public function organization(): DisplayText |
|
| 70 | + { |
|
| 71 | + return $this->_organization; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Get reference numbers. |
|
| 76 | - * |
|
| 77 | - * @return int[] |
|
| 78 | - */ |
|
| 79 | - public function numbers(): array |
|
| 80 | - { |
|
| 81 | - return $this->_numbers; |
|
| 82 | - } |
|
| 74 | + /** |
|
| 75 | + * Get reference numbers. |
|
| 76 | + * |
|
| 77 | + * @return int[] |
|
| 78 | + */ |
|
| 79 | + public function numbers(): array |
|
| 80 | + { |
|
| 81 | + return $this->_numbers; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Generate ASN.1 structure. |
|
| 86 | - * |
|
| 87 | - * @return Sequence |
|
| 88 | - */ |
|
| 89 | - public function toASN1(): Sequence |
|
| 90 | - { |
|
| 91 | - $org = $this->_organization->toASN1(); |
|
| 92 | - $nums = array_map( |
|
| 93 | - function ($number) { |
|
| 94 | - return new Integer($number); |
|
| 95 | - }, $this->_numbers); |
|
| 96 | - return new Sequence($org, new Sequence(...$nums)); |
|
| 97 | - } |
|
| 84 | + /** |
|
| 85 | + * Generate ASN.1 structure. |
|
| 86 | + * |
|
| 87 | + * @return Sequence |
|
| 88 | + */ |
|
| 89 | + public function toASN1(): Sequence |
|
| 90 | + { |
|
| 91 | + $org = $this->_organization->toASN1(); |
|
| 92 | + $nums = array_map( |
|
| 93 | + function ($number) { |
|
| 94 | + return new Integer($number); |
|
| 95 | + }, $this->_numbers); |
|
| 96 | + return new Sequence($org, new Sequence(...$nums)); |
|
| 97 | + } |
|
| 98 | 98 | } |
@@ -15,170 +15,170 @@ |
||
| 15 | 15 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.5 |
| 16 | 16 | */ |
| 17 | 17 | class PolicyMappingsExtension extends Extension implements |
| 18 | - \Countable, |
|
| 19 | - \IteratorAggregate |
|
| 18 | + \Countable, |
|
| 19 | + \IteratorAggregate |
|
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * Policy mappings. |
|
| 23 | - * |
|
| 24 | - * @var PolicyMapping[] $_mappings |
|
| 25 | - */ |
|
| 26 | - protected $_mappings; |
|
| 21 | + /** |
|
| 22 | + * Policy mappings. |
|
| 23 | + * |
|
| 24 | + * @var PolicyMapping[] $_mappings |
|
| 25 | + */ |
|
| 26 | + protected $_mappings; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Constructor. |
|
| 30 | - * |
|
| 31 | - * @param bool $critical |
|
| 32 | - * @param PolicyMapping ...$mappings One or more PolicyMapping objects |
|
| 33 | - */ |
|
| 34 | - public function __construct(bool $critical, PolicyMapping ...$mappings) |
|
| 35 | - { |
|
| 36 | - parent::__construct(self::OID_POLICY_MAPPINGS, $critical); |
|
| 37 | - $this->_mappings = $mappings; |
|
| 38 | - } |
|
| 28 | + /** |
|
| 29 | + * Constructor. |
|
| 30 | + * |
|
| 31 | + * @param bool $critical |
|
| 32 | + * @param PolicyMapping ...$mappings One or more PolicyMapping objects |
|
| 33 | + */ |
|
| 34 | + public function __construct(bool $critical, PolicyMapping ...$mappings) |
|
| 35 | + { |
|
| 36 | + parent::__construct(self::OID_POLICY_MAPPINGS, $critical); |
|
| 37 | + $this->_mappings = $mappings; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * |
|
| 42 | - * {@inheritdoc} |
|
| 43 | - * @return self |
|
| 44 | - */ |
|
| 45 | - protected static function _fromDER(string $data, bool $critical): self |
|
| 46 | - { |
|
| 47 | - $mappings = array_map( |
|
| 48 | - function (UnspecifiedType $el) { |
|
| 49 | - return PolicyMapping::fromASN1($el->asSequence()); |
|
| 50 | - }, Sequence::fromDER($data)->elements()); |
|
| 51 | - if (!count($mappings)) { |
|
| 52 | - throw new \UnexpectedValueException( |
|
| 53 | - "PolicyMappings must have at least one mapping."); |
|
| 54 | - } |
|
| 55 | - return new self($critical, ...$mappings); |
|
| 56 | - } |
|
| 40 | + /** |
|
| 41 | + * |
|
| 42 | + * {@inheritdoc} |
|
| 43 | + * @return self |
|
| 44 | + */ |
|
| 45 | + protected static function _fromDER(string $data, bool $critical): self |
|
| 46 | + { |
|
| 47 | + $mappings = array_map( |
|
| 48 | + function (UnspecifiedType $el) { |
|
| 49 | + return PolicyMapping::fromASN1($el->asSequence()); |
|
| 50 | + }, Sequence::fromDER($data)->elements()); |
|
| 51 | + if (!count($mappings)) { |
|
| 52 | + throw new \UnexpectedValueException( |
|
| 53 | + "PolicyMappings must have at least one mapping."); |
|
| 54 | + } |
|
| 55 | + return new self($critical, ...$mappings); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * |
|
| 60 | - * {@inheritdoc} |
|
| 61 | - * @return Sequence |
|
| 62 | - */ |
|
| 63 | - protected function _valueASN1(): Sequence |
|
| 64 | - { |
|
| 65 | - if (!count($this->_mappings)) { |
|
| 66 | - throw new \LogicException("No mappings."); |
|
| 67 | - } |
|
| 68 | - $elements = array_map( |
|
| 69 | - function (PolicyMapping $mapping) { |
|
| 70 | - return $mapping->toASN1(); |
|
| 71 | - }, $this->_mappings); |
|
| 72 | - return new Sequence(...$elements); |
|
| 73 | - } |
|
| 58 | + /** |
|
| 59 | + * |
|
| 60 | + * {@inheritdoc} |
|
| 61 | + * @return Sequence |
|
| 62 | + */ |
|
| 63 | + protected function _valueASN1(): Sequence |
|
| 64 | + { |
|
| 65 | + if (!count($this->_mappings)) { |
|
| 66 | + throw new \LogicException("No mappings."); |
|
| 67 | + } |
|
| 68 | + $elements = array_map( |
|
| 69 | + function (PolicyMapping $mapping) { |
|
| 70 | + return $mapping->toASN1(); |
|
| 71 | + }, $this->_mappings); |
|
| 72 | + return new Sequence(...$elements); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Get all mappings. |
|
| 77 | - * |
|
| 78 | - * @return PolicyMapping[] |
|
| 79 | - */ |
|
| 80 | - public function mappings(): array |
|
| 81 | - { |
|
| 82 | - return $this->_mappings; |
|
| 83 | - } |
|
| 75 | + /** |
|
| 76 | + * Get all mappings. |
|
| 77 | + * |
|
| 78 | + * @return PolicyMapping[] |
|
| 79 | + */ |
|
| 80 | + public function mappings(): array |
|
| 81 | + { |
|
| 82 | + return $this->_mappings; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Get mappings flattened into a single array of arrays of subject domains |
|
| 87 | - * keyed by issuer domain. |
|
| 88 | - * |
|
| 89 | - * Eg. if policy mappings contains multiple mappings with the same issuer |
|
| 90 | - * domain policy, their corresponding subject domain policies are placed |
|
| 91 | - * under the same key. |
|
| 92 | - * |
|
| 93 | - * @return (string[])[] |
|
| 94 | - */ |
|
| 95 | - public function flattenedMappings(): array |
|
| 96 | - { |
|
| 97 | - $mappings = array(); |
|
| 98 | - foreach ($this->_mappings as $mapping) { |
|
| 99 | - $idp = $mapping->issuerDomainPolicy(); |
|
| 100 | - if (!isset($mappings[$idp])) { |
|
| 101 | - $mappings[$idp] = array(); |
|
| 102 | - } |
|
| 103 | - array_push($mappings[$idp], $mapping->subjectDomainPolicy()); |
|
| 104 | - } |
|
| 105 | - return $mappings; |
|
| 106 | - } |
|
| 85 | + /** |
|
| 86 | + * Get mappings flattened into a single array of arrays of subject domains |
|
| 87 | + * keyed by issuer domain. |
|
| 88 | + * |
|
| 89 | + * Eg. if policy mappings contains multiple mappings with the same issuer |
|
| 90 | + * domain policy, their corresponding subject domain policies are placed |
|
| 91 | + * under the same key. |
|
| 92 | + * |
|
| 93 | + * @return (string[])[] |
|
| 94 | + */ |
|
| 95 | + public function flattenedMappings(): array |
|
| 96 | + { |
|
| 97 | + $mappings = array(); |
|
| 98 | + foreach ($this->_mappings as $mapping) { |
|
| 99 | + $idp = $mapping->issuerDomainPolicy(); |
|
| 100 | + if (!isset($mappings[$idp])) { |
|
| 101 | + $mappings[$idp] = array(); |
|
| 102 | + } |
|
| 103 | + array_push($mappings[$idp], $mapping->subjectDomainPolicy()); |
|
| 104 | + } |
|
| 105 | + return $mappings; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * Get all subject domain policy OIDs that are mapped to given issuer |
|
| 110 | - * domain policy OID. |
|
| 111 | - * |
|
| 112 | - * @param string $oid Issuer domain policy |
|
| 113 | - * @return string[] List of OIDs in dotted format |
|
| 114 | - */ |
|
| 115 | - public function issuerMappings(string $oid): array |
|
| 116 | - { |
|
| 117 | - $oids = array(); |
|
| 118 | - foreach ($this->_mappings as $mapping) { |
|
| 119 | - if ($mapping->issuerDomainPolicy() == $oid) { |
|
| 120 | - $oids[] = $mapping->subjectDomainPolicy(); |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - return $oids; |
|
| 124 | - } |
|
| 108 | + /** |
|
| 109 | + * Get all subject domain policy OIDs that are mapped to given issuer |
|
| 110 | + * domain policy OID. |
|
| 111 | + * |
|
| 112 | + * @param string $oid Issuer domain policy |
|
| 113 | + * @return string[] List of OIDs in dotted format |
|
| 114 | + */ |
|
| 115 | + public function issuerMappings(string $oid): array |
|
| 116 | + { |
|
| 117 | + $oids = array(); |
|
| 118 | + foreach ($this->_mappings as $mapping) { |
|
| 119 | + if ($mapping->issuerDomainPolicy() == $oid) { |
|
| 120 | + $oids[] = $mapping->subjectDomainPolicy(); |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + return $oids; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Get all mapped issuer domain policy OIDs. |
|
| 128 | - * |
|
| 129 | - * @return string[] |
|
| 130 | - */ |
|
| 131 | - public function issuerDomainPolicies(): array |
|
| 132 | - { |
|
| 133 | - $idps = array_map( |
|
| 134 | - function (PolicyMapping $mapping) { |
|
| 135 | - return $mapping->issuerDomainPolicy(); |
|
| 136 | - }, $this->_mappings); |
|
| 137 | - return array_values(array_unique($idps)); |
|
| 138 | - } |
|
| 126 | + /** |
|
| 127 | + * Get all mapped issuer domain policy OIDs. |
|
| 128 | + * |
|
| 129 | + * @return string[] |
|
| 130 | + */ |
|
| 131 | + public function issuerDomainPolicies(): array |
|
| 132 | + { |
|
| 133 | + $idps = array_map( |
|
| 134 | + function (PolicyMapping $mapping) { |
|
| 135 | + return $mapping->issuerDomainPolicy(); |
|
| 136 | + }, $this->_mappings); |
|
| 137 | + return array_values(array_unique($idps)); |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - /** |
|
| 141 | - * Check whether policy mappings have anyPolicy mapped. |
|
| 142 | - * |
|
| 143 | - * RFC 5280 section 4.2.1.5 states that "Policies MUST NOT be mapped either |
|
| 144 | - * to or from the special value anyPolicy". |
|
| 145 | - * |
|
| 146 | - * @return bool |
|
| 147 | - */ |
|
| 148 | - public function hasAnyPolicyMapping(): bool |
|
| 149 | - { |
|
| 150 | - foreach ($this->_mappings as $mapping) { |
|
| 151 | - if ($mapping->issuerDomainPolicy() == |
|
| 152 | - PolicyInformation::OID_ANY_POLICY) { |
|
| 153 | - return true; |
|
| 154 | - } |
|
| 155 | - if ($mapping->subjectDomainPolicy() == |
|
| 156 | - PolicyInformation::OID_ANY_POLICY) { |
|
| 157 | - return true; |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - return false; |
|
| 161 | - } |
|
| 140 | + /** |
|
| 141 | + * Check whether policy mappings have anyPolicy mapped. |
|
| 142 | + * |
|
| 143 | + * RFC 5280 section 4.2.1.5 states that "Policies MUST NOT be mapped either |
|
| 144 | + * to or from the special value anyPolicy". |
|
| 145 | + * |
|
| 146 | + * @return bool |
|
| 147 | + */ |
|
| 148 | + public function hasAnyPolicyMapping(): bool |
|
| 149 | + { |
|
| 150 | + foreach ($this->_mappings as $mapping) { |
|
| 151 | + if ($mapping->issuerDomainPolicy() == |
|
| 152 | + PolicyInformation::OID_ANY_POLICY) { |
|
| 153 | + return true; |
|
| 154 | + } |
|
| 155 | + if ($mapping->subjectDomainPolicy() == |
|
| 156 | + PolicyInformation::OID_ANY_POLICY) { |
|
| 157 | + return true; |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + return false; |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * Get the number of mappings. |
|
| 165 | - * |
|
| 166 | - * @see \Countable::count() |
|
| 167 | - * @return int |
|
| 168 | - */ |
|
| 169 | - public function count(): int |
|
| 170 | - { |
|
| 171 | - return count($this->_mappings); |
|
| 172 | - } |
|
| 163 | + /** |
|
| 164 | + * Get the number of mappings. |
|
| 165 | + * |
|
| 166 | + * @see \Countable::count() |
|
| 167 | + * @return int |
|
| 168 | + */ |
|
| 169 | + public function count(): int |
|
| 170 | + { |
|
| 171 | + return count($this->_mappings); |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - /** |
|
| 175 | - * Get iterator for policy mappings. |
|
| 176 | - * |
|
| 177 | - * @see \IteratorAggregate::getIterator() |
|
| 178 | - * @return \ArrayIterator |
|
| 179 | - */ |
|
| 180 | - public function getIterator(): \ArrayIterator |
|
| 181 | - { |
|
| 182 | - return new \ArrayIterator($this->_mappings); |
|
| 183 | - } |
|
| 174 | + /** |
|
| 175 | + * Get iterator for policy mappings. |
|
| 176 | + * |
|
| 177 | + * @see \IteratorAggregate::getIterator() |
|
| 178 | + * @return \ArrayIterator |
|
| 179 | + */ |
|
| 180 | + public function getIterator(): \ArrayIterator |
|
| 181 | + { |
|
| 182 | + return new \ArrayIterator($this->_mappings); |
|
| 183 | + } |
|
| 184 | 184 | } |
@@ -14,133 +14,133 @@ |
||
| 14 | 14 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.12 |
| 15 | 15 | */ |
| 16 | 16 | class ExtendedKeyUsageExtension extends Extension implements |
| 17 | - \Countable, |
|
| 18 | - \IteratorAggregate |
|
| 17 | + \Countable, |
|
| 18 | + \IteratorAggregate |
|
| 19 | 19 | { |
| 20 | - const OID_SERVER_AUTH = "1.3.6.1.5.5.7.3.1"; |
|
| 21 | - const OID_CLIENT_AUTH = "1.3.6.1.5.5.7.3.2"; |
|
| 22 | - const OID_CODE_SIGNING = "1.3.6.1.5.5.7.3.3"; |
|
| 23 | - const OID_EMAIL_PROTECTION = "1.3.6.1.5.5.7.3.4"; |
|
| 24 | - const OID_IPSEC_END_SYSTEM = "1.3.6.1.5.5.7.3.5"; |
|
| 25 | - const OID_IPSEC_TUNNEL = "1.3.6.1.5.5.7.3.6"; |
|
| 26 | - const OID_IPSEC_USER = "1.3.6.1.5.5.7.3.7"; |
|
| 27 | - const OID_TIME_STAMPING = "1.3.6.1.5.5.7.3.8"; |
|
| 28 | - const OID_OCSP_SIGNING = "1.3.6.1.5.5.7.3.9"; |
|
| 29 | - const OID_DVCS = "1.3.6.1.5.5.7.3.10"; |
|
| 30 | - const OID_SBGP_CERT_AA_SERVER_AUTH = "1.3.6.1.5.5.7.3.11"; |
|
| 31 | - const OID_SCVP_RESPONDER = "1.3.6.1.5.5.7.3.12"; |
|
| 32 | - const OID_EAP_OVER_PPP = "1.3.6.1.5.5.7.3.13"; |
|
| 33 | - const OID_EAP_OVER_LAN = "1.3.6.1.5.5.7.3.14"; |
|
| 34 | - const OID_SCVP_SERVER = "1.3.6.1.5.5.7.3.15"; |
|
| 35 | - const OID_SCVP_CLIENT = "1.3.6.1.5.5.7.3.16"; |
|
| 36 | - const OID_IPSEC_IKE = "1.3.6.1.5.5.7.3.17"; |
|
| 37 | - const OID_CAPWAP_AC = "1.3.6.1.5.5.7.3.18"; |
|
| 38 | - const OID_CAPWAP_WTP = "1.3.6.1.5.5.7.3.19"; |
|
| 39 | - const OID_SIP_DOMAIN = "1.3.6.1.5.5.7.3.20"; |
|
| 40 | - const OID_SECURE_SHELL_CLIENT = "1.3.6.1.5.5.7.3.21"; |
|
| 41 | - const OID_SECURE_SHELL_SERVER = "1.3.6.1.5.5.7.3.22"; |
|
| 42 | - const OID_SEND_ROUTER = "1.3.6.1.5.5.7.3.23"; |
|
| 43 | - const OID_SEND_PROXY = "1.3.6.1.5.5.7.3.24"; |
|
| 44 | - const OID_SEND_OWNER = "1.3.6.1.5.5.7.3.25"; |
|
| 45 | - const OID_SEND_PROXIED_OWNER = "1.3.6.1.5.5.7.3.26"; |
|
| 46 | - const OID_CMC_CA = "1.3.6.1.5.5.7.3.27"; |
|
| 47 | - const OID_CMC_RA = "1.3.6.1.5.5.7.3.28"; |
|
| 48 | - const OID_CMC_ARCHIVE = "1.3.6.1.5.5.7.3.29"; |
|
| 20 | + const OID_SERVER_AUTH = "1.3.6.1.5.5.7.3.1"; |
|
| 21 | + const OID_CLIENT_AUTH = "1.3.6.1.5.5.7.3.2"; |
|
| 22 | + const OID_CODE_SIGNING = "1.3.6.1.5.5.7.3.3"; |
|
| 23 | + const OID_EMAIL_PROTECTION = "1.3.6.1.5.5.7.3.4"; |
|
| 24 | + const OID_IPSEC_END_SYSTEM = "1.3.6.1.5.5.7.3.5"; |
|
| 25 | + const OID_IPSEC_TUNNEL = "1.3.6.1.5.5.7.3.6"; |
|
| 26 | + const OID_IPSEC_USER = "1.3.6.1.5.5.7.3.7"; |
|
| 27 | + const OID_TIME_STAMPING = "1.3.6.1.5.5.7.3.8"; |
|
| 28 | + const OID_OCSP_SIGNING = "1.3.6.1.5.5.7.3.9"; |
|
| 29 | + const OID_DVCS = "1.3.6.1.5.5.7.3.10"; |
|
| 30 | + const OID_SBGP_CERT_AA_SERVER_AUTH = "1.3.6.1.5.5.7.3.11"; |
|
| 31 | + const OID_SCVP_RESPONDER = "1.3.6.1.5.5.7.3.12"; |
|
| 32 | + const OID_EAP_OVER_PPP = "1.3.6.1.5.5.7.3.13"; |
|
| 33 | + const OID_EAP_OVER_LAN = "1.3.6.1.5.5.7.3.14"; |
|
| 34 | + const OID_SCVP_SERVER = "1.3.6.1.5.5.7.3.15"; |
|
| 35 | + const OID_SCVP_CLIENT = "1.3.6.1.5.5.7.3.16"; |
|
| 36 | + const OID_IPSEC_IKE = "1.3.6.1.5.5.7.3.17"; |
|
| 37 | + const OID_CAPWAP_AC = "1.3.6.1.5.5.7.3.18"; |
|
| 38 | + const OID_CAPWAP_WTP = "1.3.6.1.5.5.7.3.19"; |
|
| 39 | + const OID_SIP_DOMAIN = "1.3.6.1.5.5.7.3.20"; |
|
| 40 | + const OID_SECURE_SHELL_CLIENT = "1.3.6.1.5.5.7.3.21"; |
|
| 41 | + const OID_SECURE_SHELL_SERVER = "1.3.6.1.5.5.7.3.22"; |
|
| 42 | + const OID_SEND_ROUTER = "1.3.6.1.5.5.7.3.23"; |
|
| 43 | + const OID_SEND_PROXY = "1.3.6.1.5.5.7.3.24"; |
|
| 44 | + const OID_SEND_OWNER = "1.3.6.1.5.5.7.3.25"; |
|
| 45 | + const OID_SEND_PROXIED_OWNER = "1.3.6.1.5.5.7.3.26"; |
|
| 46 | + const OID_CMC_CA = "1.3.6.1.5.5.7.3.27"; |
|
| 47 | + const OID_CMC_RA = "1.3.6.1.5.5.7.3.28"; |
|
| 48 | + const OID_CMC_ARCHIVE = "1.3.6.1.5.5.7.3.29"; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Purpose OID's. |
|
| 52 | - * |
|
| 53 | - * @var string[] $_purposes |
|
| 54 | - */ |
|
| 55 | - protected $_purposes; |
|
| 50 | + /** |
|
| 51 | + * Purpose OID's. |
|
| 52 | + * |
|
| 53 | + * @var string[] $_purposes |
|
| 54 | + */ |
|
| 55 | + protected $_purposes; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Constructor. |
|
| 59 | - * |
|
| 60 | - * @param bool $critical |
|
| 61 | - * @param string ...$purposes |
|
| 62 | - */ |
|
| 63 | - public function __construct(bool $critical, string ...$purposes) |
|
| 64 | - { |
|
| 65 | - parent::__construct(self::OID_EXT_KEY_USAGE, $critical); |
|
| 66 | - $this->_purposes = $purposes; |
|
| 67 | - } |
|
| 57 | + /** |
|
| 58 | + * Constructor. |
|
| 59 | + * |
|
| 60 | + * @param bool $critical |
|
| 61 | + * @param string ...$purposes |
|
| 62 | + */ |
|
| 63 | + public function __construct(bool $critical, string ...$purposes) |
|
| 64 | + { |
|
| 65 | + parent::__construct(self::OID_EXT_KEY_USAGE, $critical); |
|
| 66 | + $this->_purposes = $purposes; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * |
|
| 71 | - * {@inheritdoc} |
|
| 72 | - * @return self |
|
| 73 | - */ |
|
| 74 | - protected static function _fromDER(string $data, bool $critical): self |
|
| 75 | - { |
|
| 76 | - $purposes = array_map( |
|
| 77 | - function (UnspecifiedType $el) { |
|
| 78 | - return $el->asObjectIdentifier()->oid(); |
|
| 79 | - }, Sequence::fromDER($data)->elements()); |
|
| 80 | - return new self($critical, ...$purposes); |
|
| 81 | - } |
|
| 69 | + /** |
|
| 70 | + * |
|
| 71 | + * {@inheritdoc} |
|
| 72 | + * @return self |
|
| 73 | + */ |
|
| 74 | + protected static function _fromDER(string $data, bool $critical): self |
|
| 75 | + { |
|
| 76 | + $purposes = array_map( |
|
| 77 | + function (UnspecifiedType $el) { |
|
| 78 | + return $el->asObjectIdentifier()->oid(); |
|
| 79 | + }, Sequence::fromDER($data)->elements()); |
|
| 80 | + return new self($critical, ...$purposes); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Whether purposes are present. |
|
| 85 | - * |
|
| 86 | - * If multiple purposes are checked, all must be present. |
|
| 87 | - * |
|
| 88 | - * @param string ...$oids |
|
| 89 | - * @return bool |
|
| 90 | - */ |
|
| 91 | - public function has(string ...$oids): bool |
|
| 92 | - { |
|
| 93 | - foreach ($oids as $oid) { |
|
| 94 | - if (!in_array($oid, $this->_purposes)) { |
|
| 95 | - return false; |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - return true; |
|
| 99 | - } |
|
| 83 | + /** |
|
| 84 | + * Whether purposes are present. |
|
| 85 | + * |
|
| 86 | + * If multiple purposes are checked, all must be present. |
|
| 87 | + * |
|
| 88 | + * @param string ...$oids |
|
| 89 | + * @return bool |
|
| 90 | + */ |
|
| 91 | + public function has(string ...$oids): bool |
|
| 92 | + { |
|
| 93 | + foreach ($oids as $oid) { |
|
| 94 | + if (!in_array($oid, $this->_purposes)) { |
|
| 95 | + return false; |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + return true; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Get key usage purpose OID's. |
|
| 103 | - * |
|
| 104 | - * @return string[] |
|
| 105 | - */ |
|
| 106 | - public function purposes(): array |
|
| 107 | - { |
|
| 108 | - return $this->_purposes; |
|
| 109 | - } |
|
| 101 | + /** |
|
| 102 | + * Get key usage purpose OID's. |
|
| 103 | + * |
|
| 104 | + * @return string[] |
|
| 105 | + */ |
|
| 106 | + public function purposes(): array |
|
| 107 | + { |
|
| 108 | + return $this->_purposes; |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * |
|
| 113 | - * {@inheritdoc} |
|
| 114 | - * @return Sequence |
|
| 115 | - */ |
|
| 116 | - protected function _valueASN1(): Sequence |
|
| 117 | - { |
|
| 118 | - $elements = array_map( |
|
| 119 | - function ($oid) { |
|
| 120 | - return new ObjectIdentifier($oid); |
|
| 121 | - }, $this->_purposes); |
|
| 122 | - return new Sequence(...$elements); |
|
| 123 | - } |
|
| 111 | + /** |
|
| 112 | + * |
|
| 113 | + * {@inheritdoc} |
|
| 114 | + * @return Sequence |
|
| 115 | + */ |
|
| 116 | + protected function _valueASN1(): Sequence |
|
| 117 | + { |
|
| 118 | + $elements = array_map( |
|
| 119 | + function ($oid) { |
|
| 120 | + return new ObjectIdentifier($oid); |
|
| 121 | + }, $this->_purposes); |
|
| 122 | + return new Sequence(...$elements); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * Get the number of purposes. |
|
| 127 | - * |
|
| 128 | - * @see \Countable::count() |
|
| 129 | - * @return int |
|
| 130 | - */ |
|
| 131 | - public function count(): int |
|
| 132 | - { |
|
| 133 | - return count($this->_purposes); |
|
| 134 | - } |
|
| 125 | + /** |
|
| 126 | + * Get the number of purposes. |
|
| 127 | + * |
|
| 128 | + * @see \Countable::count() |
|
| 129 | + * @return int |
|
| 130 | + */ |
|
| 131 | + public function count(): int |
|
| 132 | + { |
|
| 133 | + return count($this->_purposes); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - /** |
|
| 137 | - * Get iterator for usage purposes. |
|
| 138 | - * |
|
| 139 | - * @see \IteratorAggregate::getIterator() |
|
| 140 | - * @return \ArrayIterator |
|
| 141 | - */ |
|
| 142 | - public function getIterator(): \ArrayIterator |
|
| 143 | - { |
|
| 144 | - return new \ArrayIterator($this->_purposes); |
|
| 145 | - } |
|
| 136 | + /** |
|
| 137 | + * Get iterator for usage purposes. |
|
| 138 | + * |
|
| 139 | + * @see \IteratorAggregate::getIterator() |
|
| 140 | + * @return \ArrayIterator |
|
| 141 | + */ |
|
| 142 | + public function getIterator(): \ArrayIterator |
|
| 143 | + { |
|
| 144 | + return new \ArrayIterator($this->_purposes); |
|
| 145 | + } |
|
| 146 | 146 | } |