@@ -15,77 +15,77 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class PolicyMapping |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * OID of the issuer policy. |
|
| 20 | - * |
|
| 21 | - * @var string $_issuerDomainPolicy |
|
| 22 | - */ |
|
| 23 | - protected $_issuerDomainPolicy; |
|
| 18 | + /** |
|
| 19 | + * OID of the issuer policy. |
|
| 20 | + * |
|
| 21 | + * @var string $_issuerDomainPolicy |
|
| 22 | + */ |
|
| 23 | + protected $_issuerDomainPolicy; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * OID of the subject policy. |
|
| 27 | - * |
|
| 28 | - * @var string $_subjectDomainPolicy |
|
| 29 | - */ |
|
| 30 | - protected $_subjectDomainPolicy; |
|
| 25 | + /** |
|
| 26 | + * OID of the subject policy. |
|
| 27 | + * |
|
| 28 | + * @var string $_subjectDomainPolicy |
|
| 29 | + */ |
|
| 30 | + protected $_subjectDomainPolicy; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Constructor. |
|
| 34 | - * |
|
| 35 | - * @param string $issuer_policy OID of the issuer policy |
|
| 36 | - * @param string $subject_policy OID of the subject policy |
|
| 37 | - */ |
|
| 38 | - public function __construct($issuer_policy, $subject_policy) |
|
| 39 | - { |
|
| 40 | - $this->_issuerDomainPolicy = $issuer_policy; |
|
| 41 | - $this->_subjectDomainPolicy = $subject_policy; |
|
| 42 | - } |
|
| 32 | + /** |
|
| 33 | + * Constructor. |
|
| 34 | + * |
|
| 35 | + * @param string $issuer_policy OID of the issuer policy |
|
| 36 | + * @param string $subject_policy OID of the subject policy |
|
| 37 | + */ |
|
| 38 | + public function __construct($issuer_policy, $subject_policy) |
|
| 39 | + { |
|
| 40 | + $this->_issuerDomainPolicy = $issuer_policy; |
|
| 41 | + $this->_subjectDomainPolicy = $subject_policy; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Initialize from ASN.1. |
|
| 46 | - * |
|
| 47 | - * @param Sequence $seq |
|
| 48 | - * @return self |
|
| 49 | - */ |
|
| 50 | - public static function fromASN1(Sequence $seq) |
|
| 51 | - { |
|
| 52 | - $issuer_policy = $seq->at(0) |
|
| 53 | - ->asObjectIdentifier() |
|
| 54 | - ->oid(); |
|
| 55 | - $subject_policy = $seq->at(1) |
|
| 56 | - ->asObjectIdentifier() |
|
| 57 | - ->oid(); |
|
| 58 | - return new self($issuer_policy, $subject_policy); |
|
| 59 | - } |
|
| 44 | + /** |
|
| 45 | + * Initialize from ASN.1. |
|
| 46 | + * |
|
| 47 | + * @param Sequence $seq |
|
| 48 | + * @return self |
|
| 49 | + */ |
|
| 50 | + public static function fromASN1(Sequence $seq) |
|
| 51 | + { |
|
| 52 | + $issuer_policy = $seq->at(0) |
|
| 53 | + ->asObjectIdentifier() |
|
| 54 | + ->oid(); |
|
| 55 | + $subject_policy = $seq->at(1) |
|
| 56 | + ->asObjectIdentifier() |
|
| 57 | + ->oid(); |
|
| 58 | + return new self($issuer_policy, $subject_policy); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Get issuer domain policy. |
|
| 63 | - * |
|
| 64 | - * @return string OID in dotted format |
|
| 65 | - */ |
|
| 66 | - public function issuerDomainPolicy(): string |
|
| 67 | - { |
|
| 68 | - return $this->_issuerDomainPolicy; |
|
| 69 | - } |
|
| 61 | + /** |
|
| 62 | + * Get issuer domain policy. |
|
| 63 | + * |
|
| 64 | + * @return string OID in dotted format |
|
| 65 | + */ |
|
| 66 | + public function issuerDomainPolicy(): string |
|
| 67 | + { |
|
| 68 | + return $this->_issuerDomainPolicy; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Get subject domain policy. |
|
| 73 | - * |
|
| 74 | - * @return string OID in dotted format |
|
| 75 | - */ |
|
| 76 | - public function subjectDomainPolicy(): string |
|
| 77 | - { |
|
| 78 | - return $this->_subjectDomainPolicy; |
|
| 79 | - } |
|
| 71 | + /** |
|
| 72 | + * Get subject domain policy. |
|
| 73 | + * |
|
| 74 | + * @return string OID in dotted format |
|
| 75 | + */ |
|
| 76 | + public function subjectDomainPolicy(): string |
|
| 77 | + { |
|
| 78 | + return $this->_subjectDomainPolicy; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Generate ASN.1 structure. |
|
| 83 | - * |
|
| 84 | - * @return Sequence |
|
| 85 | - */ |
|
| 86 | - public function toASN1(): Sequence |
|
| 87 | - { |
|
| 88 | - return new Sequence(new ObjectIdentifier($this->_issuerDomainPolicy), |
|
| 89 | - new ObjectIdentifier($this->_subjectDomainPolicy)); |
|
| 90 | - } |
|
| 81 | + /** |
|
| 82 | + * Generate ASN.1 structure. |
|
| 83 | + * |
|
| 84 | + * @return Sequence |
|
| 85 | + */ |
|
| 86 | + public function toASN1(): Sequence |
|
| 87 | + { |
|
| 88 | + return new Sequence(new ObjectIdentifier($this->_issuerDomainPolicy), |
|
| 89 | + new ObjectIdentifier($this->_subjectDomainPolicy)); |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace X509\Certificate\Extension\PolicyMappings; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace X509\Certificate\Extension\Target; |
| 6 | 6 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | public static function fromASN1(Sequence $seq) |
| 41 | 41 | { |
| 42 | 42 | $targets = array_map( |
| 43 | - function (UnspecifiedType $el) { |
|
| 43 | + function(UnspecifiedType $el) { |
|
| 44 | 44 | return Target::fromASN1($el->asTagged()); |
| 45 | 45 | }, $seq->elements()); |
| 46 | 46 | return new self(...$targets); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | { |
| 67 | 67 | return array_values( |
| 68 | 68 | array_filter($this->_targets, |
| 69 | - function (Target $target) use ($type) { |
|
| 69 | + function(Target $target) use ($type) { |
|
| 70 | 70 | return $target->type() == $type; |
| 71 | 71 | })); |
| 72 | 72 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | public function toASN1() |
| 116 | 116 | { |
| 117 | 117 | $elements = array_map( |
| 118 | - function (Target $target) { |
|
| 118 | + function(Target $target) { |
|
| 119 | 119 | return $target->toASN1(); |
| 120 | 120 | }, $this->_targets); |
| 121 | 121 | return new Sequence(...$elements); |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace X509\Certificate\Extension\Target; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace X509\Certificate\Extension\Target; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace X509\Certificate\Extension\Target; |
| 6 | 6 | |
@@ -16,123 +16,123 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class PolicyConstraintsExtension extends Extension |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * |
|
| 21 | - * @var int $_requireExplicitPolicy |
|
| 22 | - */ |
|
| 23 | - protected $_requireExplicitPolicy; |
|
| 19 | + /** |
|
| 20 | + * |
|
| 21 | + * @var int $_requireExplicitPolicy |
|
| 22 | + */ |
|
| 23 | + protected $_requireExplicitPolicy; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * |
|
| 27 | - * @var int $_inhibitPolicyMapping |
|
| 28 | - */ |
|
| 29 | - protected $_inhibitPolicyMapping; |
|
| 25 | + /** |
|
| 26 | + * |
|
| 27 | + * @var int $_inhibitPolicyMapping |
|
| 28 | + */ |
|
| 29 | + protected $_inhibitPolicyMapping; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Constructor. |
|
| 33 | - * |
|
| 34 | - * @param bool $critical |
|
| 35 | - * @param int|null $require_explicit_policy |
|
| 36 | - * @param int|null $inhibit_policy_mapping |
|
| 37 | - */ |
|
| 38 | - public function __construct(bool $critical, $require_explicit_policy = null, |
|
| 39 | - $inhibit_policy_mapping = null) |
|
| 40 | - { |
|
| 41 | - parent::__construct(self::OID_POLICY_CONSTRAINTS, $critical); |
|
| 42 | - $this->_requireExplicitPolicy = $require_explicit_policy; |
|
| 43 | - $this->_inhibitPolicyMapping = $inhibit_policy_mapping; |
|
| 44 | - } |
|
| 31 | + /** |
|
| 32 | + * Constructor. |
|
| 33 | + * |
|
| 34 | + * @param bool $critical |
|
| 35 | + * @param int|null $require_explicit_policy |
|
| 36 | + * @param int|null $inhibit_policy_mapping |
|
| 37 | + */ |
|
| 38 | + public function __construct(bool $critical, $require_explicit_policy = null, |
|
| 39 | + $inhibit_policy_mapping = null) |
|
| 40 | + { |
|
| 41 | + parent::__construct(self::OID_POLICY_CONSTRAINTS, $critical); |
|
| 42 | + $this->_requireExplicitPolicy = $require_explicit_policy; |
|
| 43 | + $this->_inhibitPolicyMapping = $inhibit_policy_mapping; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * |
|
| 48 | - * {@inheritdoc} |
|
| 49 | - * @return self |
|
| 50 | - */ |
|
| 51 | - protected static function _fromDER($data, $critical) |
|
| 52 | - { |
|
| 53 | - $seq = Sequence::fromDER($data); |
|
| 54 | - $require_explicit_policy = null; |
|
| 55 | - $inhibit_policy_mapping = null; |
|
| 56 | - if ($seq->hasTagged(0)) { |
|
| 57 | - $require_explicit_policy = $seq->getTagged(0) |
|
| 58 | - ->asImplicit(Element::TYPE_INTEGER) |
|
| 59 | - ->asInteger() |
|
| 60 | - ->number(); |
|
| 61 | - } |
|
| 62 | - if ($seq->hasTagged(1)) { |
|
| 63 | - $inhibit_policy_mapping = $seq->getTagged(1) |
|
| 64 | - ->asImplicit(Element::TYPE_INTEGER) |
|
| 65 | - ->asInteger() |
|
| 66 | - ->number(); |
|
| 67 | - } |
|
| 68 | - return new self($critical, $require_explicit_policy, |
|
| 69 | - $inhibit_policy_mapping); |
|
| 70 | - } |
|
| 46 | + /** |
|
| 47 | + * |
|
| 48 | + * {@inheritdoc} |
|
| 49 | + * @return self |
|
| 50 | + */ |
|
| 51 | + protected static function _fromDER($data, $critical) |
|
| 52 | + { |
|
| 53 | + $seq = Sequence::fromDER($data); |
|
| 54 | + $require_explicit_policy = null; |
|
| 55 | + $inhibit_policy_mapping = null; |
|
| 56 | + if ($seq->hasTagged(0)) { |
|
| 57 | + $require_explicit_policy = $seq->getTagged(0) |
|
| 58 | + ->asImplicit(Element::TYPE_INTEGER) |
|
| 59 | + ->asInteger() |
|
| 60 | + ->number(); |
|
| 61 | + } |
|
| 62 | + if ($seq->hasTagged(1)) { |
|
| 63 | + $inhibit_policy_mapping = $seq->getTagged(1) |
|
| 64 | + ->asImplicit(Element::TYPE_INTEGER) |
|
| 65 | + ->asInteger() |
|
| 66 | + ->number(); |
|
| 67 | + } |
|
| 68 | + return new self($critical, $require_explicit_policy, |
|
| 69 | + $inhibit_policy_mapping); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Whether requireExplicitPolicy is present. |
|
| 74 | - * |
|
| 75 | - * @return bool |
|
| 76 | - */ |
|
| 77 | - public function hasRequireExplicitPolicy(): bool |
|
| 78 | - { |
|
| 79 | - return isset($this->_requireExplicitPolicy); |
|
| 80 | - } |
|
| 72 | + /** |
|
| 73 | + * Whether requireExplicitPolicy is present. |
|
| 74 | + * |
|
| 75 | + * @return bool |
|
| 76 | + */ |
|
| 77 | + public function hasRequireExplicitPolicy(): bool |
|
| 78 | + { |
|
| 79 | + return isset($this->_requireExplicitPolicy); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Get requireExplicitPolicy. |
|
| 84 | - * |
|
| 85 | - * @throws \LogicException |
|
| 86 | - * @return int |
|
| 87 | - */ |
|
| 88 | - public function requireExplicitPolicy() |
|
| 89 | - { |
|
| 90 | - if (!$this->hasRequireExplicitPolicy()) { |
|
| 91 | - throw new \LogicException("requireExplicitPolicy not set."); |
|
| 92 | - } |
|
| 93 | - return $this->_requireExplicitPolicy; |
|
| 94 | - } |
|
| 82 | + /** |
|
| 83 | + * Get requireExplicitPolicy. |
|
| 84 | + * |
|
| 85 | + * @throws \LogicException |
|
| 86 | + * @return int |
|
| 87 | + */ |
|
| 88 | + public function requireExplicitPolicy() |
|
| 89 | + { |
|
| 90 | + if (!$this->hasRequireExplicitPolicy()) { |
|
| 91 | + throw new \LogicException("requireExplicitPolicy not set."); |
|
| 92 | + } |
|
| 93 | + return $this->_requireExplicitPolicy; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Whether inhibitPolicyMapping is present. |
|
| 98 | - * |
|
| 99 | - * @return bool |
|
| 100 | - */ |
|
| 101 | - public function hasInhibitPolicyMapping(): bool |
|
| 102 | - { |
|
| 103 | - return isset($this->_inhibitPolicyMapping); |
|
| 104 | - } |
|
| 96 | + /** |
|
| 97 | + * Whether inhibitPolicyMapping is present. |
|
| 98 | + * |
|
| 99 | + * @return bool |
|
| 100 | + */ |
|
| 101 | + public function hasInhibitPolicyMapping(): bool |
|
| 102 | + { |
|
| 103 | + return isset($this->_inhibitPolicyMapping); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Get inhibitPolicyMapping. |
|
| 108 | - * |
|
| 109 | - * @throws \LogicException |
|
| 110 | - * @return int |
|
| 111 | - */ |
|
| 112 | - public function inhibitPolicyMapping() |
|
| 113 | - { |
|
| 114 | - if (!$this->hasInhibitPolicyMapping()) { |
|
| 115 | - throw new \LogicException("inhibitPolicyMapping not set."); |
|
| 116 | - } |
|
| 117 | - return $this->_inhibitPolicyMapping; |
|
| 118 | - } |
|
| 106 | + /** |
|
| 107 | + * Get inhibitPolicyMapping. |
|
| 108 | + * |
|
| 109 | + * @throws \LogicException |
|
| 110 | + * @return int |
|
| 111 | + */ |
|
| 112 | + public function inhibitPolicyMapping() |
|
| 113 | + { |
|
| 114 | + if (!$this->hasInhibitPolicyMapping()) { |
|
| 115 | + throw new \LogicException("inhibitPolicyMapping not set."); |
|
| 116 | + } |
|
| 117 | + return $this->_inhibitPolicyMapping; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * |
|
| 122 | - * {@inheritdoc} |
|
| 123 | - * @return Sequence |
|
| 124 | - */ |
|
| 125 | - protected function _valueASN1() |
|
| 126 | - { |
|
| 127 | - $elements = array(); |
|
| 128 | - if (isset($this->_requireExplicitPolicy)) { |
|
| 129 | - $elements[] = new ImplicitlyTaggedType(0, |
|
| 130 | - new Integer($this->_requireExplicitPolicy)); |
|
| 131 | - } |
|
| 132 | - if (isset($this->_inhibitPolicyMapping)) { |
|
| 133 | - $elements[] = new ImplicitlyTaggedType(1, |
|
| 134 | - new Integer($this->_inhibitPolicyMapping)); |
|
| 135 | - } |
|
| 136 | - return new Sequence(...$elements); |
|
| 137 | - } |
|
| 120 | + /** |
|
| 121 | + * |
|
| 122 | + * {@inheritdoc} |
|
| 123 | + * @return Sequence |
|
| 124 | + */ |
|
| 125 | + protected function _valueASN1() |
|
| 126 | + { |
|
| 127 | + $elements = array(); |
|
| 128 | + if (isset($this->_requireExplicitPolicy)) { |
|
| 129 | + $elements[] = new ImplicitlyTaggedType(0, |
|
| 130 | + new Integer($this->_requireExplicitPolicy)); |
|
| 131 | + } |
|
| 132 | + if (isset($this->_inhibitPolicyMapping)) { |
|
| 133 | + $elements[] = new ImplicitlyTaggedType(1, |
|
| 134 | + new Integer($this->_inhibitPolicyMapping)); |
|
| 135 | + } |
|
| 136 | + return new Sequence(...$elements); |
|
| 137 | + } |
|
| 138 | 138 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace X509\Certificate\Extension; |
| 6 | 6 | |
@@ -18,170 +18,170 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class AuthorityKeyIdentifierExtension extends Extension |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * Key identifier. |
|
| 23 | - * |
|
| 24 | - * @var string|null $_keyIdentifier |
|
| 25 | - */ |
|
| 26 | - protected $_keyIdentifier; |
|
| 21 | + /** |
|
| 22 | + * Key identifier. |
|
| 23 | + * |
|
| 24 | + * @var string|null $_keyIdentifier |
|
| 25 | + */ |
|
| 26 | + protected $_keyIdentifier; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Issuer name. |
|
| 30 | - * |
|
| 31 | - * @var GeneralNames|null $_authorityCertIssuer |
|
| 32 | - */ |
|
| 33 | - protected $_authorityCertIssuer; |
|
| 28 | + /** |
|
| 29 | + * Issuer name. |
|
| 30 | + * |
|
| 31 | + * @var GeneralNames|null $_authorityCertIssuer |
|
| 32 | + */ |
|
| 33 | + protected $_authorityCertIssuer; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Issuer serial number. |
|
| 37 | - * |
|
| 38 | - * @var int|string|null $_authorityCertSerialNumber |
|
| 39 | - */ |
|
| 40 | - protected $_authorityCertSerialNumber; |
|
| 35 | + /** |
|
| 36 | + * Issuer serial number. |
|
| 37 | + * |
|
| 38 | + * @var int|string|null $_authorityCertSerialNumber |
|
| 39 | + */ |
|
| 40 | + protected $_authorityCertSerialNumber; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Constructor. |
|
| 44 | - * |
|
| 45 | - * @param bool $critical Conforming CA's must mark as non-critical (false) |
|
| 46 | - * @param string|null $keyIdentifier |
|
| 47 | - * @param GeneralNames|null $issuer |
|
| 48 | - * @param int|string|null $serial |
|
| 49 | - */ |
|
| 50 | - public function __construct(bool $critical, $keyIdentifier, |
|
| 51 | - GeneralNames $issuer = null, $serial = null) |
|
| 52 | - { |
|
| 53 | - parent::__construct(self::OID_AUTHORITY_KEY_IDENTIFIER, $critical); |
|
| 54 | - $this->_keyIdentifier = $keyIdentifier; |
|
| 55 | - $this->_authorityCertIssuer = $issuer; |
|
| 56 | - $this->_authorityCertSerialNumber = $serial; |
|
| 57 | - } |
|
| 42 | + /** |
|
| 43 | + * Constructor. |
|
| 44 | + * |
|
| 45 | + * @param bool $critical Conforming CA's must mark as non-critical (false) |
|
| 46 | + * @param string|null $keyIdentifier |
|
| 47 | + * @param GeneralNames|null $issuer |
|
| 48 | + * @param int|string|null $serial |
|
| 49 | + */ |
|
| 50 | + public function __construct(bool $critical, $keyIdentifier, |
|
| 51 | + GeneralNames $issuer = null, $serial = null) |
|
| 52 | + { |
|
| 53 | + parent::__construct(self::OID_AUTHORITY_KEY_IDENTIFIER, $critical); |
|
| 54 | + $this->_keyIdentifier = $keyIdentifier; |
|
| 55 | + $this->_authorityCertIssuer = $issuer; |
|
| 56 | + $this->_authorityCertSerialNumber = $serial; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * |
|
| 61 | - * {@inheritdoc} |
|
| 62 | - * @return self |
|
| 63 | - */ |
|
| 64 | - protected static function _fromDER($data, $critical) |
|
| 65 | - { |
|
| 66 | - $seq = Sequence::fromDER($data); |
|
| 67 | - $keyIdentifier = null; |
|
| 68 | - $issuer = null; |
|
| 69 | - $serial = null; |
|
| 70 | - if ($seq->hasTagged(0)) { |
|
| 71 | - $keyIdentifier = $seq->getTagged(0) |
|
| 72 | - ->asImplicit(Element::TYPE_OCTET_STRING) |
|
| 73 | - ->asOctetString() |
|
| 74 | - ->string(); |
|
| 75 | - } |
|
| 76 | - if ($seq->hasTagged(1) || $seq->hasTagged(2)) { |
|
| 77 | - if (!$seq->hasTagged(1) || !$seq->hasTagged(2)) { |
|
| 78 | - throw new \UnexpectedValueException( |
|
| 79 | - "AuthorityKeyIdentifier must have both" . |
|
| 80 | - " authorityCertIssuer and authorityCertSerialNumber" . |
|
| 81 | - " present or both absent."); |
|
| 82 | - } |
|
| 83 | - $issuer = GeneralNames::fromASN1( |
|
| 84 | - $seq->getTagged(1) |
|
| 85 | - ->asImplicit(Element::TYPE_SEQUENCE) |
|
| 86 | - ->asSequence()); |
|
| 87 | - $serial = $seq->getTagged(2) |
|
| 88 | - ->asImplicit(Element::TYPE_INTEGER) |
|
| 89 | - ->asInteger() |
|
| 90 | - ->number(); |
|
| 91 | - } |
|
| 92 | - return new self($critical, $keyIdentifier, $issuer, $serial); |
|
| 93 | - } |
|
| 59 | + /** |
|
| 60 | + * |
|
| 61 | + * {@inheritdoc} |
|
| 62 | + * @return self |
|
| 63 | + */ |
|
| 64 | + protected static function _fromDER($data, $critical) |
|
| 65 | + { |
|
| 66 | + $seq = Sequence::fromDER($data); |
|
| 67 | + $keyIdentifier = null; |
|
| 68 | + $issuer = null; |
|
| 69 | + $serial = null; |
|
| 70 | + if ($seq->hasTagged(0)) { |
|
| 71 | + $keyIdentifier = $seq->getTagged(0) |
|
| 72 | + ->asImplicit(Element::TYPE_OCTET_STRING) |
|
| 73 | + ->asOctetString() |
|
| 74 | + ->string(); |
|
| 75 | + } |
|
| 76 | + if ($seq->hasTagged(1) || $seq->hasTagged(2)) { |
|
| 77 | + if (!$seq->hasTagged(1) || !$seq->hasTagged(2)) { |
|
| 78 | + throw new \UnexpectedValueException( |
|
| 79 | + "AuthorityKeyIdentifier must have both" . |
|
| 80 | + " authorityCertIssuer and authorityCertSerialNumber" . |
|
| 81 | + " present or both absent."); |
|
| 82 | + } |
|
| 83 | + $issuer = GeneralNames::fromASN1( |
|
| 84 | + $seq->getTagged(1) |
|
| 85 | + ->asImplicit(Element::TYPE_SEQUENCE) |
|
| 86 | + ->asSequence()); |
|
| 87 | + $serial = $seq->getTagged(2) |
|
| 88 | + ->asImplicit(Element::TYPE_INTEGER) |
|
| 89 | + ->asInteger() |
|
| 90 | + ->number(); |
|
| 91 | + } |
|
| 92 | + return new self($critical, $keyIdentifier, $issuer, $serial); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Whether key identifier is present. |
|
| 97 | - * |
|
| 98 | - * @return bool |
|
| 99 | - */ |
|
| 100 | - public function hasKeyIdentifier(): bool |
|
| 101 | - { |
|
| 102 | - return isset($this->_keyIdentifier); |
|
| 103 | - } |
|
| 95 | + /** |
|
| 96 | + * Whether key identifier is present. |
|
| 97 | + * |
|
| 98 | + * @return bool |
|
| 99 | + */ |
|
| 100 | + public function hasKeyIdentifier(): bool |
|
| 101 | + { |
|
| 102 | + return isset($this->_keyIdentifier); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Get key identifier. |
|
| 107 | - * |
|
| 108 | - * @throws \LogicException |
|
| 109 | - * @return string |
|
| 110 | - */ |
|
| 111 | - public function keyIdentifier(): string |
|
| 112 | - { |
|
| 113 | - if (!$this->hasKeyIdentifier()) { |
|
| 114 | - throw new \LogicException("keyIdentifier not set."); |
|
| 115 | - } |
|
| 116 | - return $this->_keyIdentifier; |
|
| 117 | - } |
|
| 105 | + /** |
|
| 106 | + * Get key identifier. |
|
| 107 | + * |
|
| 108 | + * @throws \LogicException |
|
| 109 | + * @return string |
|
| 110 | + */ |
|
| 111 | + public function keyIdentifier(): string |
|
| 112 | + { |
|
| 113 | + if (!$this->hasKeyIdentifier()) { |
|
| 114 | + throw new \LogicException("keyIdentifier not set."); |
|
| 115 | + } |
|
| 116 | + return $this->_keyIdentifier; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Whether issuer is present. |
|
| 121 | - * |
|
| 122 | - * @return bool |
|
| 123 | - */ |
|
| 124 | - public function hasIssuer(): bool |
|
| 125 | - { |
|
| 126 | - return isset($this->_authorityCertIssuer); |
|
| 127 | - } |
|
| 119 | + /** |
|
| 120 | + * Whether issuer is present. |
|
| 121 | + * |
|
| 122 | + * @return bool |
|
| 123 | + */ |
|
| 124 | + public function hasIssuer(): bool |
|
| 125 | + { |
|
| 126 | + return isset($this->_authorityCertIssuer); |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * Get issuer. |
|
| 131 | - * |
|
| 132 | - * @throws \LogicException |
|
| 133 | - * @return GeneralNames |
|
| 134 | - */ |
|
| 135 | - public function issuer(): GeneralNames |
|
| 136 | - { |
|
| 137 | - if (!$this->hasIssuer()) { |
|
| 138 | - throw new \LogicException("authorityCertIssuer not set."); |
|
| 139 | - } |
|
| 140 | - return $this->_authorityCertIssuer; |
|
| 141 | - } |
|
| 129 | + /** |
|
| 130 | + * Get issuer. |
|
| 131 | + * |
|
| 132 | + * @throws \LogicException |
|
| 133 | + * @return GeneralNames |
|
| 134 | + */ |
|
| 135 | + public function issuer(): GeneralNames |
|
| 136 | + { |
|
| 137 | + if (!$this->hasIssuer()) { |
|
| 138 | + throw new \LogicException("authorityCertIssuer not set."); |
|
| 139 | + } |
|
| 140 | + return $this->_authorityCertIssuer; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * Get serial number. |
|
| 145 | - * |
|
| 146 | - * @throws \LogicException |
|
| 147 | - * @return int|string |
|
| 148 | - */ |
|
| 149 | - public function serial() |
|
| 150 | - { |
|
| 151 | - // both issuer and serial must be present or both absent |
|
| 152 | - if (!$this->hasIssuer()) { |
|
| 153 | - throw new \LogicException("authorityCertSerialNumber not set."); |
|
| 154 | - } |
|
| 155 | - return $this->_authorityCertSerialNumber; |
|
| 156 | - } |
|
| 143 | + /** |
|
| 144 | + * Get serial number. |
|
| 145 | + * |
|
| 146 | + * @throws \LogicException |
|
| 147 | + * @return int|string |
|
| 148 | + */ |
|
| 149 | + public function serial() |
|
| 150 | + { |
|
| 151 | + // both issuer and serial must be present or both absent |
|
| 152 | + if (!$this->hasIssuer()) { |
|
| 153 | + throw new \LogicException("authorityCertSerialNumber not set."); |
|
| 154 | + } |
|
| 155 | + return $this->_authorityCertSerialNumber; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * |
|
| 160 | - * {@inheritdoc} |
|
| 161 | - * @return Sequence |
|
| 162 | - */ |
|
| 163 | - protected function _valueASN1() |
|
| 164 | - { |
|
| 165 | - $elements = array(); |
|
| 166 | - if (isset($this->_keyIdentifier)) { |
|
| 167 | - $elements[] = new ImplicitlyTaggedType(0, |
|
| 168 | - new OctetString($this->_keyIdentifier)); |
|
| 169 | - } |
|
| 170 | - // if either issuer or serial is set, both must be set |
|
| 171 | - if (isset($this->_authorityCertIssuer) || |
|
| 172 | - isset($this->_authorityCertSerialNumber)) { |
|
| 173 | - if (!isset($this->_authorityCertIssuer, |
|
| 174 | - $this->_authorityCertSerialNumber)) { |
|
| 175 | - throw new \LogicException( |
|
| 176 | - "AuthorityKeyIdentifier must have both" . |
|
| 177 | - " authorityCertIssuer and authorityCertSerialNumber" . |
|
| 178 | - " present or both absent."); |
|
| 179 | - } |
|
| 180 | - $elements[] = new ImplicitlyTaggedType(1, |
|
| 181 | - $this->_authorityCertIssuer->toASN1()); |
|
| 182 | - $elements[] = new ImplicitlyTaggedType(2, |
|
| 183 | - new Integer($this->_authorityCertSerialNumber)); |
|
| 184 | - } |
|
| 185 | - return new Sequence(...$elements); |
|
| 186 | - } |
|
| 158 | + /** |
|
| 159 | + * |
|
| 160 | + * {@inheritdoc} |
|
| 161 | + * @return Sequence |
|
| 162 | + */ |
|
| 163 | + protected function _valueASN1() |
|
| 164 | + { |
|
| 165 | + $elements = array(); |
|
| 166 | + if (isset($this->_keyIdentifier)) { |
|
| 167 | + $elements[] = new ImplicitlyTaggedType(0, |
|
| 168 | + new OctetString($this->_keyIdentifier)); |
|
| 169 | + } |
|
| 170 | + // if either issuer or serial is set, both must be set |
|
| 171 | + if (isset($this->_authorityCertIssuer) || |
|
| 172 | + isset($this->_authorityCertSerialNumber)) { |
|
| 173 | + if (!isset($this->_authorityCertIssuer, |
|
| 174 | + $this->_authorityCertSerialNumber)) { |
|
| 175 | + throw new \LogicException( |
|
| 176 | + "AuthorityKeyIdentifier must have both" . |
|
| 177 | + " authorityCertIssuer and authorityCertSerialNumber" . |
|
| 178 | + " present or both absent."); |
|
| 179 | + } |
|
| 180 | + $elements[] = new ImplicitlyTaggedType(1, |
|
| 181 | + $this->_authorityCertIssuer->toASN1()); |
|
| 182 | + $elements[] = new ImplicitlyTaggedType(2, |
|
| 183 | + new Integer($this->_authorityCertSerialNumber)); |
|
| 184 | + } |
|
| 185 | + return new Sequence(...$elements); |
|
| 186 | + } |
|
| 187 | 187 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace X509\Certificate\Extension; |
| 6 | 6 | |
@@ -15,55 +15,55 @@ |
||
| 15 | 15 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.8 |
| 16 | 16 | */ |
| 17 | 17 | class SubjectDirectoryAttributesExtension extends Extension implements |
| 18 | - \Countable, |
|
| 19 | - \IteratorAggregate |
|
| 18 | + \Countable, |
|
| 19 | + \IteratorAggregate |
|
| 20 | 20 | { |
| 21 | - use AttributeContainer; |
|
| 21 | + use AttributeContainer; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Constructor. |
|
| 25 | - * |
|
| 26 | - * @param bool $critical |
|
| 27 | - * @param Attribute ...$attribs One or more Attribute objects |
|
| 28 | - */ |
|
| 29 | - public function __construct(bool $critical, Attribute ...$attribs) |
|
| 30 | - { |
|
| 31 | - parent::__construct(self::OID_SUBJECT_DIRECTORY_ATTRIBUTES, $critical); |
|
| 32 | - $this->_attributes = $attribs; |
|
| 33 | - } |
|
| 23 | + /** |
|
| 24 | + * Constructor. |
|
| 25 | + * |
|
| 26 | + * @param bool $critical |
|
| 27 | + * @param Attribute ...$attribs One or more Attribute objects |
|
| 28 | + */ |
|
| 29 | + public function __construct(bool $critical, Attribute ...$attribs) |
|
| 30 | + { |
|
| 31 | + parent::__construct(self::OID_SUBJECT_DIRECTORY_ATTRIBUTES, $critical); |
|
| 32 | + $this->_attributes = $attribs; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * |
|
| 37 | - * {@inheritdoc} |
|
| 38 | - * @return self |
|
| 39 | - */ |
|
| 40 | - protected static function _fromDER($data, $critical) |
|
| 41 | - { |
|
| 42 | - $attribs = array_map( |
|
| 43 | - function (UnspecifiedType $el) { |
|
| 44 | - return Attribute::fromASN1($el->asSequence()); |
|
| 45 | - }, Sequence::fromDER($data)->elements()); |
|
| 46 | - if (!count($attribs)) { |
|
| 47 | - throw new \UnexpectedValueException( |
|
| 48 | - "SubjectDirectoryAttributes must have at least one Attribute."); |
|
| 49 | - } |
|
| 50 | - return new self($critical, ...$attribs); |
|
| 51 | - } |
|
| 35 | + /** |
|
| 36 | + * |
|
| 37 | + * {@inheritdoc} |
|
| 38 | + * @return self |
|
| 39 | + */ |
|
| 40 | + protected static function _fromDER($data, $critical) |
|
| 41 | + { |
|
| 42 | + $attribs = array_map( |
|
| 43 | + function (UnspecifiedType $el) { |
|
| 44 | + return Attribute::fromASN1($el->asSequence()); |
|
| 45 | + }, Sequence::fromDER($data)->elements()); |
|
| 46 | + if (!count($attribs)) { |
|
| 47 | + throw new \UnexpectedValueException( |
|
| 48 | + "SubjectDirectoryAttributes must have at least one Attribute."); |
|
| 49 | + } |
|
| 50 | + return new self($critical, ...$attribs); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * |
|
| 55 | - * {@inheritdoc} |
|
| 56 | - * @return Sequence |
|
| 57 | - */ |
|
| 58 | - protected function _valueASN1(): Sequence |
|
| 59 | - { |
|
| 60 | - if (!count($this->_attributes)) { |
|
| 61 | - throw new \LogicException("No attributes"); |
|
| 62 | - } |
|
| 63 | - $elements = array_map( |
|
| 64 | - function (Attribute $attr) { |
|
| 65 | - return $attr->toASN1(); |
|
| 66 | - }, array_values($this->_attributes)); |
|
| 67 | - return new Sequence(...$elements); |
|
| 68 | - } |
|
| 53 | + /** |
|
| 54 | + * |
|
| 55 | + * {@inheritdoc} |
|
| 56 | + * @return Sequence |
|
| 57 | + */ |
|
| 58 | + protected function _valueASN1(): Sequence |
|
| 59 | + { |
|
| 60 | + if (!count($this->_attributes)) { |
|
| 61 | + throw new \LogicException("No attributes"); |
|
| 62 | + } |
|
| 63 | + $elements = array_map( |
|
| 64 | + function (Attribute $attr) { |
|
| 65 | + return $attr->toASN1(); |
|
| 66 | + }, array_values($this->_attributes)); |
|
| 67 | + return new Sequence(...$elements); |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace X509\Certificate\Extension; |
| 6 | 6 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | protected static function _fromDER($data, $critical) |
| 41 | 41 | { |
| 42 | 42 | $attribs = array_map( |
| 43 | - function (UnspecifiedType $el) { |
|
| 43 | + function(UnspecifiedType $el) { |
|
| 44 | 44 | return Attribute::fromASN1($el->asSequence()); |
| 45 | 45 | }, Sequence::fromDER($data)->elements()); |
| 46 | 46 | if (!count($attribs)) { |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | throw new \LogicException("No attributes"); |
| 62 | 62 | } |
| 63 | 63 | $elements = array_map( |
| 64 | - function (Attribute $attr) { |
|
| 64 | + function(Attribute $attr) { |
|
| 65 | 65 | return $attr->toASN1(); |
| 66 | 66 | }, array_values($this->_attributes)); |
| 67 | 67 | return new Sequence(...$elements); |
@@ -15,52 +15,52 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class FullName extends DistributionPointName |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * Names. |
|
| 20 | - * |
|
| 21 | - * @var GeneralNames $_names |
|
| 22 | - */ |
|
| 23 | - protected $_names; |
|
| 18 | + /** |
|
| 19 | + * Names. |
|
| 20 | + * |
|
| 21 | + * @var GeneralNames $_names |
|
| 22 | + */ |
|
| 23 | + protected $_names; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Constructor. |
|
| 27 | - * |
|
| 28 | - * @param GeneralNames $names |
|
| 29 | - */ |
|
| 30 | - public function __construct(GeneralNames $names) |
|
| 31 | - { |
|
| 32 | - $this->_tag = self::TAG_FULL_NAME; |
|
| 33 | - $this->_names = $names; |
|
| 34 | - } |
|
| 25 | + /** |
|
| 26 | + * Constructor. |
|
| 27 | + * |
|
| 28 | + * @param GeneralNames $names |
|
| 29 | + */ |
|
| 30 | + public function __construct(GeneralNames $names) |
|
| 31 | + { |
|
| 32 | + $this->_tag = self::TAG_FULL_NAME; |
|
| 33 | + $this->_names = $names; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Initialize with a single URI. |
|
| 38 | - * |
|
| 39 | - * @param string $uri |
|
| 40 | - * @return self |
|
| 41 | - */ |
|
| 42 | - public static function fromURI(string $uri) |
|
| 43 | - { |
|
| 44 | - return new self(new GeneralNames(new UniformResourceIdentifier($uri))); |
|
| 45 | - } |
|
| 36 | + /** |
|
| 37 | + * Initialize with a single URI. |
|
| 38 | + * |
|
| 39 | + * @param string $uri |
|
| 40 | + * @return self |
|
| 41 | + */ |
|
| 42 | + public static function fromURI(string $uri) |
|
| 43 | + { |
|
| 44 | + return new self(new GeneralNames(new UniformResourceIdentifier($uri))); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Get names. |
|
| 49 | - * |
|
| 50 | - * @return GeneralNames |
|
| 51 | - */ |
|
| 52 | - public function names(): GeneralNames |
|
| 53 | - { |
|
| 54 | - return $this->_names; |
|
| 55 | - } |
|
| 47 | + /** |
|
| 48 | + * Get names. |
|
| 49 | + * |
|
| 50 | + * @return GeneralNames |
|
| 51 | + */ |
|
| 52 | + public function names(): GeneralNames |
|
| 53 | + { |
|
| 54 | + return $this->_names; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * |
|
| 59 | - * {@inheritdoc} |
|
| 60 | - * @return \ASN1\Type\Constructed\Sequence |
|
| 61 | - */ |
|
| 62 | - protected function _valueASN1(): \ASN1\Type\Constructed\Sequence |
|
| 63 | - { |
|
| 64 | - return $this->_names->toASN1(); |
|
| 65 | - } |
|
| 57 | + /** |
|
| 58 | + * |
|
| 59 | + * {@inheritdoc} |
|
| 60 | + * @return \ASN1\Type\Constructed\Sequence |
|
| 61 | + */ |
|
| 62 | + protected function _valueASN1(): \ASN1\Type\Constructed\Sequence |
|
| 63 | + { |
|
| 64 | + return $this->_names->toASN1(); |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace X509\Certificate\Extension\DistributionPoint; |
| 6 | 6 | |