@@ -16,51 +16,51 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class FullName extends DistributionPointName |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Names. |
|
| 21 | - * |
|
| 22 | - * @var GeneralNames |
|
| 23 | - */ |
|
| 24 | - protected $_names; |
|
| 19 | + /** |
|
| 20 | + * Names. |
|
| 21 | + * |
|
| 22 | + * @var GeneralNames |
|
| 23 | + */ |
|
| 24 | + protected $_names; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Constructor. |
|
| 28 | - * |
|
| 29 | - * @param GeneralNames $names |
|
| 30 | - */ |
|
| 31 | - public function __construct(GeneralNames $names) |
|
| 32 | - { |
|
| 33 | - $this->_tag = self::TAG_FULL_NAME; |
|
| 34 | - $this->_names = $names; |
|
| 35 | - } |
|
| 26 | + /** |
|
| 27 | + * Constructor. |
|
| 28 | + * |
|
| 29 | + * @param GeneralNames $names |
|
| 30 | + */ |
|
| 31 | + public function __construct(GeneralNames $names) |
|
| 32 | + { |
|
| 33 | + $this->_tag = self::TAG_FULL_NAME; |
|
| 34 | + $this->_names = $names; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Initialize with a single URI. |
|
| 39 | - * |
|
| 40 | - * @param string $uri |
|
| 41 | - * |
|
| 42 | - * @return self |
|
| 43 | - */ |
|
| 44 | - public static function fromURI(string $uri): self |
|
| 45 | - { |
|
| 46 | - return new self(new GeneralNames(new UniformResourceIdentifier($uri))); |
|
| 47 | - } |
|
| 37 | + /** |
|
| 38 | + * Initialize with a single URI. |
|
| 39 | + * |
|
| 40 | + * @param string $uri |
|
| 41 | + * |
|
| 42 | + * @return self |
|
| 43 | + */ |
|
| 44 | + public static function fromURI(string $uri): self |
|
| 45 | + { |
|
| 46 | + return new self(new GeneralNames(new UniformResourceIdentifier($uri))); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Get names. |
|
| 51 | - * |
|
| 52 | - * @return GeneralNames |
|
| 53 | - */ |
|
| 54 | - public function names(): GeneralNames |
|
| 55 | - { |
|
| 56 | - return $this->_names; |
|
| 57 | - } |
|
| 49 | + /** |
|
| 50 | + * Get names. |
|
| 51 | + * |
|
| 52 | + * @return GeneralNames |
|
| 53 | + */ |
|
| 54 | + public function names(): GeneralNames |
|
| 55 | + { |
|
| 56 | + return $this->_names; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * {@inheritdoc} |
|
| 61 | - */ |
|
| 62 | - protected function _valueASN1(): Element |
|
| 63 | - { |
|
| 64 | - return $this->_names->toASN1(); |
|
| 65 | - } |
|
| 59 | + /** |
|
| 60 | + * {@inheritdoc} |
|
| 61 | + */ |
|
| 62 | + protected function _valueASN1(): Element |
|
| 63 | + { |
|
| 64 | + return $this->_names->toASN1(); |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -18,65 +18,65 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | abstract class DistributionPointName |
| 20 | 20 | { |
| 21 | - const TAG_FULL_NAME = 0; |
|
| 22 | - const TAG_RDN = 1; |
|
| 21 | + const TAG_FULL_NAME = 0; |
|
| 22 | + const TAG_RDN = 1; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Type. |
|
| 26 | - * |
|
| 27 | - * @var int |
|
| 28 | - */ |
|
| 29 | - protected $_tag; |
|
| 24 | + /** |
|
| 25 | + * Type. |
|
| 26 | + * |
|
| 27 | + * @var int |
|
| 28 | + */ |
|
| 29 | + protected $_tag; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Initialize from TaggedType. |
|
| 33 | - * |
|
| 34 | - * @param TaggedType $el |
|
| 35 | - * |
|
| 36 | - * @throws \UnexpectedValueException |
|
| 37 | - * |
|
| 38 | - * @return self |
|
| 39 | - */ |
|
| 40 | - public static function fromTaggedType(TaggedType $el): self |
|
| 41 | - { |
|
| 42 | - switch ($el->tag()) { |
|
| 43 | - case self::TAG_FULL_NAME: |
|
| 44 | - return new FullName( |
|
| 45 | - GeneralNames::fromASN1( |
|
| 46 | - $el->asImplicit(Element::TYPE_SEQUENCE)->asSequence())); |
|
| 47 | - case self::TAG_RDN: |
|
| 48 | - return new RelativeName( |
|
| 49 | - RDN::fromASN1($el->asImplicit(Element::TYPE_SET)->asSet())); |
|
| 50 | - default: |
|
| 51 | - throw new \UnexpectedValueException( |
|
| 52 | - 'DistributionPointName tag ' . $el->tag() . ' not supported.'); |
|
| 53 | - } |
|
| 54 | - } |
|
| 31 | + /** |
|
| 32 | + * Initialize from TaggedType. |
|
| 33 | + * |
|
| 34 | + * @param TaggedType $el |
|
| 35 | + * |
|
| 36 | + * @throws \UnexpectedValueException |
|
| 37 | + * |
|
| 38 | + * @return self |
|
| 39 | + */ |
|
| 40 | + public static function fromTaggedType(TaggedType $el): self |
|
| 41 | + { |
|
| 42 | + switch ($el->tag()) { |
|
| 43 | + case self::TAG_FULL_NAME: |
|
| 44 | + return new FullName( |
|
| 45 | + GeneralNames::fromASN1( |
|
| 46 | + $el->asImplicit(Element::TYPE_SEQUENCE)->asSequence())); |
|
| 47 | + case self::TAG_RDN: |
|
| 48 | + return new RelativeName( |
|
| 49 | + RDN::fromASN1($el->asImplicit(Element::TYPE_SET)->asSet())); |
|
| 50 | + default: |
|
| 51 | + throw new \UnexpectedValueException( |
|
| 52 | + 'DistributionPointName tag ' . $el->tag() . ' not supported.'); |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Get type tag. |
|
| 58 | - * |
|
| 59 | - * @return int |
|
| 60 | - */ |
|
| 61 | - public function tag(): int |
|
| 62 | - { |
|
| 63 | - return $this->_tag; |
|
| 64 | - } |
|
| 56 | + /** |
|
| 57 | + * Get type tag. |
|
| 58 | + * |
|
| 59 | + * @return int |
|
| 60 | + */ |
|
| 61 | + public function tag(): int |
|
| 62 | + { |
|
| 63 | + return $this->_tag; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Generate ASN.1 structure. |
|
| 68 | - * |
|
| 69 | - * @return ImplicitlyTaggedType |
|
| 70 | - */ |
|
| 71 | - public function toASN1(): ImplicitlyTaggedType |
|
| 72 | - { |
|
| 73 | - return new ImplicitlyTaggedType($this->_tag, $this->_valueASN1()); |
|
| 74 | - } |
|
| 66 | + /** |
|
| 67 | + * Generate ASN.1 structure. |
|
| 68 | + * |
|
| 69 | + * @return ImplicitlyTaggedType |
|
| 70 | + */ |
|
| 71 | + public function toASN1(): ImplicitlyTaggedType |
|
| 72 | + { |
|
| 73 | + return new ImplicitlyTaggedType($this->_tag, $this->_valueASN1()); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Generate ASN.1 element. |
|
| 78 | - * |
|
| 79 | - * @return Element |
|
| 80 | - */ |
|
| 81 | - abstract protected function _valueASN1(): Element; |
|
| 76 | + /** |
|
| 77 | + * Generate ASN.1 element. |
|
| 78 | + * |
|
| 79 | + * @return Element |
|
| 80 | + */ |
|
| 81 | + abstract protected function _valueASN1(): Element; |
|
| 82 | 82 | } |
@@ -18,217 +18,217 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class DistributionPoint |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * Distribution point name. |
|
| 23 | - * |
|
| 24 | - * @var null|DistributionPointName |
|
| 25 | - */ |
|
| 26 | - protected $_distributionPoint; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Revocation reason. |
|
| 30 | - * |
|
| 31 | - * @var null|ReasonFlags |
|
| 32 | - */ |
|
| 33 | - protected $_reasons; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * CRL issuer. |
|
| 37 | - * |
|
| 38 | - * @var null|GeneralNames |
|
| 39 | - */ |
|
| 40 | - protected $_issuer; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Constructor. |
|
| 44 | - * |
|
| 45 | - * @param null|DistributionPointName $name |
|
| 46 | - * @param null|ReasonFlags $reasons |
|
| 47 | - * @param null|GeneralNames $issuer |
|
| 48 | - */ |
|
| 49 | - public function __construct(?DistributionPointName $name = null, |
|
| 50 | - ?ReasonFlags $reasons = null, ?GeneralNames $issuer = null) |
|
| 51 | - { |
|
| 52 | - $this->_distributionPoint = $name; |
|
| 53 | - $this->_reasons = $reasons; |
|
| 54 | - $this->_issuer = $issuer; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Initialize from ASN.1. |
|
| 59 | - * |
|
| 60 | - * @param Sequence $seq |
|
| 61 | - * |
|
| 62 | - * @return self |
|
| 63 | - */ |
|
| 64 | - public static function fromASN1(Sequence $seq): self |
|
| 65 | - { |
|
| 66 | - $name = null; |
|
| 67 | - $reasons = null; |
|
| 68 | - $issuer = null; |
|
| 69 | - if ($seq->hasTagged(0)) { |
|
| 70 | - // promoted to explicit tagging because underlying type is CHOICE |
|
| 71 | - $name = DistributionPointName::fromTaggedType( |
|
| 72 | - $seq->getTagged(0)->asExplicit()->asTagged()); |
|
| 73 | - } |
|
| 74 | - if ($seq->hasTagged(1)) { |
|
| 75 | - $reasons = ReasonFlags::fromASN1( |
|
| 76 | - $seq->getTagged(1)->asImplicit(Element::TYPE_BIT_STRING) |
|
| 77 | - ->asBitString()); |
|
| 78 | - } |
|
| 79 | - if ($seq->hasTagged(2)) { |
|
| 80 | - $issuer = GeneralNames::fromASN1( |
|
| 81 | - $seq->getTagged(2)->asImplicit(Element::TYPE_SEQUENCE) |
|
| 82 | - ->asSequence()); |
|
| 83 | - } |
|
| 84 | - return new self($name, $reasons, $issuer); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Check whether distribution point name is set. |
|
| 89 | - * |
|
| 90 | - * @return bool |
|
| 91 | - */ |
|
| 92 | - public function hasDistributionPointName(): bool |
|
| 93 | - { |
|
| 94 | - return isset($this->_distributionPoint); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Get distribution point name. |
|
| 99 | - * |
|
| 100 | - * @throws \LogicException If not set |
|
| 101 | - * |
|
| 102 | - * @return DistributionPointName |
|
| 103 | - */ |
|
| 104 | - public function distributionPointName(): DistributionPointName |
|
| 105 | - { |
|
| 106 | - if (!$this->hasDistributionPointName()) { |
|
| 107 | - throw new \LogicException('distributionPoint not set.'); |
|
| 108 | - } |
|
| 109 | - return $this->_distributionPoint; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Check whether distribution point name is set and it's a full name. |
|
| 114 | - * |
|
| 115 | - * @return bool |
|
| 116 | - */ |
|
| 117 | - public function hasFullName(): bool |
|
| 118 | - { |
|
| 119 | - return DistributionPointName::TAG_FULL_NAME === |
|
| 120 | - $this->distributionPointName()->tag(); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Get full distribution point name. |
|
| 125 | - * |
|
| 126 | - * @throws \LogicException If not set |
|
| 127 | - * |
|
| 128 | - * @return FullName |
|
| 129 | - */ |
|
| 130 | - public function fullName(): FullName |
|
| 131 | - { |
|
| 132 | - if (!$this->hasFullName()) { |
|
| 133 | - throw new \LogicException('fullName not set.'); |
|
| 134 | - } |
|
| 135 | - return $this->_distributionPoint; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * Check whether distribution point name is set and it's a relative name. |
|
| 140 | - * |
|
| 141 | - * @return bool |
|
| 142 | - */ |
|
| 143 | - public function hasRelativeName(): bool |
|
| 144 | - { |
|
| 145 | - return DistributionPointName::TAG_RDN === |
|
| 146 | - $this->distributionPointName()->tag(); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Get relative distribution point name. |
|
| 151 | - * |
|
| 152 | - * @throws \LogicException If not set |
|
| 153 | - * |
|
| 154 | - * @return RelativeName |
|
| 155 | - */ |
|
| 156 | - public function relativeName(): RelativeName |
|
| 157 | - { |
|
| 158 | - if (!$this->hasRelativeName()) { |
|
| 159 | - throw new \LogicException('nameRelativeToCRLIssuer not set.'); |
|
| 160 | - } |
|
| 161 | - return $this->_distributionPoint; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Check whether reasons flags is set. |
|
| 166 | - * |
|
| 167 | - * @return bool |
|
| 168 | - */ |
|
| 169 | - public function hasReasons(): bool |
|
| 170 | - { |
|
| 171 | - return isset($this->_reasons); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Get revocation reason flags. |
|
| 176 | - * |
|
| 177 | - * @throws \LogicException If not set |
|
| 178 | - * |
|
| 179 | - * @return ReasonFlags |
|
| 180 | - */ |
|
| 181 | - public function reasons(): ReasonFlags |
|
| 182 | - { |
|
| 183 | - if (!$this->hasReasons()) { |
|
| 184 | - throw new \LogicException('reasons not set.'); |
|
| 185 | - } |
|
| 186 | - return $this->_reasons; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * Check whether cRLIssuer is set. |
|
| 191 | - * |
|
| 192 | - * @return bool |
|
| 193 | - */ |
|
| 194 | - public function hasCRLIssuer(): bool |
|
| 195 | - { |
|
| 196 | - return isset($this->_issuer); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * Get CRL issuer. |
|
| 201 | - * |
|
| 202 | - * @throws \LogicException If not set |
|
| 203 | - * |
|
| 204 | - * @return GeneralNames |
|
| 205 | - */ |
|
| 206 | - public function crlIssuer(): GeneralNames |
|
| 207 | - { |
|
| 208 | - if (!$this->hasCRLIssuer()) { |
|
| 209 | - throw new \LogicException('crlIssuer not set.'); |
|
| 210 | - } |
|
| 211 | - return $this->_issuer; |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * Generate ASN.1 structure. |
|
| 216 | - * |
|
| 217 | - * @return Sequence |
|
| 218 | - */ |
|
| 219 | - public function toASN1(): Sequence |
|
| 220 | - { |
|
| 221 | - $elements = []; |
|
| 222 | - if (isset($this->_distributionPoint)) { |
|
| 223 | - $elements[] = new ExplicitlyTaggedType(0, |
|
| 224 | - $this->_distributionPoint->toASN1()); |
|
| 225 | - } |
|
| 226 | - if (isset($this->_reasons)) { |
|
| 227 | - $elements[] = new ImplicitlyTaggedType(1, $this->_reasons->toASN1()); |
|
| 228 | - } |
|
| 229 | - if (isset($this->_issuer)) { |
|
| 230 | - $elements[] = new ImplicitlyTaggedType(2, $this->_issuer->toASN1()); |
|
| 231 | - } |
|
| 232 | - return new Sequence(...$elements); |
|
| 233 | - } |
|
| 21 | + /** |
|
| 22 | + * Distribution point name. |
|
| 23 | + * |
|
| 24 | + * @var null|DistributionPointName |
|
| 25 | + */ |
|
| 26 | + protected $_distributionPoint; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Revocation reason. |
|
| 30 | + * |
|
| 31 | + * @var null|ReasonFlags |
|
| 32 | + */ |
|
| 33 | + protected $_reasons; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * CRL issuer. |
|
| 37 | + * |
|
| 38 | + * @var null|GeneralNames |
|
| 39 | + */ |
|
| 40 | + protected $_issuer; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Constructor. |
|
| 44 | + * |
|
| 45 | + * @param null|DistributionPointName $name |
|
| 46 | + * @param null|ReasonFlags $reasons |
|
| 47 | + * @param null|GeneralNames $issuer |
|
| 48 | + */ |
|
| 49 | + public function __construct(?DistributionPointName $name = null, |
|
| 50 | + ?ReasonFlags $reasons = null, ?GeneralNames $issuer = null) |
|
| 51 | + { |
|
| 52 | + $this->_distributionPoint = $name; |
|
| 53 | + $this->_reasons = $reasons; |
|
| 54 | + $this->_issuer = $issuer; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Initialize from ASN.1. |
|
| 59 | + * |
|
| 60 | + * @param Sequence $seq |
|
| 61 | + * |
|
| 62 | + * @return self |
|
| 63 | + */ |
|
| 64 | + public static function fromASN1(Sequence $seq): self |
|
| 65 | + { |
|
| 66 | + $name = null; |
|
| 67 | + $reasons = null; |
|
| 68 | + $issuer = null; |
|
| 69 | + if ($seq->hasTagged(0)) { |
|
| 70 | + // promoted to explicit tagging because underlying type is CHOICE |
|
| 71 | + $name = DistributionPointName::fromTaggedType( |
|
| 72 | + $seq->getTagged(0)->asExplicit()->asTagged()); |
|
| 73 | + } |
|
| 74 | + if ($seq->hasTagged(1)) { |
|
| 75 | + $reasons = ReasonFlags::fromASN1( |
|
| 76 | + $seq->getTagged(1)->asImplicit(Element::TYPE_BIT_STRING) |
|
| 77 | + ->asBitString()); |
|
| 78 | + } |
|
| 79 | + if ($seq->hasTagged(2)) { |
|
| 80 | + $issuer = GeneralNames::fromASN1( |
|
| 81 | + $seq->getTagged(2)->asImplicit(Element::TYPE_SEQUENCE) |
|
| 82 | + ->asSequence()); |
|
| 83 | + } |
|
| 84 | + return new self($name, $reasons, $issuer); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Check whether distribution point name is set. |
|
| 89 | + * |
|
| 90 | + * @return bool |
|
| 91 | + */ |
|
| 92 | + public function hasDistributionPointName(): bool |
|
| 93 | + { |
|
| 94 | + return isset($this->_distributionPoint); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * Get distribution point name. |
|
| 99 | + * |
|
| 100 | + * @throws \LogicException If not set |
|
| 101 | + * |
|
| 102 | + * @return DistributionPointName |
|
| 103 | + */ |
|
| 104 | + public function distributionPointName(): DistributionPointName |
|
| 105 | + { |
|
| 106 | + if (!$this->hasDistributionPointName()) { |
|
| 107 | + throw new \LogicException('distributionPoint not set.'); |
|
| 108 | + } |
|
| 109 | + return $this->_distributionPoint; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Check whether distribution point name is set and it's a full name. |
|
| 114 | + * |
|
| 115 | + * @return bool |
|
| 116 | + */ |
|
| 117 | + public function hasFullName(): bool |
|
| 118 | + { |
|
| 119 | + return DistributionPointName::TAG_FULL_NAME === |
|
| 120 | + $this->distributionPointName()->tag(); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Get full distribution point name. |
|
| 125 | + * |
|
| 126 | + * @throws \LogicException If not set |
|
| 127 | + * |
|
| 128 | + * @return FullName |
|
| 129 | + */ |
|
| 130 | + public function fullName(): FullName |
|
| 131 | + { |
|
| 132 | + if (!$this->hasFullName()) { |
|
| 133 | + throw new \LogicException('fullName not set.'); |
|
| 134 | + } |
|
| 135 | + return $this->_distributionPoint; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * Check whether distribution point name is set and it's a relative name. |
|
| 140 | + * |
|
| 141 | + * @return bool |
|
| 142 | + */ |
|
| 143 | + public function hasRelativeName(): bool |
|
| 144 | + { |
|
| 145 | + return DistributionPointName::TAG_RDN === |
|
| 146 | + $this->distributionPointName()->tag(); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Get relative distribution point name. |
|
| 151 | + * |
|
| 152 | + * @throws \LogicException If not set |
|
| 153 | + * |
|
| 154 | + * @return RelativeName |
|
| 155 | + */ |
|
| 156 | + public function relativeName(): RelativeName |
|
| 157 | + { |
|
| 158 | + if (!$this->hasRelativeName()) { |
|
| 159 | + throw new \LogicException('nameRelativeToCRLIssuer not set.'); |
|
| 160 | + } |
|
| 161 | + return $this->_distributionPoint; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Check whether reasons flags is set. |
|
| 166 | + * |
|
| 167 | + * @return bool |
|
| 168 | + */ |
|
| 169 | + public function hasReasons(): bool |
|
| 170 | + { |
|
| 171 | + return isset($this->_reasons); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Get revocation reason flags. |
|
| 176 | + * |
|
| 177 | + * @throws \LogicException If not set |
|
| 178 | + * |
|
| 179 | + * @return ReasonFlags |
|
| 180 | + */ |
|
| 181 | + public function reasons(): ReasonFlags |
|
| 182 | + { |
|
| 183 | + if (!$this->hasReasons()) { |
|
| 184 | + throw new \LogicException('reasons not set.'); |
|
| 185 | + } |
|
| 186 | + return $this->_reasons; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * Check whether cRLIssuer is set. |
|
| 191 | + * |
|
| 192 | + * @return bool |
|
| 193 | + */ |
|
| 194 | + public function hasCRLIssuer(): bool |
|
| 195 | + { |
|
| 196 | + return isset($this->_issuer); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * Get CRL issuer. |
|
| 201 | + * |
|
| 202 | + * @throws \LogicException If not set |
|
| 203 | + * |
|
| 204 | + * @return GeneralNames |
|
| 205 | + */ |
|
| 206 | + public function crlIssuer(): GeneralNames |
|
| 207 | + { |
|
| 208 | + if (!$this->hasCRLIssuer()) { |
|
| 209 | + throw new \LogicException('crlIssuer not set.'); |
|
| 210 | + } |
|
| 211 | + return $this->_issuer; |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * Generate ASN.1 structure. |
|
| 216 | + * |
|
| 217 | + * @return Sequence |
|
| 218 | + */ |
|
| 219 | + public function toASN1(): Sequence |
|
| 220 | + { |
|
| 221 | + $elements = []; |
|
| 222 | + if (isset($this->_distributionPoint)) { |
|
| 223 | + $elements[] = new ExplicitlyTaggedType(0, |
|
| 224 | + $this->_distributionPoint->toASN1()); |
|
| 225 | + } |
|
| 226 | + if (isset($this->_reasons)) { |
|
| 227 | + $elements[] = new ImplicitlyTaggedType(1, $this->_reasons->toASN1()); |
|
| 228 | + } |
|
| 229 | + if (isset($this->_issuer)) { |
|
| 230 | + $elements[] = new ImplicitlyTaggedType(2, $this->_issuer->toASN1()); |
|
| 231 | + } |
|
| 232 | + return new Sequence(...$elements); |
|
| 233 | + } |
|
| 234 | 234 | } |
@@ -17,80 +17,80 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class SubjectInformationAccessExtension extends Extension implements \Countable, \IteratorAggregate |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Access descriptions. |
|
| 22 | - * |
|
| 23 | - * @var SubjectAccessDescription[] |
|
| 24 | - */ |
|
| 25 | - private $_accessDescriptions; |
|
| 20 | + /** |
|
| 21 | + * Access descriptions. |
|
| 22 | + * |
|
| 23 | + * @var SubjectAccessDescription[] |
|
| 24 | + */ |
|
| 25 | + private $_accessDescriptions; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Constructor. |
|
| 29 | - * |
|
| 30 | - * @param bool $critical |
|
| 31 | - * @param SubjectAccessDescription ...$access |
|
| 32 | - */ |
|
| 33 | - public function __construct(bool $critical, SubjectAccessDescription ...$access) |
|
| 34 | - { |
|
| 35 | - parent::__construct(self::OID_SUBJECT_INFORMATION_ACCESS, $critical); |
|
| 36 | - $this->_accessDescriptions = $access; |
|
| 37 | - } |
|
| 27 | + /** |
|
| 28 | + * Constructor. |
|
| 29 | + * |
|
| 30 | + * @param bool $critical |
|
| 31 | + * @param SubjectAccessDescription ...$access |
|
| 32 | + */ |
|
| 33 | + public function __construct(bool $critical, SubjectAccessDescription ...$access) |
|
| 34 | + { |
|
| 35 | + parent::__construct(self::OID_SUBJECT_INFORMATION_ACCESS, $critical); |
|
| 36 | + $this->_accessDescriptions = $access; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Get the access descriptions. |
|
| 41 | - * |
|
| 42 | - * @return SubjectAccessDescription[] |
|
| 43 | - */ |
|
| 44 | - public function accessDescriptions(): array |
|
| 45 | - { |
|
| 46 | - return $this->_accessDescriptions; |
|
| 47 | - } |
|
| 39 | + /** |
|
| 40 | + * Get the access descriptions. |
|
| 41 | + * |
|
| 42 | + * @return SubjectAccessDescription[] |
|
| 43 | + */ |
|
| 44 | + public function accessDescriptions(): array |
|
| 45 | + { |
|
| 46 | + return $this->_accessDescriptions; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Get the number of access descriptions. |
|
| 51 | - * |
|
| 52 | - * @see \Countable::count() |
|
| 53 | - * |
|
| 54 | - * @return int |
|
| 55 | - */ |
|
| 56 | - public function count(): int |
|
| 57 | - { |
|
| 58 | - return count($this->_accessDescriptions); |
|
| 59 | - } |
|
| 49 | + /** |
|
| 50 | + * Get the number of access descriptions. |
|
| 51 | + * |
|
| 52 | + * @see \Countable::count() |
|
| 53 | + * |
|
| 54 | + * @return int |
|
| 55 | + */ |
|
| 56 | + public function count(): int |
|
| 57 | + { |
|
| 58 | + return count($this->_accessDescriptions); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Get iterator for access descriptions. |
|
| 63 | - * |
|
| 64 | - * @see \IteratorAggregate::getIterator() |
|
| 65 | - * |
|
| 66 | - * @return \ArrayIterator List of SubjectAccessDescription objects |
|
| 67 | - */ |
|
| 68 | - public function getIterator(): \ArrayIterator |
|
| 69 | - { |
|
| 70 | - return new \ArrayIterator($this->_accessDescriptions); |
|
| 71 | - } |
|
| 61 | + /** |
|
| 62 | + * Get iterator for access descriptions. |
|
| 63 | + * |
|
| 64 | + * @see \IteratorAggregate::getIterator() |
|
| 65 | + * |
|
| 66 | + * @return \ArrayIterator List of SubjectAccessDescription objects |
|
| 67 | + */ |
|
| 68 | + public function getIterator(): \ArrayIterator |
|
| 69 | + { |
|
| 70 | + return new \ArrayIterator($this->_accessDescriptions); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * {@inheritdoc} |
|
| 75 | - */ |
|
| 76 | - protected static function _fromDER(string $data, bool $critical): Extension |
|
| 77 | - { |
|
| 78 | - $access = array_map( |
|
| 79 | - function (UnspecifiedType $el) { |
|
| 80 | - return SubjectAccessDescription::fromASN1($el->asSequence()); |
|
| 81 | - }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
| 82 | - return new self($critical, ...$access); |
|
| 83 | - } |
|
| 73 | + /** |
|
| 74 | + * {@inheritdoc} |
|
| 75 | + */ |
|
| 76 | + protected static function _fromDER(string $data, bool $critical): Extension |
|
| 77 | + { |
|
| 78 | + $access = array_map( |
|
| 79 | + function (UnspecifiedType $el) { |
|
| 80 | + return SubjectAccessDescription::fromASN1($el->asSequence()); |
|
| 81 | + }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
| 82 | + return new self($critical, ...$access); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * {@inheritdoc} |
|
| 87 | - */ |
|
| 88 | - protected function _valueASN1(): Element |
|
| 89 | - { |
|
| 90 | - $elements = array_map( |
|
| 91 | - function (AccessDescription $access) { |
|
| 92 | - return $access->toASN1(); |
|
| 93 | - }, $this->_accessDescriptions); |
|
| 94 | - return new Sequence(...$elements); |
|
| 95 | - } |
|
| 85 | + /** |
|
| 86 | + * {@inheritdoc} |
|
| 87 | + */ |
|
| 88 | + protected function _valueASN1(): Element |
|
| 89 | + { |
|
| 90 | + $elements = array_map( |
|
| 91 | + function (AccessDescription $access) { |
|
| 92 | + return $access->toASN1(); |
|
| 93 | + }, $this->_accessDescriptions); |
|
| 94 | + return new Sequence(...$elements); |
|
| 95 | + } |
|
| 96 | 96 | } |
@@ -18,277 +18,277 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | abstract class Extension |
| 20 | 20 | { |
| 21 | - // OID's from standard certificate extensions |
|
| 22 | - const OID_OBSOLETE_AUTHORITY_KEY_IDENTIFIER = '2.5.29.1'; |
|
| 23 | - const OID_OBSOLETE_KEY_ATTRIBUTES = '2.5.29.2'; |
|
| 24 | - const OID_OBSOLETE_CERTIFICATE_POLICIES = '2.5.29.3'; |
|
| 25 | - const OID_OBSOLETE_KEY_USAGE_RESTRICTION = '2.5.29.4'; |
|
| 26 | - const OID_OBSOLETE_POLICY_MAPPING = '2.5.29.5'; |
|
| 27 | - const OID_OBSOLETE_SUBTREES_CONSTRAINT = '2.5.29.6'; |
|
| 28 | - const OID_OBSOLETE_SUBJECT_ALT_NAME = '2.5.29.7'; |
|
| 29 | - const OID_OBSOLETE_ISSUER_ALT_NAME = '2.5.29.8'; |
|
| 30 | - const OID_SUBJECT_DIRECTORY_ATTRIBUTES = '2.5.29.9'; |
|
| 31 | - const OID_OBSOLETE_BASIC_CONSTRAINTS = '2.5.29.10'; |
|
| 32 | - const OID_SUBJECT_KEY_IDENTIFIER = '2.5.29.14'; |
|
| 33 | - const OID_KEY_USAGE = '2.5.29.15'; |
|
| 34 | - const OID_PRIVATE_KEY_USAGE_PERIOD = '2.5.29.16'; |
|
| 35 | - const OID_SUBJECT_ALT_NAME = '2.5.29.17'; |
|
| 36 | - const OID_ISSUER_ALT_NAME = '2.5.29.18'; |
|
| 37 | - const OID_BASIC_CONSTRAINTS = '2.5.29.19'; |
|
| 38 | - const OID_CRL_NUMBER = '2.5.29.20'; |
|
| 39 | - const OID_REASON_CODE = '2.5.29.21'; |
|
| 40 | - const OID_OBSOLETE_EXPIRATION_DATE = '2.5.29.22'; |
|
| 41 | - const OID_INSTRUCTION_CODE = '2.5.29.23'; |
|
| 42 | - const OID_INVALIDITY_DATE = '2.5.29.24'; |
|
| 43 | - const OID_OBSOLETE_CRL_DISTRIBUTION_POINTS = '2.5.29.25'; |
|
| 44 | - const OID_OBSOLETE_ISSUING_DISTRIBUTION_POINT = '2.5.29.26'; |
|
| 45 | - const OID_DELTA_CRL_INDICATOR = '2.5.29.27'; |
|
| 46 | - const OID_ISSUING_DISTRIBUTION_POINT = '2.5.29.28'; |
|
| 47 | - const OID_CERTIFICATE_ISSUER = '2.5.29.29'; |
|
| 48 | - const OID_NAME_CONSTRAINTS = '2.5.29.30'; |
|
| 49 | - const OID_CRL_DISTRIBUTION_POINTS = '2.5.29.31'; |
|
| 50 | - const OID_CERTIFICATE_POLICIES = '2.5.29.32'; |
|
| 51 | - const OID_POLICY_MAPPINGS = '2.5.29.33'; |
|
| 52 | - const OID_OBSOLETE_POLICY_CONSTRAINTS = '2.5.29.34'; |
|
| 53 | - const OID_AUTHORITY_KEY_IDENTIFIER = '2.5.29.35'; |
|
| 54 | - const OID_POLICY_CONSTRAINTS = '2.5.29.36'; |
|
| 55 | - const OID_EXT_KEY_USAGE = '2.5.29.37'; |
|
| 56 | - const OID_AUTHORITY_ATTRIBUTE_IDENTIFIER = '2.5.29.38'; |
|
| 57 | - const OID_ROLE_SPEC_CERT_IDENTIFIER = '2.5.29.39'; |
|
| 58 | - const OID_CRL_STREAM_IDENTIFIER = '2.5.29.40'; |
|
| 59 | - const OID_BASIC_ATT_CONSTRAINTS = '2.5.29.41'; |
|
| 60 | - const OID_DELEGATED_NAME_CONSTRAINTS = '2.5.29.42'; |
|
| 61 | - const OID_TIME_SPECIFICATION = '2.5.29.43'; |
|
| 62 | - const OID_CRL_SCOPE = '2.5.29.44'; |
|
| 63 | - const OID_STATUS_REFERRALS = '2.5.29.45'; |
|
| 64 | - const OID_FRESHEST_CRL = '2.5.29.46'; |
|
| 65 | - const OID_ORDERED_LIST = '2.5.29.47'; |
|
| 66 | - const OID_ATTRIBUTE_DESCRIPTOR = '2.5.29.48'; |
|
| 67 | - const OID_USER_NOTICE = '2.5.29.49'; |
|
| 68 | - const OID_SOA_IDENTIFIER = '2.5.29.50'; |
|
| 69 | - const OID_BASE_UPDATE_TIME = '2.5.29.51'; |
|
| 70 | - const OID_ACCEPTABLE_CERT_POLICIES = '2.5.29.52'; |
|
| 71 | - const OID_DELTA_INFO = '2.5.29.53'; |
|
| 72 | - const OID_INHIBIT_ANY_POLICY = '2.5.29.54'; |
|
| 73 | - const OID_TARGET_INFORMATION = '2.5.29.55'; |
|
| 74 | - const OID_NO_REV_AVAIL = '2.5.29.56'; |
|
| 75 | - const OID_ACCEPTABLE_PRIVILEGE_POLICIES = '2.5.29.57'; |
|
| 76 | - const OID_TO_BE_REVOKED = '2.5.29.58'; |
|
| 77 | - const OID_REVOKED_GROUPS = '2.5.29.59'; |
|
| 78 | - const OID_EXPIRED_CERTS_ON_CRL = '2.5.29.60'; |
|
| 79 | - const OID_INDIRECT_ISSUER = '2.5.29.61'; |
|
| 80 | - const OID_NO_ASSERTION = '2.5.29.62'; |
|
| 81 | - const OID_AA_ISSUING_DISTRIBUTION_POINT = '2.5.29.63'; |
|
| 82 | - const OID_ISSUED_ON_BEHALF_OF = '2.5.29.64'; |
|
| 83 | - const OID_SINGLE_USE = '2.5.29.65'; |
|
| 84 | - const OID_GROUP_AC = '2.5.29.66'; |
|
| 85 | - const OID_ALLOWED_ATT_ASS = '2.5.29.67'; |
|
| 86 | - const OID_ATTRIBUTE_MAPPINGS = '2.5.29.68'; |
|
| 87 | - const OID_HOLDER_NAME_CONSTRAINTS = '2.5.29.69'; |
|
| 21 | + // OID's from standard certificate extensions |
|
| 22 | + const OID_OBSOLETE_AUTHORITY_KEY_IDENTIFIER = '2.5.29.1'; |
|
| 23 | + const OID_OBSOLETE_KEY_ATTRIBUTES = '2.5.29.2'; |
|
| 24 | + const OID_OBSOLETE_CERTIFICATE_POLICIES = '2.5.29.3'; |
|
| 25 | + const OID_OBSOLETE_KEY_USAGE_RESTRICTION = '2.5.29.4'; |
|
| 26 | + const OID_OBSOLETE_POLICY_MAPPING = '2.5.29.5'; |
|
| 27 | + const OID_OBSOLETE_SUBTREES_CONSTRAINT = '2.5.29.6'; |
|
| 28 | + const OID_OBSOLETE_SUBJECT_ALT_NAME = '2.5.29.7'; |
|
| 29 | + const OID_OBSOLETE_ISSUER_ALT_NAME = '2.5.29.8'; |
|
| 30 | + const OID_SUBJECT_DIRECTORY_ATTRIBUTES = '2.5.29.9'; |
|
| 31 | + const OID_OBSOLETE_BASIC_CONSTRAINTS = '2.5.29.10'; |
|
| 32 | + const OID_SUBJECT_KEY_IDENTIFIER = '2.5.29.14'; |
|
| 33 | + const OID_KEY_USAGE = '2.5.29.15'; |
|
| 34 | + const OID_PRIVATE_KEY_USAGE_PERIOD = '2.5.29.16'; |
|
| 35 | + const OID_SUBJECT_ALT_NAME = '2.5.29.17'; |
|
| 36 | + const OID_ISSUER_ALT_NAME = '2.5.29.18'; |
|
| 37 | + const OID_BASIC_CONSTRAINTS = '2.5.29.19'; |
|
| 38 | + const OID_CRL_NUMBER = '2.5.29.20'; |
|
| 39 | + const OID_REASON_CODE = '2.5.29.21'; |
|
| 40 | + const OID_OBSOLETE_EXPIRATION_DATE = '2.5.29.22'; |
|
| 41 | + const OID_INSTRUCTION_CODE = '2.5.29.23'; |
|
| 42 | + const OID_INVALIDITY_DATE = '2.5.29.24'; |
|
| 43 | + const OID_OBSOLETE_CRL_DISTRIBUTION_POINTS = '2.5.29.25'; |
|
| 44 | + const OID_OBSOLETE_ISSUING_DISTRIBUTION_POINT = '2.5.29.26'; |
|
| 45 | + const OID_DELTA_CRL_INDICATOR = '2.5.29.27'; |
|
| 46 | + const OID_ISSUING_DISTRIBUTION_POINT = '2.5.29.28'; |
|
| 47 | + const OID_CERTIFICATE_ISSUER = '2.5.29.29'; |
|
| 48 | + const OID_NAME_CONSTRAINTS = '2.5.29.30'; |
|
| 49 | + const OID_CRL_DISTRIBUTION_POINTS = '2.5.29.31'; |
|
| 50 | + const OID_CERTIFICATE_POLICIES = '2.5.29.32'; |
|
| 51 | + const OID_POLICY_MAPPINGS = '2.5.29.33'; |
|
| 52 | + const OID_OBSOLETE_POLICY_CONSTRAINTS = '2.5.29.34'; |
|
| 53 | + const OID_AUTHORITY_KEY_IDENTIFIER = '2.5.29.35'; |
|
| 54 | + const OID_POLICY_CONSTRAINTS = '2.5.29.36'; |
|
| 55 | + const OID_EXT_KEY_USAGE = '2.5.29.37'; |
|
| 56 | + const OID_AUTHORITY_ATTRIBUTE_IDENTIFIER = '2.5.29.38'; |
|
| 57 | + const OID_ROLE_SPEC_CERT_IDENTIFIER = '2.5.29.39'; |
|
| 58 | + const OID_CRL_STREAM_IDENTIFIER = '2.5.29.40'; |
|
| 59 | + const OID_BASIC_ATT_CONSTRAINTS = '2.5.29.41'; |
|
| 60 | + const OID_DELEGATED_NAME_CONSTRAINTS = '2.5.29.42'; |
|
| 61 | + const OID_TIME_SPECIFICATION = '2.5.29.43'; |
|
| 62 | + const OID_CRL_SCOPE = '2.5.29.44'; |
|
| 63 | + const OID_STATUS_REFERRALS = '2.5.29.45'; |
|
| 64 | + const OID_FRESHEST_CRL = '2.5.29.46'; |
|
| 65 | + const OID_ORDERED_LIST = '2.5.29.47'; |
|
| 66 | + const OID_ATTRIBUTE_DESCRIPTOR = '2.5.29.48'; |
|
| 67 | + const OID_USER_NOTICE = '2.5.29.49'; |
|
| 68 | + const OID_SOA_IDENTIFIER = '2.5.29.50'; |
|
| 69 | + const OID_BASE_UPDATE_TIME = '2.5.29.51'; |
|
| 70 | + const OID_ACCEPTABLE_CERT_POLICIES = '2.5.29.52'; |
|
| 71 | + const OID_DELTA_INFO = '2.5.29.53'; |
|
| 72 | + const OID_INHIBIT_ANY_POLICY = '2.5.29.54'; |
|
| 73 | + const OID_TARGET_INFORMATION = '2.5.29.55'; |
|
| 74 | + const OID_NO_REV_AVAIL = '2.5.29.56'; |
|
| 75 | + const OID_ACCEPTABLE_PRIVILEGE_POLICIES = '2.5.29.57'; |
|
| 76 | + const OID_TO_BE_REVOKED = '2.5.29.58'; |
|
| 77 | + const OID_REVOKED_GROUPS = '2.5.29.59'; |
|
| 78 | + const OID_EXPIRED_CERTS_ON_CRL = '2.5.29.60'; |
|
| 79 | + const OID_INDIRECT_ISSUER = '2.5.29.61'; |
|
| 80 | + const OID_NO_ASSERTION = '2.5.29.62'; |
|
| 81 | + const OID_AA_ISSUING_DISTRIBUTION_POINT = '2.5.29.63'; |
|
| 82 | + const OID_ISSUED_ON_BEHALF_OF = '2.5.29.64'; |
|
| 83 | + const OID_SINGLE_USE = '2.5.29.65'; |
|
| 84 | + const OID_GROUP_AC = '2.5.29.66'; |
|
| 85 | + const OID_ALLOWED_ATT_ASS = '2.5.29.67'; |
|
| 86 | + const OID_ATTRIBUTE_MAPPINGS = '2.5.29.68'; |
|
| 87 | + const OID_HOLDER_NAME_CONSTRAINTS = '2.5.29.69'; |
|
| 88 | 88 | |
| 89 | - // OID's from private certificate extensions arc |
|
| 90 | - const OID_AUTHORITY_INFORMATION_ACCESS = '1.3.6.1.5.5.7.1.1'; |
|
| 91 | - const OID_AA_CONTROLS = '1.3.6.1.5.5.7.1.6'; |
|
| 92 | - const OID_SUBJECT_INFORMATION_ACCESS = '1.3.6.1.5.5.7.1.11'; |
|
| 93 | - const OID_LOGOTYPE = '1.3.6.1.5.5.7.1.12'; |
|
| 89 | + // OID's from private certificate extensions arc |
|
| 90 | + const OID_AUTHORITY_INFORMATION_ACCESS = '1.3.6.1.5.5.7.1.1'; |
|
| 91 | + const OID_AA_CONTROLS = '1.3.6.1.5.5.7.1.6'; |
|
| 92 | + const OID_SUBJECT_INFORMATION_ACCESS = '1.3.6.1.5.5.7.1.11'; |
|
| 93 | + const OID_LOGOTYPE = '1.3.6.1.5.5.7.1.12'; |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Mapping from extension ID to implementation class name. |
|
| 97 | - * |
|
| 98 | - * @internal |
|
| 99 | - * |
|
| 100 | - * @var array |
|
| 101 | - */ |
|
| 102 | - const MAP_OID_TO_CLASS = [ |
|
| 103 | - self::OID_AUTHORITY_KEY_IDENTIFIER => AuthorityKeyIdentifierExtension::class, |
|
| 104 | - self::OID_SUBJECT_KEY_IDENTIFIER => SubjectKeyIdentifierExtension::class, |
|
| 105 | - self::OID_KEY_USAGE => KeyUsageExtension::class, |
|
| 106 | - self::OID_CERTIFICATE_POLICIES => CertificatePoliciesExtension::class, |
|
| 107 | - self::OID_POLICY_MAPPINGS => PolicyMappingsExtension::class, |
|
| 108 | - self::OID_SUBJECT_ALT_NAME => SubjectAlternativeNameExtension::class, |
|
| 109 | - self::OID_ISSUER_ALT_NAME => IssuerAlternativeNameExtension::class, |
|
| 110 | - self::OID_SUBJECT_DIRECTORY_ATTRIBUTES => SubjectDirectoryAttributesExtension::class, |
|
| 111 | - self::OID_BASIC_CONSTRAINTS => BasicConstraintsExtension::class, |
|
| 112 | - self::OID_NAME_CONSTRAINTS => NameConstraintsExtension::class, |
|
| 113 | - self::OID_POLICY_CONSTRAINTS => PolicyConstraintsExtension::class, |
|
| 114 | - self::OID_EXT_KEY_USAGE => ExtendedKeyUsageExtension::class, |
|
| 115 | - self::OID_CRL_DISTRIBUTION_POINTS => CRLDistributionPointsExtension::class, |
|
| 116 | - self::OID_INHIBIT_ANY_POLICY => InhibitAnyPolicyExtension::class, |
|
| 117 | - self::OID_FRESHEST_CRL => FreshestCRLExtension::class, |
|
| 118 | - self::OID_NO_REV_AVAIL => NoRevocationAvailableExtension::class, |
|
| 119 | - self::OID_TARGET_INFORMATION => TargetInformationExtension::class, |
|
| 120 | - self::OID_AUTHORITY_INFORMATION_ACCESS => AuthorityInformationAccessExtension::class, |
|
| 121 | - self::OID_AA_CONTROLS => AAControlsExtension::class, |
|
| 122 | - self::OID_SUBJECT_INFORMATION_ACCESS => SubjectInformationAccessExtension::class, |
|
| 123 | - ]; |
|
| 95 | + /** |
|
| 96 | + * Mapping from extension ID to implementation class name. |
|
| 97 | + * |
|
| 98 | + * @internal |
|
| 99 | + * |
|
| 100 | + * @var array |
|
| 101 | + */ |
|
| 102 | + const MAP_OID_TO_CLASS = [ |
|
| 103 | + self::OID_AUTHORITY_KEY_IDENTIFIER => AuthorityKeyIdentifierExtension::class, |
|
| 104 | + self::OID_SUBJECT_KEY_IDENTIFIER => SubjectKeyIdentifierExtension::class, |
|
| 105 | + self::OID_KEY_USAGE => KeyUsageExtension::class, |
|
| 106 | + self::OID_CERTIFICATE_POLICIES => CertificatePoliciesExtension::class, |
|
| 107 | + self::OID_POLICY_MAPPINGS => PolicyMappingsExtension::class, |
|
| 108 | + self::OID_SUBJECT_ALT_NAME => SubjectAlternativeNameExtension::class, |
|
| 109 | + self::OID_ISSUER_ALT_NAME => IssuerAlternativeNameExtension::class, |
|
| 110 | + self::OID_SUBJECT_DIRECTORY_ATTRIBUTES => SubjectDirectoryAttributesExtension::class, |
|
| 111 | + self::OID_BASIC_CONSTRAINTS => BasicConstraintsExtension::class, |
|
| 112 | + self::OID_NAME_CONSTRAINTS => NameConstraintsExtension::class, |
|
| 113 | + self::OID_POLICY_CONSTRAINTS => PolicyConstraintsExtension::class, |
|
| 114 | + self::OID_EXT_KEY_USAGE => ExtendedKeyUsageExtension::class, |
|
| 115 | + self::OID_CRL_DISTRIBUTION_POINTS => CRLDistributionPointsExtension::class, |
|
| 116 | + self::OID_INHIBIT_ANY_POLICY => InhibitAnyPolicyExtension::class, |
|
| 117 | + self::OID_FRESHEST_CRL => FreshestCRLExtension::class, |
|
| 118 | + self::OID_NO_REV_AVAIL => NoRevocationAvailableExtension::class, |
|
| 119 | + self::OID_TARGET_INFORMATION => TargetInformationExtension::class, |
|
| 120 | + self::OID_AUTHORITY_INFORMATION_ACCESS => AuthorityInformationAccessExtension::class, |
|
| 121 | + self::OID_AA_CONTROLS => AAControlsExtension::class, |
|
| 122 | + self::OID_SUBJECT_INFORMATION_ACCESS => SubjectInformationAccessExtension::class, |
|
| 123 | + ]; |
|
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * Mapping from extensions ID to short name. |
|
| 127 | - * |
|
| 128 | - * @internal |
|
| 129 | - * |
|
| 130 | - * @var array |
|
| 131 | - */ |
|
| 132 | - const MAP_OID_TO_NAME = [ |
|
| 133 | - self::OID_AUTHORITY_KEY_IDENTIFIER => 'authorityKeyIdentifier', |
|
| 134 | - self::OID_SUBJECT_KEY_IDENTIFIER => 'subjectKeyIdentifier', |
|
| 135 | - self::OID_KEY_USAGE => 'keyUsage', |
|
| 136 | - self::OID_PRIVATE_KEY_USAGE_PERIOD => 'privateKeyUsagePeriod', |
|
| 137 | - self::OID_CERTIFICATE_POLICIES => 'certificatePolicies', |
|
| 138 | - self::OID_POLICY_MAPPINGS => 'policyMappings', |
|
| 139 | - self::OID_SUBJECT_ALT_NAME => 'subjectAltName', |
|
| 140 | - self::OID_ISSUER_ALT_NAME => 'issuerAltName', |
|
| 141 | - self::OID_SUBJECT_DIRECTORY_ATTRIBUTES => 'subjectDirectoryAttributes', |
|
| 142 | - self::OID_BASIC_CONSTRAINTS => 'basicConstraints', |
|
| 143 | - self::OID_NAME_CONSTRAINTS => 'nameConstraints', |
|
| 144 | - self::OID_POLICY_CONSTRAINTS => 'policyConstraints', |
|
| 145 | - self::OID_EXT_KEY_USAGE => 'extKeyUsage', |
|
| 146 | - self::OID_CRL_DISTRIBUTION_POINTS => 'cRLDistributionPoints', |
|
| 147 | - self::OID_INHIBIT_ANY_POLICY => 'inhibitAnyPolicy', |
|
| 148 | - self::OID_FRESHEST_CRL => 'freshestCRL', |
|
| 149 | - self::OID_NO_REV_AVAIL => 'noRevAvail', |
|
| 150 | - self::OID_TARGET_INFORMATION => 'targetInformation', |
|
| 151 | - self::OID_AUTHORITY_INFORMATION_ACCESS => 'authorityInfoAccess', |
|
| 152 | - self::OID_AA_CONTROLS => 'aaControls', |
|
| 153 | - self::OID_SUBJECT_INFORMATION_ACCESS => 'subjectInfoAccess', |
|
| 154 | - self::OID_LOGOTYPE => 'logotype', |
|
| 155 | - ]; |
|
| 125 | + /** |
|
| 126 | + * Mapping from extensions ID to short name. |
|
| 127 | + * |
|
| 128 | + * @internal |
|
| 129 | + * |
|
| 130 | + * @var array |
|
| 131 | + */ |
|
| 132 | + const MAP_OID_TO_NAME = [ |
|
| 133 | + self::OID_AUTHORITY_KEY_IDENTIFIER => 'authorityKeyIdentifier', |
|
| 134 | + self::OID_SUBJECT_KEY_IDENTIFIER => 'subjectKeyIdentifier', |
|
| 135 | + self::OID_KEY_USAGE => 'keyUsage', |
|
| 136 | + self::OID_PRIVATE_KEY_USAGE_PERIOD => 'privateKeyUsagePeriod', |
|
| 137 | + self::OID_CERTIFICATE_POLICIES => 'certificatePolicies', |
|
| 138 | + self::OID_POLICY_MAPPINGS => 'policyMappings', |
|
| 139 | + self::OID_SUBJECT_ALT_NAME => 'subjectAltName', |
|
| 140 | + self::OID_ISSUER_ALT_NAME => 'issuerAltName', |
|
| 141 | + self::OID_SUBJECT_DIRECTORY_ATTRIBUTES => 'subjectDirectoryAttributes', |
|
| 142 | + self::OID_BASIC_CONSTRAINTS => 'basicConstraints', |
|
| 143 | + self::OID_NAME_CONSTRAINTS => 'nameConstraints', |
|
| 144 | + self::OID_POLICY_CONSTRAINTS => 'policyConstraints', |
|
| 145 | + self::OID_EXT_KEY_USAGE => 'extKeyUsage', |
|
| 146 | + self::OID_CRL_DISTRIBUTION_POINTS => 'cRLDistributionPoints', |
|
| 147 | + self::OID_INHIBIT_ANY_POLICY => 'inhibitAnyPolicy', |
|
| 148 | + self::OID_FRESHEST_CRL => 'freshestCRL', |
|
| 149 | + self::OID_NO_REV_AVAIL => 'noRevAvail', |
|
| 150 | + self::OID_TARGET_INFORMATION => 'targetInformation', |
|
| 151 | + self::OID_AUTHORITY_INFORMATION_ACCESS => 'authorityInfoAccess', |
|
| 152 | + self::OID_AA_CONTROLS => 'aaControls', |
|
| 153 | + self::OID_SUBJECT_INFORMATION_ACCESS => 'subjectInfoAccess', |
|
| 154 | + self::OID_LOGOTYPE => 'logotype', |
|
| 155 | + ]; |
|
| 156 | 156 | |
| 157 | - /** |
|
| 158 | - * Extension's OID. |
|
| 159 | - * |
|
| 160 | - * @var string |
|
| 161 | - */ |
|
| 162 | - protected $_oid; |
|
| 157 | + /** |
|
| 158 | + * Extension's OID. |
|
| 159 | + * |
|
| 160 | + * @var string |
|
| 161 | + */ |
|
| 162 | + protected $_oid; |
|
| 163 | 163 | |
| 164 | - /** |
|
| 165 | - * Whether extension is critical. |
|
| 166 | - * |
|
| 167 | - * @var bool |
|
| 168 | - */ |
|
| 169 | - protected $_critical; |
|
| 164 | + /** |
|
| 165 | + * Whether extension is critical. |
|
| 166 | + * |
|
| 167 | + * @var bool |
|
| 168 | + */ |
|
| 169 | + protected $_critical; |
|
| 170 | 170 | |
| 171 | - /** |
|
| 172 | - * Constructor. |
|
| 173 | - * |
|
| 174 | - * @param string $oid Extension OID |
|
| 175 | - * @param bool $critical Whether extension is critical |
|
| 176 | - */ |
|
| 177 | - public function __construct(string $oid, bool $critical) |
|
| 178 | - { |
|
| 179 | - $this->_oid = $oid; |
|
| 180 | - $this->_critical = $critical; |
|
| 181 | - } |
|
| 171 | + /** |
|
| 172 | + * Constructor. |
|
| 173 | + * |
|
| 174 | + * @param string $oid Extension OID |
|
| 175 | + * @param bool $critical Whether extension is critical |
|
| 176 | + */ |
|
| 177 | + public function __construct(string $oid, bool $critical) |
|
| 178 | + { |
|
| 179 | + $this->_oid = $oid; |
|
| 180 | + $this->_critical = $critical; |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - /** |
|
| 184 | - * @return string |
|
| 185 | - */ |
|
| 186 | - public function __toString(): string |
|
| 187 | - { |
|
| 188 | - return $this->extensionName(); |
|
| 189 | - } |
|
| 183 | + /** |
|
| 184 | + * @return string |
|
| 185 | + */ |
|
| 186 | + public function __toString(): string |
|
| 187 | + { |
|
| 188 | + return $this->extensionName(); |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - /** |
|
| 192 | - * Initialize from ASN.1. |
|
| 193 | - * |
|
| 194 | - * @param Sequence $seq |
|
| 195 | - * |
|
| 196 | - * @return self |
|
| 197 | - */ |
|
| 198 | - public static function fromASN1(Sequence $seq): Extension |
|
| 199 | - { |
|
| 200 | - $idx = 0; |
|
| 201 | - $extnID = $seq->at($idx++)->asObjectIdentifier()->oid(); |
|
| 202 | - $critical = false; |
|
| 203 | - if ($seq->has($idx, Element::TYPE_BOOLEAN)) { |
|
| 204 | - $critical = $seq->at($idx++)->asBoolean()->value(); |
|
| 205 | - } |
|
| 206 | - $data = $seq->at($idx)->asOctetString()->string(); |
|
| 207 | - if (array_key_exists($extnID, self::MAP_OID_TO_CLASS)) { |
|
| 208 | - $cls = self::MAP_OID_TO_CLASS[$extnID]; |
|
| 209 | - return $cls::_fromDER($data, $critical); |
|
| 210 | - } |
|
| 211 | - return UnknownExtension::fromRawString($extnID, $critical, $data); |
|
| 212 | - } |
|
| 191 | + /** |
|
| 192 | + * Initialize from ASN.1. |
|
| 193 | + * |
|
| 194 | + * @param Sequence $seq |
|
| 195 | + * |
|
| 196 | + * @return self |
|
| 197 | + */ |
|
| 198 | + public static function fromASN1(Sequence $seq): Extension |
|
| 199 | + { |
|
| 200 | + $idx = 0; |
|
| 201 | + $extnID = $seq->at($idx++)->asObjectIdentifier()->oid(); |
|
| 202 | + $critical = false; |
|
| 203 | + if ($seq->has($idx, Element::TYPE_BOOLEAN)) { |
|
| 204 | + $critical = $seq->at($idx++)->asBoolean()->value(); |
|
| 205 | + } |
|
| 206 | + $data = $seq->at($idx)->asOctetString()->string(); |
|
| 207 | + if (array_key_exists($extnID, self::MAP_OID_TO_CLASS)) { |
|
| 208 | + $cls = self::MAP_OID_TO_CLASS[$extnID]; |
|
| 209 | + return $cls::_fromDER($data, $critical); |
|
| 210 | + } |
|
| 211 | + return UnknownExtension::fromRawString($extnID, $critical, $data); |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - /** |
|
| 215 | - * Get extension OID. |
|
| 216 | - * |
|
| 217 | - * @return string |
|
| 218 | - */ |
|
| 219 | - public function oid(): string |
|
| 220 | - { |
|
| 221 | - return $this->_oid; |
|
| 222 | - } |
|
| 214 | + /** |
|
| 215 | + * Get extension OID. |
|
| 216 | + * |
|
| 217 | + * @return string |
|
| 218 | + */ |
|
| 219 | + public function oid(): string |
|
| 220 | + { |
|
| 221 | + return $this->_oid; |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - /** |
|
| 225 | - * Check whether extension is critical. |
|
| 226 | - * |
|
| 227 | - * @return bool |
|
| 228 | - */ |
|
| 229 | - public function isCritical(): bool |
|
| 230 | - { |
|
| 231 | - return $this->_critical; |
|
| 232 | - } |
|
| 224 | + /** |
|
| 225 | + * Check whether extension is critical. |
|
| 226 | + * |
|
| 227 | + * @return bool |
|
| 228 | + */ |
|
| 229 | + public function isCritical(): bool |
|
| 230 | + { |
|
| 231 | + return $this->_critical; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - /** |
|
| 235 | - * Generate ASN.1 structure. |
|
| 236 | - * |
|
| 237 | - * @return Sequence |
|
| 238 | - */ |
|
| 239 | - public function toASN1(): Sequence |
|
| 240 | - { |
|
| 241 | - $elements = [new ObjectIdentifier($this->_oid)]; |
|
| 242 | - if ($this->_critical) { |
|
| 243 | - $elements[] = new Boolean(true); |
|
| 244 | - } |
|
| 245 | - $elements[] = $this->_extnValue(); |
|
| 246 | - return new Sequence(...$elements); |
|
| 247 | - } |
|
| 234 | + /** |
|
| 235 | + * Generate ASN.1 structure. |
|
| 236 | + * |
|
| 237 | + * @return Sequence |
|
| 238 | + */ |
|
| 239 | + public function toASN1(): Sequence |
|
| 240 | + { |
|
| 241 | + $elements = [new ObjectIdentifier($this->_oid)]; |
|
| 242 | + if ($this->_critical) { |
|
| 243 | + $elements[] = new Boolean(true); |
|
| 244 | + } |
|
| 245 | + $elements[] = $this->_extnValue(); |
|
| 246 | + return new Sequence(...$elements); |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - /** |
|
| 250 | - * Get short name of the extension. |
|
| 251 | - * |
|
| 252 | - * @return string |
|
| 253 | - */ |
|
| 254 | - public function extensionName(): string |
|
| 255 | - { |
|
| 256 | - if (array_key_exists($this->_oid, self::MAP_OID_TO_NAME)) { |
|
| 257 | - return self::MAP_OID_TO_NAME[$this->_oid]; |
|
| 258 | - } |
|
| 259 | - return $this->oid(); |
|
| 260 | - } |
|
| 249 | + /** |
|
| 250 | + * Get short name of the extension. |
|
| 251 | + * |
|
| 252 | + * @return string |
|
| 253 | + */ |
|
| 254 | + public function extensionName(): string |
|
| 255 | + { |
|
| 256 | + if (array_key_exists($this->_oid, self::MAP_OID_TO_NAME)) { |
|
| 257 | + return self::MAP_OID_TO_NAME[$this->_oid]; |
|
| 258 | + } |
|
| 259 | + return $this->oid(); |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - /** |
|
| 263 | - * Get ASN.1 structure of the extension value. |
|
| 264 | - * |
|
| 265 | - * @return Element |
|
| 266 | - */ |
|
| 267 | - abstract protected function _valueASN1(): Element; |
|
| 262 | + /** |
|
| 263 | + * Get ASN.1 structure of the extension value. |
|
| 264 | + * |
|
| 265 | + * @return Element |
|
| 266 | + */ |
|
| 267 | + abstract protected function _valueASN1(): Element; |
|
| 268 | 268 | |
| 269 | - /** |
|
| 270 | - * Parse extension value from DER. |
|
| 271 | - * |
|
| 272 | - * @param string $data DER data |
|
| 273 | - * @param bool $critical Whether extension is critical |
|
| 274 | - * |
|
| 275 | - * @throws \BadMethodCallException |
|
| 276 | - * |
|
| 277 | - * @return self |
|
| 278 | - */ |
|
| 279 | - protected static function _fromDER(string $data, bool $critical): Extension |
|
| 280 | - { |
|
| 281 | - throw new \BadMethodCallException( |
|
| 282 | - __FUNCTION__ . ' must be implemented in derived class.'); |
|
| 283 | - } |
|
| 269 | + /** |
|
| 270 | + * Parse extension value from DER. |
|
| 271 | + * |
|
| 272 | + * @param string $data DER data |
|
| 273 | + * @param bool $critical Whether extension is critical |
|
| 274 | + * |
|
| 275 | + * @throws \BadMethodCallException |
|
| 276 | + * |
|
| 277 | + * @return self |
|
| 278 | + */ |
|
| 279 | + protected static function _fromDER(string $data, bool $critical): Extension |
|
| 280 | + { |
|
| 281 | + throw new \BadMethodCallException( |
|
| 282 | + __FUNCTION__ . ' must be implemented in derived class.'); |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - /** |
|
| 286 | - * Get the extnValue element. |
|
| 287 | - * |
|
| 288 | - * @return OctetString |
|
| 289 | - */ |
|
| 290 | - protected function _extnValue(): OctetString |
|
| 291 | - { |
|
| 292 | - return new OctetString($this->_valueASN1()->toDER()); |
|
| 293 | - } |
|
| 285 | + /** |
|
| 286 | + * Get the extnValue element. |
|
| 287 | + * |
|
| 288 | + * @return OctetString |
|
| 289 | + */ |
|
| 290 | + protected function _extnValue(): OctetString |
|
| 291 | + { |
|
| 292 | + return new OctetString($this->_valueASN1()->toDER()); |
|
| 293 | + } |
|
| 294 | 294 | } |
@@ -16,89 +16,89 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class CRLDistributionPointsExtension extends Extension implements \Countable, \IteratorAggregate |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Distribution points. |
|
| 21 | - * |
|
| 22 | - * @var DistributionPoint[] |
|
| 23 | - */ |
|
| 24 | - protected $_distributionPoints; |
|
| 19 | + /** |
|
| 20 | + * Distribution points. |
|
| 21 | + * |
|
| 22 | + * @var DistributionPoint[] |
|
| 23 | + */ |
|
| 24 | + protected $_distributionPoints; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Constructor. |
|
| 28 | - * |
|
| 29 | - * @param bool $critical |
|
| 30 | - * @param DistributionPoint ...$distribution_points |
|
| 31 | - */ |
|
| 32 | - public function __construct(bool $critical, |
|
| 33 | - DistributionPoint ...$distribution_points) |
|
| 34 | - { |
|
| 35 | - parent::__construct(self::OID_CRL_DISTRIBUTION_POINTS, $critical); |
|
| 36 | - $this->_distributionPoints = $distribution_points; |
|
| 37 | - } |
|
| 26 | + /** |
|
| 27 | + * Constructor. |
|
| 28 | + * |
|
| 29 | + * @param bool $critical |
|
| 30 | + * @param DistributionPoint ...$distribution_points |
|
| 31 | + */ |
|
| 32 | + public function __construct(bool $critical, |
|
| 33 | + DistributionPoint ...$distribution_points) |
|
| 34 | + { |
|
| 35 | + parent::__construct(self::OID_CRL_DISTRIBUTION_POINTS, $critical); |
|
| 36 | + $this->_distributionPoints = $distribution_points; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Get distribution points. |
|
| 41 | - * |
|
| 42 | - * @return DistributionPoint[] |
|
| 43 | - */ |
|
| 44 | - public function distributionPoints(): array |
|
| 45 | - { |
|
| 46 | - return $this->_distributionPoints; |
|
| 47 | - } |
|
| 39 | + /** |
|
| 40 | + * Get distribution points. |
|
| 41 | + * |
|
| 42 | + * @return DistributionPoint[] |
|
| 43 | + */ |
|
| 44 | + public function distributionPoints(): array |
|
| 45 | + { |
|
| 46 | + return $this->_distributionPoints; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Get the number of distribution points. |
|
| 51 | - * |
|
| 52 | - * @see \Countable::count() |
|
| 53 | - * |
|
| 54 | - * @return int |
|
| 55 | - */ |
|
| 56 | - public function count(): int |
|
| 57 | - { |
|
| 58 | - return count($this->_distributionPoints); |
|
| 59 | - } |
|
| 49 | + /** |
|
| 50 | + * Get the number of distribution points. |
|
| 51 | + * |
|
| 52 | + * @see \Countable::count() |
|
| 53 | + * |
|
| 54 | + * @return int |
|
| 55 | + */ |
|
| 56 | + public function count(): int |
|
| 57 | + { |
|
| 58 | + return count($this->_distributionPoints); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Get iterator for distribution points. |
|
| 63 | - * |
|
| 64 | - * @see \IteratorAggregate::getIterator() |
|
| 65 | - * |
|
| 66 | - * @return \ArrayIterator |
|
| 67 | - */ |
|
| 68 | - public function getIterator(): \ArrayIterator |
|
| 69 | - { |
|
| 70 | - return new \ArrayIterator($this->_distributionPoints); |
|
| 71 | - } |
|
| 61 | + /** |
|
| 62 | + * Get iterator for distribution points. |
|
| 63 | + * |
|
| 64 | + * @see \IteratorAggregate::getIterator() |
|
| 65 | + * |
|
| 66 | + * @return \ArrayIterator |
|
| 67 | + */ |
|
| 68 | + public function getIterator(): \ArrayIterator |
|
| 69 | + { |
|
| 70 | + return new \ArrayIterator($this->_distributionPoints); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * {@inheritdoc} |
|
| 75 | - */ |
|
| 76 | - protected static function _fromDER(string $data, bool $critical): Extension |
|
| 77 | - { |
|
| 78 | - $dps = array_map( |
|
| 79 | - function (UnspecifiedType $el) { |
|
| 80 | - return DistributionPoint::fromASN1($el->asSequence()); |
|
| 81 | - }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
| 82 | - if (!count($dps)) { |
|
| 83 | - throw new \UnexpectedValueException( |
|
| 84 | - 'CRLDistributionPoints must have at least one DistributionPoint.'); |
|
| 85 | - } |
|
| 86 | - // late static bound, extended by Freshest CRL extension |
|
| 87 | - return new static($critical, ...$dps); |
|
| 88 | - } |
|
| 73 | + /** |
|
| 74 | + * {@inheritdoc} |
|
| 75 | + */ |
|
| 76 | + protected static function _fromDER(string $data, bool $critical): Extension |
|
| 77 | + { |
|
| 78 | + $dps = array_map( |
|
| 79 | + function (UnspecifiedType $el) { |
|
| 80 | + return DistributionPoint::fromASN1($el->asSequence()); |
|
| 81 | + }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
| 82 | + if (!count($dps)) { |
|
| 83 | + throw new \UnexpectedValueException( |
|
| 84 | + 'CRLDistributionPoints must have at least one DistributionPoint.'); |
|
| 85 | + } |
|
| 86 | + // late static bound, extended by Freshest CRL extension |
|
| 87 | + return new static($critical, ...$dps); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * {@inheritdoc} |
|
| 92 | - */ |
|
| 93 | - protected function _valueASN1(): Element |
|
| 94 | - { |
|
| 95 | - if (!count($this->_distributionPoints)) { |
|
| 96 | - throw new \LogicException('No distribution points.'); |
|
| 97 | - } |
|
| 98 | - $elements = array_map( |
|
| 99 | - function (DistributionPoint $dp) { |
|
| 100 | - return $dp->toASN1(); |
|
| 101 | - }, $this->_distributionPoints); |
|
| 102 | - return new Sequence(...$elements); |
|
| 103 | - } |
|
| 90 | + /** |
|
| 91 | + * {@inheritdoc} |
|
| 92 | + */ |
|
| 93 | + protected function _valueASN1(): Element |
|
| 94 | + { |
|
| 95 | + if (!count($this->_distributionPoints)) { |
|
| 96 | + throw new \LogicException('No distribution points.'); |
|
| 97 | + } |
|
| 98 | + $elements = array_map( |
|
| 99 | + function (DistributionPoint $dp) { |
|
| 100 | + return $dp->toASN1(); |
|
| 101 | + }, $this->_distributionPoints); |
|
| 102 | + return new Sequence(...$elements); |
|
| 103 | + } |
|
| 104 | 104 | } |
@@ -17,164 +17,164 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class PolicyMappingsExtension extends Extension implements \Countable, \IteratorAggregate |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Policy mappings. |
|
| 22 | - * |
|
| 23 | - * @var PolicyMapping[] |
|
| 24 | - */ |
|
| 25 | - protected $_mappings; |
|
| 20 | + /** |
|
| 21 | + * Policy mappings. |
|
| 22 | + * |
|
| 23 | + * @var PolicyMapping[] |
|
| 24 | + */ |
|
| 25 | + protected $_mappings; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Constructor. |
|
| 29 | - * |
|
| 30 | - * @param bool $critical |
|
| 31 | - * @param PolicyMapping ...$mappings One or more PolicyMapping objects |
|
| 32 | - */ |
|
| 33 | - public function __construct(bool $critical, PolicyMapping ...$mappings) |
|
| 34 | - { |
|
| 35 | - parent::__construct(self::OID_POLICY_MAPPINGS, $critical); |
|
| 36 | - $this->_mappings = $mappings; |
|
| 37 | - } |
|
| 27 | + /** |
|
| 28 | + * Constructor. |
|
| 29 | + * |
|
| 30 | + * @param bool $critical |
|
| 31 | + * @param PolicyMapping ...$mappings One or more PolicyMapping objects |
|
| 32 | + */ |
|
| 33 | + public function __construct(bool $critical, PolicyMapping ...$mappings) |
|
| 34 | + { |
|
| 35 | + parent::__construct(self::OID_POLICY_MAPPINGS, $critical); |
|
| 36 | + $this->_mappings = $mappings; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Get all mappings. |
|
| 41 | - * |
|
| 42 | - * @return PolicyMapping[] |
|
| 43 | - */ |
|
| 44 | - public function mappings(): array |
|
| 45 | - { |
|
| 46 | - return $this->_mappings; |
|
| 47 | - } |
|
| 39 | + /** |
|
| 40 | + * Get all mappings. |
|
| 41 | + * |
|
| 42 | + * @return PolicyMapping[] |
|
| 43 | + */ |
|
| 44 | + public function mappings(): array |
|
| 45 | + { |
|
| 46 | + return $this->_mappings; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Get mappings flattened into a single array of arrays of subject domains |
|
| 51 | - * keyed by issuer domain. |
|
| 52 | - * |
|
| 53 | - * Eg. if policy mappings contains multiple mappings with the same issuer |
|
| 54 | - * domain policy, their corresponding subject domain policies are placed |
|
| 55 | - * under the same key. |
|
| 56 | - * |
|
| 57 | - * @return (string[])[] |
|
| 58 | - */ |
|
| 59 | - public function flattenedMappings(): array |
|
| 60 | - { |
|
| 61 | - $mappings = []; |
|
| 62 | - foreach ($this->_mappings as $mapping) { |
|
| 63 | - $idp = $mapping->issuerDomainPolicy(); |
|
| 64 | - if (!isset($mappings[$idp])) { |
|
| 65 | - $mappings[$idp] = []; |
|
| 66 | - } |
|
| 67 | - array_push($mappings[$idp], $mapping->subjectDomainPolicy()); |
|
| 68 | - } |
|
| 69 | - return $mappings; |
|
| 70 | - } |
|
| 49 | + /** |
|
| 50 | + * Get mappings flattened into a single array of arrays of subject domains |
|
| 51 | + * keyed by issuer domain. |
|
| 52 | + * |
|
| 53 | + * Eg. if policy mappings contains multiple mappings with the same issuer |
|
| 54 | + * domain policy, their corresponding subject domain policies are placed |
|
| 55 | + * under the same key. |
|
| 56 | + * |
|
| 57 | + * @return (string[])[] |
|
| 58 | + */ |
|
| 59 | + public function flattenedMappings(): array |
|
| 60 | + { |
|
| 61 | + $mappings = []; |
|
| 62 | + foreach ($this->_mappings as $mapping) { |
|
| 63 | + $idp = $mapping->issuerDomainPolicy(); |
|
| 64 | + if (!isset($mappings[$idp])) { |
|
| 65 | + $mappings[$idp] = []; |
|
| 66 | + } |
|
| 67 | + array_push($mappings[$idp], $mapping->subjectDomainPolicy()); |
|
| 68 | + } |
|
| 69 | + return $mappings; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Get all subject domain policy OIDs that are mapped to given issuer |
|
| 74 | - * domain policy OID. |
|
| 75 | - * |
|
| 76 | - * @param string $oid Issuer domain policy |
|
| 77 | - * |
|
| 78 | - * @return string[] List of OIDs in dotted format |
|
| 79 | - */ |
|
| 80 | - public function issuerMappings(string $oid): array |
|
| 81 | - { |
|
| 82 | - $oids = []; |
|
| 83 | - foreach ($this->_mappings as $mapping) { |
|
| 84 | - if ($mapping->issuerDomainPolicy() == $oid) { |
|
| 85 | - $oids[] = $mapping->subjectDomainPolicy(); |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - return $oids; |
|
| 89 | - } |
|
| 72 | + /** |
|
| 73 | + * Get all subject domain policy OIDs that are mapped to given issuer |
|
| 74 | + * domain policy OID. |
|
| 75 | + * |
|
| 76 | + * @param string $oid Issuer domain policy |
|
| 77 | + * |
|
| 78 | + * @return string[] List of OIDs in dotted format |
|
| 79 | + */ |
|
| 80 | + public function issuerMappings(string $oid): array |
|
| 81 | + { |
|
| 82 | + $oids = []; |
|
| 83 | + foreach ($this->_mappings as $mapping) { |
|
| 84 | + if ($mapping->issuerDomainPolicy() == $oid) { |
|
| 85 | + $oids[] = $mapping->subjectDomainPolicy(); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + return $oids; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Get all mapped issuer domain policy OIDs. |
|
| 93 | - * |
|
| 94 | - * @return string[] |
|
| 95 | - */ |
|
| 96 | - public function issuerDomainPolicies(): array |
|
| 97 | - { |
|
| 98 | - $idps = array_map( |
|
| 99 | - function (PolicyMapping $mapping) { |
|
| 100 | - return $mapping->issuerDomainPolicy(); |
|
| 101 | - }, $this->_mappings); |
|
| 102 | - return array_values(array_unique($idps)); |
|
| 103 | - } |
|
| 91 | + /** |
|
| 92 | + * Get all mapped issuer domain policy OIDs. |
|
| 93 | + * |
|
| 94 | + * @return string[] |
|
| 95 | + */ |
|
| 96 | + public function issuerDomainPolicies(): array |
|
| 97 | + { |
|
| 98 | + $idps = array_map( |
|
| 99 | + function (PolicyMapping $mapping) { |
|
| 100 | + return $mapping->issuerDomainPolicy(); |
|
| 101 | + }, $this->_mappings); |
|
| 102 | + return array_values(array_unique($idps)); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Check whether policy mappings have anyPolicy mapped. |
|
| 107 | - * |
|
| 108 | - * RFC 5280 section 4.2.1.5 states that "Policies MUST NOT be mapped either |
|
| 109 | - * to or from the special value anyPolicy". |
|
| 110 | - * |
|
| 111 | - * @return bool |
|
| 112 | - */ |
|
| 113 | - public function hasAnyPolicyMapping(): bool |
|
| 114 | - { |
|
| 115 | - foreach ($this->_mappings as $mapping) { |
|
| 116 | - if (PolicyInformation::OID_ANY_POLICY === $mapping->issuerDomainPolicy()) { |
|
| 117 | - return true; |
|
| 118 | - } |
|
| 119 | - if (PolicyInformation::OID_ANY_POLICY === $mapping->subjectDomainPolicy()) { |
|
| 120 | - return true; |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - return false; |
|
| 124 | - } |
|
| 105 | + /** |
|
| 106 | + * Check whether policy mappings have anyPolicy mapped. |
|
| 107 | + * |
|
| 108 | + * RFC 5280 section 4.2.1.5 states that "Policies MUST NOT be mapped either |
|
| 109 | + * to or from the special value anyPolicy". |
|
| 110 | + * |
|
| 111 | + * @return bool |
|
| 112 | + */ |
|
| 113 | + public function hasAnyPolicyMapping(): bool |
|
| 114 | + { |
|
| 115 | + foreach ($this->_mappings as $mapping) { |
|
| 116 | + if (PolicyInformation::OID_ANY_POLICY === $mapping->issuerDomainPolicy()) { |
|
| 117 | + return true; |
|
| 118 | + } |
|
| 119 | + if (PolicyInformation::OID_ANY_POLICY === $mapping->subjectDomainPolicy()) { |
|
| 120 | + return true; |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + return false; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Get the number of mappings. |
|
| 128 | - * |
|
| 129 | - * @see \Countable::count() |
|
| 130 | - * |
|
| 131 | - * @return int |
|
| 132 | - */ |
|
| 133 | - public function count(): int |
|
| 134 | - { |
|
| 135 | - return count($this->_mappings); |
|
| 136 | - } |
|
| 126 | + /** |
|
| 127 | + * Get the number of mappings. |
|
| 128 | + * |
|
| 129 | + * @see \Countable::count() |
|
| 130 | + * |
|
| 131 | + * @return int |
|
| 132 | + */ |
|
| 133 | + public function count(): int |
|
| 134 | + { |
|
| 135 | + return count($this->_mappings); |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - /** |
|
| 139 | - * Get iterator for policy mappings. |
|
| 140 | - * |
|
| 141 | - * @see \IteratorAggregate::getIterator() |
|
| 142 | - * |
|
| 143 | - * @return \ArrayIterator |
|
| 144 | - */ |
|
| 145 | - public function getIterator(): \ArrayIterator |
|
| 146 | - { |
|
| 147 | - return new \ArrayIterator($this->_mappings); |
|
| 148 | - } |
|
| 138 | + /** |
|
| 139 | + * Get iterator for policy mappings. |
|
| 140 | + * |
|
| 141 | + * @see \IteratorAggregate::getIterator() |
|
| 142 | + * |
|
| 143 | + * @return \ArrayIterator |
|
| 144 | + */ |
|
| 145 | + public function getIterator(): \ArrayIterator |
|
| 146 | + { |
|
| 147 | + return new \ArrayIterator($this->_mappings); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * {@inheritdoc} |
|
| 152 | - */ |
|
| 153 | - protected static function _fromDER(string $data, bool $critical): Extension |
|
| 154 | - { |
|
| 155 | - $mappings = array_map( |
|
| 156 | - function (UnspecifiedType $el) { |
|
| 157 | - return PolicyMapping::fromASN1($el->asSequence()); |
|
| 158 | - }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
| 159 | - if (!count($mappings)) { |
|
| 160 | - throw new \UnexpectedValueException( |
|
| 161 | - 'PolicyMappings must have at least one mapping.'); |
|
| 162 | - } |
|
| 163 | - return new self($critical, ...$mappings); |
|
| 164 | - } |
|
| 150 | + /** |
|
| 151 | + * {@inheritdoc} |
|
| 152 | + */ |
|
| 153 | + protected static function _fromDER(string $data, bool $critical): Extension |
|
| 154 | + { |
|
| 155 | + $mappings = array_map( |
|
| 156 | + function (UnspecifiedType $el) { |
|
| 157 | + return PolicyMapping::fromASN1($el->asSequence()); |
|
| 158 | + }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
| 159 | + if (!count($mappings)) { |
|
| 160 | + throw new \UnexpectedValueException( |
|
| 161 | + 'PolicyMappings must have at least one mapping.'); |
|
| 162 | + } |
|
| 163 | + return new self($critical, ...$mappings); |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - /** |
|
| 167 | - * {@inheritdoc} |
|
| 168 | - */ |
|
| 169 | - protected function _valueASN1(): Element |
|
| 170 | - { |
|
| 171 | - if (!count($this->_mappings)) { |
|
| 172 | - throw new \LogicException('No mappings.'); |
|
| 173 | - } |
|
| 174 | - $elements = array_map( |
|
| 175 | - function (PolicyMapping $mapping) { |
|
| 176 | - return $mapping->toASN1(); |
|
| 177 | - }, $this->_mappings); |
|
| 178 | - return new Sequence(...$elements); |
|
| 179 | - } |
|
| 166 | + /** |
|
| 167 | + * {@inheritdoc} |
|
| 168 | + */ |
|
| 169 | + protected function _valueASN1(): Element |
|
| 170 | + { |
|
| 171 | + if (!count($this->_mappings)) { |
|
| 172 | + throw new \LogicException('No mappings.'); |
|
| 173 | + } |
|
| 174 | + $elements = array_map( |
|
| 175 | + function (PolicyMapping $mapping) { |
|
| 176 | + return $mapping->toASN1(); |
|
| 177 | + }, $this->_mappings); |
|
| 178 | + return new Sequence(...$elements); |
|
| 179 | + } |
|
| 180 | 180 | } |
@@ -15,49 +15,49 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class SubjectKeyIdentifierExtension extends Extension |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * Key identifier. |
|
| 20 | - * |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - protected $_keyIdentifier; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Constructor. |
|
| 27 | - * |
|
| 28 | - * @param bool $critical |
|
| 29 | - * @param string $keyIdentifier |
|
| 30 | - */ |
|
| 31 | - public function __construct(bool $critical, string $keyIdentifier) |
|
| 32 | - { |
|
| 33 | - parent::__construct(self::OID_SUBJECT_KEY_IDENTIFIER, $critical); |
|
| 34 | - $this->_keyIdentifier = $keyIdentifier; |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Get key identifier. |
|
| 39 | - * |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - public function keyIdentifier(): string |
|
| 43 | - { |
|
| 44 | - return $this->_keyIdentifier; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * {@inheritdoc} |
|
| 49 | - */ |
|
| 50 | - protected static function _fromDER(string $data, bool $critical): Extension |
|
| 51 | - { |
|
| 52 | - return new self($critical, |
|
| 53 | - UnspecifiedType::fromDER($data)->asOctetString()->string()); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * {@inheritdoc} |
|
| 58 | - */ |
|
| 59 | - protected function _valueASN1(): Element |
|
| 60 | - { |
|
| 61 | - return new OctetString($this->_keyIdentifier); |
|
| 62 | - } |
|
| 18 | + /** |
|
| 19 | + * Key identifier. |
|
| 20 | + * |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + protected $_keyIdentifier; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Constructor. |
|
| 27 | + * |
|
| 28 | + * @param bool $critical |
|
| 29 | + * @param string $keyIdentifier |
|
| 30 | + */ |
|
| 31 | + public function __construct(bool $critical, string $keyIdentifier) |
|
| 32 | + { |
|
| 33 | + parent::__construct(self::OID_SUBJECT_KEY_IDENTIFIER, $critical); |
|
| 34 | + $this->_keyIdentifier = $keyIdentifier; |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Get key identifier. |
|
| 39 | + * |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + public function keyIdentifier(): string |
|
| 43 | + { |
|
| 44 | + return $this->_keyIdentifier; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * {@inheritdoc} |
|
| 49 | + */ |
|
| 50 | + protected static function _fromDER(string $data, bool $critical): Extension |
|
| 51 | + { |
|
| 52 | + return new self($critical, |
|
| 53 | + UnspecifiedType::fromDER($data)->asOctetString()->string()); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * {@inheritdoc} |
|
| 58 | + */ |
|
| 59 | + protected function _valueASN1(): Element |
|
| 60 | + { |
|
| 61 | + return new OctetString($this->_keyIdentifier); |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -15,74 +15,74 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class PolicyMapping |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * OID of the issuer policy. |
|
| 20 | - * |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - protected $_issuerDomainPolicy; |
|
| 18 | + /** |
|
| 19 | + * OID of the issuer policy. |
|
| 20 | + * |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + protected $_issuerDomainPolicy; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * OID of the subject policy. |
|
| 27 | - * |
|
| 28 | - * @var string |
|
| 29 | - */ |
|
| 30 | - protected $_subjectDomainPolicy; |
|
| 25 | + /** |
|
| 26 | + * OID of the subject policy. |
|
| 27 | + * |
|
| 28 | + * @var string |
|
| 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(string $issuer_policy, string $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(string $issuer_policy, string $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 | - * |
|
| 49 | - * @return self |
|
| 50 | - */ |
|
| 51 | - public static function fromASN1(Sequence $seq): self |
|
| 52 | - { |
|
| 53 | - $issuer_policy = $seq->at(0)->asObjectIdentifier()->oid(); |
|
| 54 | - $subject_policy = $seq->at(1)->asObjectIdentifier()->oid(); |
|
| 55 | - return new self($issuer_policy, $subject_policy); |
|
| 56 | - } |
|
| 44 | + /** |
|
| 45 | + * Initialize from ASN.1. |
|
| 46 | + * |
|
| 47 | + * @param Sequence $seq |
|
| 48 | + * |
|
| 49 | + * @return self |
|
| 50 | + */ |
|
| 51 | + public static function fromASN1(Sequence $seq): self |
|
| 52 | + { |
|
| 53 | + $issuer_policy = $seq->at(0)->asObjectIdentifier()->oid(); |
|
| 54 | + $subject_policy = $seq->at(1)->asObjectIdentifier()->oid(); |
|
| 55 | + return new self($issuer_policy, $subject_policy); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Get issuer domain policy. |
|
| 60 | - * |
|
| 61 | - * @return string OID in dotted format |
|
| 62 | - */ |
|
| 63 | - public function issuerDomainPolicy(): string |
|
| 64 | - { |
|
| 65 | - return $this->_issuerDomainPolicy; |
|
| 66 | - } |
|
| 58 | + /** |
|
| 59 | + * Get issuer domain policy. |
|
| 60 | + * |
|
| 61 | + * @return string OID in dotted format |
|
| 62 | + */ |
|
| 63 | + public function issuerDomainPolicy(): string |
|
| 64 | + { |
|
| 65 | + return $this->_issuerDomainPolicy; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Get subject domain policy. |
|
| 70 | - * |
|
| 71 | - * @return string OID in dotted format |
|
| 72 | - */ |
|
| 73 | - public function subjectDomainPolicy(): string |
|
| 74 | - { |
|
| 75 | - return $this->_subjectDomainPolicy; |
|
| 76 | - } |
|
| 68 | + /** |
|
| 69 | + * Get subject domain policy. |
|
| 70 | + * |
|
| 71 | + * @return string OID in dotted format |
|
| 72 | + */ |
|
| 73 | + public function subjectDomainPolicy(): string |
|
| 74 | + { |
|
| 75 | + return $this->_subjectDomainPolicy; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Generate ASN.1 structure. |
|
| 80 | - * |
|
| 81 | - * @return Sequence |
|
| 82 | - */ |
|
| 83 | - public function toASN1(): Sequence |
|
| 84 | - { |
|
| 85 | - return new Sequence(new ObjectIdentifier($this->_issuerDomainPolicy), |
|
| 86 | - new ObjectIdentifier($this->_subjectDomainPolicy)); |
|
| 87 | - } |
|
| 78 | + /** |
|
| 79 | + * Generate ASN.1 structure. |
|
| 80 | + * |
|
| 81 | + * @return Sequence |
|
| 82 | + */ |
|
| 83 | + public function toASN1(): Sequence |
|
| 84 | + { |
|
| 85 | + return new Sequence(new ObjectIdentifier($this->_issuerDomainPolicy), |
|
| 86 | + new ObjectIdentifier($this->_subjectDomainPolicy)); |
|
| 87 | + } |
|
| 88 | 88 | } |