@@ -16,58 +16,58 @@ |
||
16 | 16 | */ |
17 | 17 | class RegisteredID extends GeneralName |
18 | 18 | { |
19 | - /** |
|
20 | - * Object identifier. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $_oid; |
|
19 | + /** |
|
20 | + * Object identifier. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $_oid; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Constructor. |
|
28 | - * |
|
29 | - * @param string $oid OID in dotted format |
|
30 | - */ |
|
31 | - public function __construct(string $oid) |
|
32 | - { |
|
33 | - $this->_tag = self::TAG_REGISTERED_ID; |
|
34 | - $this->_oid = $oid; |
|
35 | - } |
|
26 | + /** |
|
27 | + * Constructor. |
|
28 | + * |
|
29 | + * @param string $oid OID in dotted format |
|
30 | + */ |
|
31 | + public function __construct(string $oid) |
|
32 | + { |
|
33 | + $this->_tag = self::TAG_REGISTERED_ID; |
|
34 | + $this->_oid = $oid; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * {@inheritdoc} |
|
39 | - * |
|
40 | - * @return self |
|
41 | - */ |
|
42 | - public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
43 | - { |
|
44 | - return new self($el->asObjectIdentifier()->oid()); |
|
45 | - } |
|
37 | + /** |
|
38 | + * {@inheritdoc} |
|
39 | + * |
|
40 | + * @return self |
|
41 | + */ |
|
42 | + public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
43 | + { |
|
44 | + return new self($el->asObjectIdentifier()->oid()); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * {@inheritdoc} |
|
49 | - */ |
|
50 | - public function string(): string |
|
51 | - { |
|
52 | - return $this->_oid; |
|
53 | - } |
|
47 | + /** |
|
48 | + * {@inheritdoc} |
|
49 | + */ |
|
50 | + public function string(): string |
|
51 | + { |
|
52 | + return $this->_oid; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Get object identifier in dotted format. |
|
57 | - * |
|
58 | - * @return string OID |
|
59 | - */ |
|
60 | - public function oid(): string |
|
61 | - { |
|
62 | - return $this->_oid; |
|
63 | - } |
|
55 | + /** |
|
56 | + * Get object identifier in dotted format. |
|
57 | + * |
|
58 | + * @return string OID |
|
59 | + */ |
|
60 | + public function oid(): string |
|
61 | + { |
|
62 | + return $this->_oid; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * {@inheritdoc} |
|
67 | - */ |
|
68 | - protected function _choiceASN1(): TaggedType |
|
69 | - { |
|
70 | - return new ImplicitlyTaggedType($this->_tag, |
|
71 | - new ObjectIdentifier($this->_oid)); |
|
72 | - } |
|
65 | + /** |
|
66 | + * {@inheritdoc} |
|
67 | + */ |
|
68 | + protected function _choiceASN1(): TaggedType |
|
69 | + { |
|
70 | + return new ImplicitlyTaggedType($this->_tag, |
|
71 | + new ObjectIdentifier($this->_oid)); |
|
72 | + } |
|
73 | 73 | } |
@@ -19,81 +19,81 @@ |
||
19 | 19 | */ |
20 | 20 | class OtherName extends GeneralName |
21 | 21 | { |
22 | - /** |
|
23 | - * Type OID. |
|
24 | - * |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - protected $_type; |
|
22 | + /** |
|
23 | + * Type OID. |
|
24 | + * |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + protected $_type; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Value. |
|
31 | - * |
|
32 | - * @var Element |
|
33 | - */ |
|
34 | - protected $_element; |
|
29 | + /** |
|
30 | + * Value. |
|
31 | + * |
|
32 | + * @var Element |
|
33 | + */ |
|
34 | + protected $_element; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Constructor. |
|
38 | - * |
|
39 | - * @param string $type_id OID |
|
40 | - * @param Element $el |
|
41 | - */ |
|
42 | - public function __construct(string $type_id, Element $el) |
|
43 | - { |
|
44 | - $this->_tag = self::TAG_OTHER_NAME; |
|
45 | - $this->_type = $type_id; |
|
46 | - $this->_element = $el; |
|
47 | - } |
|
36 | + /** |
|
37 | + * Constructor. |
|
38 | + * |
|
39 | + * @param string $type_id OID |
|
40 | + * @param Element $el |
|
41 | + */ |
|
42 | + public function __construct(string $type_id, Element $el) |
|
43 | + { |
|
44 | + $this->_tag = self::TAG_OTHER_NAME; |
|
45 | + $this->_type = $type_id; |
|
46 | + $this->_element = $el; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * {@inheritdoc} |
|
51 | - * |
|
52 | - * @return self |
|
53 | - */ |
|
54 | - public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
55 | - { |
|
56 | - $seq = $el->asSequence(); |
|
57 | - $type_id = $seq->at(0)->asObjectIdentifier()->oid(); |
|
58 | - $value = $seq->getTagged(0)->asExplicit()->asElement(); |
|
59 | - return new self($type_id, $value); |
|
60 | - } |
|
49 | + /** |
|
50 | + * {@inheritdoc} |
|
51 | + * |
|
52 | + * @return self |
|
53 | + */ |
|
54 | + public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
55 | + { |
|
56 | + $seq = $el->asSequence(); |
|
57 | + $type_id = $seq->at(0)->asObjectIdentifier()->oid(); |
|
58 | + $value = $seq->getTagged(0)->asExplicit()->asElement(); |
|
59 | + return new self($type_id, $value); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * {@inheritdoc} |
|
64 | - */ |
|
65 | - public function string(): string |
|
66 | - { |
|
67 | - return $this->_type . '/#' . bin2hex($this->_element->toDER()); |
|
68 | - } |
|
62 | + /** |
|
63 | + * {@inheritdoc} |
|
64 | + */ |
|
65 | + public function string(): string |
|
66 | + { |
|
67 | + return $this->_type . '/#' . bin2hex($this->_element->toDER()); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Get type OID. |
|
72 | - * |
|
73 | - * @return string |
|
74 | - */ |
|
75 | - public function type(): string |
|
76 | - { |
|
77 | - return $this->_type; |
|
78 | - } |
|
70 | + /** |
|
71 | + * Get type OID. |
|
72 | + * |
|
73 | + * @return string |
|
74 | + */ |
|
75 | + public function type(): string |
|
76 | + { |
|
77 | + return $this->_type; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Get value element. |
|
82 | - * |
|
83 | - * @return Element |
|
84 | - */ |
|
85 | - public function value(): Element |
|
86 | - { |
|
87 | - return $this->_element; |
|
88 | - } |
|
80 | + /** |
|
81 | + * Get value element. |
|
82 | + * |
|
83 | + * @return Element |
|
84 | + */ |
|
85 | + public function value(): Element |
|
86 | + { |
|
87 | + return $this->_element; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * {@inheritdoc} |
|
92 | - */ |
|
93 | - protected function _choiceASN1(): TaggedType |
|
94 | - { |
|
95 | - return new ImplicitlyTaggedType($this->_tag, |
|
96 | - new Sequence(new ObjectIdentifier($this->_type), |
|
97 | - new ExplicitlyTaggedType(0, $this->_element))); |
|
98 | - } |
|
90 | + /** |
|
91 | + * {@inheritdoc} |
|
92 | + */ |
|
93 | + protected function _choiceASN1(): TaggedType |
|
94 | + { |
|
95 | + return new ImplicitlyTaggedType($this->_tag, |
|
96 | + new Sequence(new ObjectIdentifier($this->_type), |
|
97 | + new ExplicitlyTaggedType(0, $this->_element))); |
|
98 | + } |
|
99 | 99 | } |
@@ -17,57 +17,57 @@ |
||
17 | 17 | */ |
18 | 18 | class UniformResourceIdentifier extends GeneralName |
19 | 19 | { |
20 | - /** |
|
21 | - * URI. |
|
22 | - * |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - protected $_uri; |
|
20 | + /** |
|
21 | + * URI. |
|
22 | + * |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + protected $_uri; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Constructor. |
|
29 | - * |
|
30 | - * @param string $uri |
|
31 | - */ |
|
32 | - public function __construct(string $uri) |
|
33 | - { |
|
34 | - $this->_tag = self::TAG_URI; |
|
35 | - $this->_uri = $uri; |
|
36 | - } |
|
27 | + /** |
|
28 | + * Constructor. |
|
29 | + * |
|
30 | + * @param string $uri |
|
31 | + */ |
|
32 | + public function __construct(string $uri) |
|
33 | + { |
|
34 | + $this->_tag = self::TAG_URI; |
|
35 | + $this->_uri = $uri; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * {@inheritdoc} |
|
40 | - * |
|
41 | - * @return self |
|
42 | - */ |
|
43 | - public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
44 | - { |
|
45 | - return new self($el->asIA5String()->string()); |
|
46 | - } |
|
38 | + /** |
|
39 | + * {@inheritdoc} |
|
40 | + * |
|
41 | + * @return self |
|
42 | + */ |
|
43 | + public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
44 | + { |
|
45 | + return new self($el->asIA5String()->string()); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * {@inheritdoc} |
|
50 | - */ |
|
51 | - public function string(): string |
|
52 | - { |
|
53 | - return $this->_uri; |
|
54 | - } |
|
48 | + /** |
|
49 | + * {@inheritdoc} |
|
50 | + */ |
|
51 | + public function string(): string |
|
52 | + { |
|
53 | + return $this->_uri; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Get URI. |
|
58 | - * |
|
59 | - * @return string |
|
60 | - */ |
|
61 | - public function uri(): string |
|
62 | - { |
|
63 | - return $this->_uri; |
|
64 | - } |
|
56 | + /** |
|
57 | + * Get URI. |
|
58 | + * |
|
59 | + * @return string |
|
60 | + */ |
|
61 | + public function uri(): string |
|
62 | + { |
|
63 | + return $this->_uri; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * {@inheritdoc} |
|
68 | - */ |
|
69 | - protected function _choiceASN1(): TaggedType |
|
70 | - { |
|
71 | - return new ImplicitlyTaggedType($this->_tag, new IA5String($this->_uri)); |
|
72 | - } |
|
66 | + /** |
|
67 | + * {@inheritdoc} |
|
68 | + */ |
|
69 | + protected function _choiceASN1(): TaggedType |
|
70 | + { |
|
71 | + return new ImplicitlyTaggedType($this->_tag, new IA5String($this->_uri)); |
|
72 | + } |
|
73 | 73 | } |
@@ -15,151 +15,151 @@ |
||
15 | 15 | */ |
16 | 16 | abstract class GeneralName |
17 | 17 | { |
18 | - // GeneralName CHOICE tags |
|
19 | - const TAG_OTHER_NAME = 0; |
|
20 | - const TAG_RFC822_NAME = 1; |
|
21 | - const TAG_DNS_NAME = 2; |
|
22 | - const TAG_X400_ADDRESS = 3; |
|
23 | - const TAG_DIRECTORY_NAME = 4; |
|
24 | - const TAG_EDI_PARTY_NAME = 5; |
|
25 | - const TAG_URI = 6; |
|
26 | - const TAG_IP_ADDRESS = 7; |
|
27 | - const TAG_REGISTERED_ID = 8; |
|
18 | + // GeneralName CHOICE tags |
|
19 | + const TAG_OTHER_NAME = 0; |
|
20 | + const TAG_RFC822_NAME = 1; |
|
21 | + const TAG_DNS_NAME = 2; |
|
22 | + const TAG_X400_ADDRESS = 3; |
|
23 | + const TAG_DIRECTORY_NAME = 4; |
|
24 | + const TAG_EDI_PARTY_NAME = 5; |
|
25 | + const TAG_URI = 6; |
|
26 | + const TAG_IP_ADDRESS = 7; |
|
27 | + const TAG_REGISTERED_ID = 8; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Chosen tag. |
|
31 | - * |
|
32 | - * @var int |
|
33 | - */ |
|
34 | - protected $_tag; |
|
29 | + /** |
|
30 | + * Chosen tag. |
|
31 | + * |
|
32 | + * @var int |
|
33 | + */ |
|
34 | + protected $_tag; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Get general name as a string. |
|
38 | - * |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function __toString(): string |
|
42 | - { |
|
43 | - return $this->string(); |
|
44 | - } |
|
36 | + /** |
|
37 | + * Get general name as a string. |
|
38 | + * |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function __toString(): string |
|
42 | + { |
|
43 | + return $this->string(); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Get string value of the type. |
|
48 | - * |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - abstract public function string(): string; |
|
46 | + /** |
|
47 | + * Get string value of the type. |
|
48 | + * |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + abstract public function string(): string; |
|
52 | 52 | |
53 | - /** |
|
54 | - * Initialize concrete object from the chosen ASN.1 element. |
|
55 | - * |
|
56 | - * @param UnspecifiedType $el |
|
57 | - * |
|
58 | - * @return self |
|
59 | - */ |
|
60 | - public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
61 | - { |
|
62 | - throw new \BadMethodCallException( |
|
63 | - __FUNCTION__ . ' must be implemented in the derived class.'); |
|
64 | - } |
|
53 | + /** |
|
54 | + * Initialize concrete object from the chosen ASN.1 element. |
|
55 | + * |
|
56 | + * @param UnspecifiedType $el |
|
57 | + * |
|
58 | + * @return self |
|
59 | + */ |
|
60 | + public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
61 | + { |
|
62 | + throw new \BadMethodCallException( |
|
63 | + __FUNCTION__ . ' must be implemented in the derived class.'); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Initialize from ASN.1. |
|
68 | - * |
|
69 | - * @param TaggedType $el |
|
70 | - * |
|
71 | - * @throws \UnexpectedValueException |
|
72 | - * |
|
73 | - * @return self |
|
74 | - */ |
|
75 | - public static function fromASN1(TaggedType $el): self |
|
76 | - { |
|
77 | - switch ($el->tag()) { |
|
78 | - // otherName |
|
79 | - case self::TAG_OTHER_NAME: |
|
80 | - return OtherName::fromChosenASN1( |
|
81 | - $el->asImplicit(Element::TYPE_SEQUENCE)); |
|
82 | - // rfc822Name |
|
83 | - case self::TAG_RFC822_NAME: |
|
84 | - return RFC822Name::fromChosenASN1( |
|
85 | - $el->asImplicit(Element::TYPE_IA5_STRING)); |
|
86 | - // dNSName |
|
87 | - case self::TAG_DNS_NAME: |
|
88 | - return DNSName::fromChosenASN1( |
|
89 | - $el->asImplicit(Element::TYPE_IA5_STRING)); |
|
90 | - // x400Address |
|
91 | - case self::TAG_X400_ADDRESS: |
|
92 | - return X400Address::fromChosenASN1( |
|
93 | - $el->asImplicit(Element::TYPE_SEQUENCE)); |
|
94 | - // directoryName |
|
95 | - case self::TAG_DIRECTORY_NAME: |
|
96 | - // because Name is a CHOICE, albeit having only one option, |
|
97 | - // explicit tagging must be used |
|
98 | - // (see X.680 07/2002 30.6.c) |
|
99 | - return DirectoryName::fromChosenASN1($el->asExplicit()); |
|
100 | - // ediPartyName |
|
101 | - case self::TAG_EDI_PARTY_NAME: |
|
102 | - return EDIPartyName::fromChosenASN1( |
|
103 | - $el->asImplicit(Element::TYPE_SEQUENCE)); |
|
104 | - // uniformResourceIdentifier |
|
105 | - case self::TAG_URI: |
|
106 | - return UniformResourceIdentifier::fromChosenASN1( |
|
107 | - $el->asImplicit(Element::TYPE_IA5_STRING)); |
|
108 | - // iPAddress |
|
109 | - case self::TAG_IP_ADDRESS: |
|
110 | - return IPAddress::fromChosenASN1( |
|
111 | - $el->asImplicit(Element::TYPE_OCTET_STRING)); |
|
112 | - // registeredID |
|
113 | - case self::TAG_REGISTERED_ID: |
|
114 | - return RegisteredID::fromChosenASN1( |
|
115 | - $el->asImplicit(Element::TYPE_OBJECT_IDENTIFIER)); |
|
116 | - } |
|
117 | - throw new \UnexpectedValueException( |
|
118 | - 'GeneralName type ' . $el->tag() . ' not supported.'); |
|
119 | - } |
|
66 | + /** |
|
67 | + * Initialize from ASN.1. |
|
68 | + * |
|
69 | + * @param TaggedType $el |
|
70 | + * |
|
71 | + * @throws \UnexpectedValueException |
|
72 | + * |
|
73 | + * @return self |
|
74 | + */ |
|
75 | + public static function fromASN1(TaggedType $el): self |
|
76 | + { |
|
77 | + switch ($el->tag()) { |
|
78 | + // otherName |
|
79 | + case self::TAG_OTHER_NAME: |
|
80 | + return OtherName::fromChosenASN1( |
|
81 | + $el->asImplicit(Element::TYPE_SEQUENCE)); |
|
82 | + // rfc822Name |
|
83 | + case self::TAG_RFC822_NAME: |
|
84 | + return RFC822Name::fromChosenASN1( |
|
85 | + $el->asImplicit(Element::TYPE_IA5_STRING)); |
|
86 | + // dNSName |
|
87 | + case self::TAG_DNS_NAME: |
|
88 | + return DNSName::fromChosenASN1( |
|
89 | + $el->asImplicit(Element::TYPE_IA5_STRING)); |
|
90 | + // x400Address |
|
91 | + case self::TAG_X400_ADDRESS: |
|
92 | + return X400Address::fromChosenASN1( |
|
93 | + $el->asImplicit(Element::TYPE_SEQUENCE)); |
|
94 | + // directoryName |
|
95 | + case self::TAG_DIRECTORY_NAME: |
|
96 | + // because Name is a CHOICE, albeit having only one option, |
|
97 | + // explicit tagging must be used |
|
98 | + // (see X.680 07/2002 30.6.c) |
|
99 | + return DirectoryName::fromChosenASN1($el->asExplicit()); |
|
100 | + // ediPartyName |
|
101 | + case self::TAG_EDI_PARTY_NAME: |
|
102 | + return EDIPartyName::fromChosenASN1( |
|
103 | + $el->asImplicit(Element::TYPE_SEQUENCE)); |
|
104 | + // uniformResourceIdentifier |
|
105 | + case self::TAG_URI: |
|
106 | + return UniformResourceIdentifier::fromChosenASN1( |
|
107 | + $el->asImplicit(Element::TYPE_IA5_STRING)); |
|
108 | + // iPAddress |
|
109 | + case self::TAG_IP_ADDRESS: |
|
110 | + return IPAddress::fromChosenASN1( |
|
111 | + $el->asImplicit(Element::TYPE_OCTET_STRING)); |
|
112 | + // registeredID |
|
113 | + case self::TAG_REGISTERED_ID: |
|
114 | + return RegisteredID::fromChosenASN1( |
|
115 | + $el->asImplicit(Element::TYPE_OBJECT_IDENTIFIER)); |
|
116 | + } |
|
117 | + throw new \UnexpectedValueException( |
|
118 | + 'GeneralName type ' . $el->tag() . ' not supported.'); |
|
119 | + } |
|
120 | 120 | |
121 | - /** |
|
122 | - * Get type tag. |
|
123 | - * |
|
124 | - * @return int |
|
125 | - */ |
|
126 | - public function tag(): int |
|
127 | - { |
|
128 | - return $this->_tag; |
|
129 | - } |
|
121 | + /** |
|
122 | + * Get type tag. |
|
123 | + * |
|
124 | + * @return int |
|
125 | + */ |
|
126 | + public function tag(): int |
|
127 | + { |
|
128 | + return $this->_tag; |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * Generate ASN.1 element. |
|
133 | - * |
|
134 | - * @return Element |
|
135 | - */ |
|
136 | - public function toASN1(): Element |
|
137 | - { |
|
138 | - return $this->_choiceASN1(); |
|
139 | - } |
|
131 | + /** |
|
132 | + * Generate ASN.1 element. |
|
133 | + * |
|
134 | + * @return Element |
|
135 | + */ |
|
136 | + public function toASN1(): Element |
|
137 | + { |
|
138 | + return $this->_choiceASN1(); |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * Check whether GeneralName is equal to other. |
|
143 | - * |
|
144 | - * @param GeneralName $other GeneralName to compare to |
|
145 | - * |
|
146 | - * @return bool True if names are equal |
|
147 | - */ |
|
148 | - public function equals(GeneralName $other): bool |
|
149 | - { |
|
150 | - if ($this->_tag !== $other->_tag) { |
|
151 | - return false; |
|
152 | - } |
|
153 | - if ($this->_choiceASN1()->toDER() !== $other->_choiceASN1()->toDER()) { |
|
154 | - return false; |
|
155 | - } |
|
156 | - return true; |
|
157 | - } |
|
141 | + /** |
|
142 | + * Check whether GeneralName is equal to other. |
|
143 | + * |
|
144 | + * @param GeneralName $other GeneralName to compare to |
|
145 | + * |
|
146 | + * @return bool True if names are equal |
|
147 | + */ |
|
148 | + public function equals(GeneralName $other): bool |
|
149 | + { |
|
150 | + if ($this->_tag !== $other->_tag) { |
|
151 | + return false; |
|
152 | + } |
|
153 | + if ($this->_choiceASN1()->toDER() !== $other->_choiceASN1()->toDER()) { |
|
154 | + return false; |
|
155 | + } |
|
156 | + return true; |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * Get ASN.1 value in GeneralName CHOICE context. |
|
161 | - * |
|
162 | - * @return TaggedType |
|
163 | - */ |
|
164 | - abstract protected function _choiceASN1(): TaggedType; |
|
159 | + /** |
|
160 | + * Get ASN.1 value in GeneralName CHOICE context. |
|
161 | + * |
|
162 | + * @return TaggedType |
|
163 | + */ |
|
164 | + abstract protected function _choiceASN1(): TaggedType; |
|
165 | 165 | } |
@@ -19,44 +19,44 @@ |
||
19 | 19 | */ |
20 | 20 | class EDIPartyName extends GeneralName |
21 | 21 | { |
22 | - /** |
|
23 | - * @var \Sop\ASN1\Element |
|
24 | - */ |
|
25 | - protected $_element; |
|
26 | - |
|
27 | - /** |
|
28 | - * Constructor. |
|
29 | - */ |
|
30 | - protected function __construct() |
|
31 | - { |
|
32 | - $this->_tag = self::TAG_EDI_PARTY_NAME; |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * {@inheritdoc} |
|
37 | - * |
|
38 | - * @return self |
|
39 | - */ |
|
40 | - public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
41 | - { |
|
42 | - $obj = new self(); |
|
43 | - $obj->_element = $el->asSequence(); |
|
44 | - return $obj; |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * {@inheritdoc} |
|
49 | - */ |
|
50 | - public function string(): string |
|
51 | - { |
|
52 | - return bin2hex($this->_element->toDER()); |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * {@inheritdoc} |
|
57 | - */ |
|
58 | - protected function _choiceASN1(): TaggedType |
|
59 | - { |
|
60 | - return new ImplicitlyTaggedType($this->_tag, $this->_element); |
|
61 | - } |
|
22 | + /** |
|
23 | + * @var \Sop\ASN1\Element |
|
24 | + */ |
|
25 | + protected $_element; |
|
26 | + |
|
27 | + /** |
|
28 | + * Constructor. |
|
29 | + */ |
|
30 | + protected function __construct() |
|
31 | + { |
|
32 | + $this->_tag = self::TAG_EDI_PARTY_NAME; |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * {@inheritdoc} |
|
37 | + * |
|
38 | + * @return self |
|
39 | + */ |
|
40 | + public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
41 | + { |
|
42 | + $obj = new self(); |
|
43 | + $obj->_element = $el->asSequence(); |
|
44 | + return $obj; |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * {@inheritdoc} |
|
49 | + */ |
|
50 | + public function string(): string |
|
51 | + { |
|
52 | + return bin2hex($this->_element->toDER()); |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * {@inheritdoc} |
|
57 | + */ |
|
58 | + protected function _choiceASN1(): TaggedType |
|
59 | + { |
|
60 | + return new ImplicitlyTaggedType($this->_tag, $this->_element); |
|
61 | + } |
|
62 | 62 | } |
@@ -16,57 +16,57 @@ |
||
16 | 16 | */ |
17 | 17 | class DNSName extends GeneralName |
18 | 18 | { |
19 | - /** |
|
20 | - * DNS name. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $_name; |
|
19 | + /** |
|
20 | + * DNS name. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $_name; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Constructor. |
|
28 | - * |
|
29 | - * @param string $name Domain name |
|
30 | - */ |
|
31 | - public function __construct(string $name) |
|
32 | - { |
|
33 | - $this->_tag = self::TAG_DNS_NAME; |
|
34 | - $this->_name = $name; |
|
35 | - } |
|
26 | + /** |
|
27 | + * Constructor. |
|
28 | + * |
|
29 | + * @param string $name Domain name |
|
30 | + */ |
|
31 | + public function __construct(string $name) |
|
32 | + { |
|
33 | + $this->_tag = self::TAG_DNS_NAME; |
|
34 | + $this->_name = $name; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * {@inheritdoc} |
|
39 | - * |
|
40 | - * @return self |
|
41 | - */ |
|
42 | - public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
43 | - { |
|
44 | - return new self($el->asIA5String()->string()); |
|
45 | - } |
|
37 | + /** |
|
38 | + * {@inheritdoc} |
|
39 | + * |
|
40 | + * @return self |
|
41 | + */ |
|
42 | + public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
43 | + { |
|
44 | + return new self($el->asIA5String()->string()); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * {@inheritdoc} |
|
49 | - */ |
|
50 | - public function string(): string |
|
51 | - { |
|
52 | - return $this->_name; |
|
53 | - } |
|
47 | + /** |
|
48 | + * {@inheritdoc} |
|
49 | + */ |
|
50 | + public function string(): string |
|
51 | + { |
|
52 | + return $this->_name; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Get DNS name. |
|
57 | - * |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function name(): string |
|
61 | - { |
|
62 | - return $this->_name; |
|
63 | - } |
|
55 | + /** |
|
56 | + * Get DNS name. |
|
57 | + * |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function name(): string |
|
61 | + { |
|
62 | + return $this->_name; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * {@inheritdoc} |
|
67 | - */ |
|
68 | - protected function _choiceASN1(): TaggedType |
|
69 | - { |
|
70 | - return new ImplicitlyTaggedType($this->_tag, new IA5String($this->_name)); |
|
71 | - } |
|
65 | + /** |
|
66 | + * {@inheritdoc} |
|
67 | + */ |
|
68 | + protected function _choiceASN1(): TaggedType |
|
69 | + { |
|
70 | + return new ImplicitlyTaggedType($this->_tag, new IA5String($this->_name)); |
|
71 | + } |
|
72 | 72 | } |
@@ -16,71 +16,71 @@ |
||
16 | 16 | */ |
17 | 17 | class DirectoryName extends GeneralName |
18 | 18 | { |
19 | - /** |
|
20 | - * Directory name. |
|
21 | - * |
|
22 | - * @var Name |
|
23 | - */ |
|
24 | - protected $_dn; |
|
19 | + /** |
|
20 | + * Directory name. |
|
21 | + * |
|
22 | + * @var Name |
|
23 | + */ |
|
24 | + protected $_dn; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Constructor. |
|
28 | - * |
|
29 | - * @param Name $dn |
|
30 | - */ |
|
31 | - public function __construct(Name $dn) |
|
32 | - { |
|
33 | - $this->_tag = self::TAG_DIRECTORY_NAME; |
|
34 | - $this->_dn = $dn; |
|
35 | - } |
|
26 | + /** |
|
27 | + * Constructor. |
|
28 | + * |
|
29 | + * @param Name $dn |
|
30 | + */ |
|
31 | + public function __construct(Name $dn) |
|
32 | + { |
|
33 | + $this->_tag = self::TAG_DIRECTORY_NAME; |
|
34 | + $this->_dn = $dn; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * {@inheritdoc} |
|
39 | - * |
|
40 | - * @return self |
|
41 | - */ |
|
42 | - public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
43 | - { |
|
44 | - return new self(Name::fromASN1($el->asSequence())); |
|
45 | - } |
|
37 | + /** |
|
38 | + * {@inheritdoc} |
|
39 | + * |
|
40 | + * @return self |
|
41 | + */ |
|
42 | + public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
43 | + { |
|
44 | + return new self(Name::fromASN1($el->asSequence())); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Initialize from distinguished name string. |
|
49 | - * |
|
50 | - * @param string $str |
|
51 | - * |
|
52 | - * @return self |
|
53 | - */ |
|
54 | - public static function fromDNString(string $str): self |
|
55 | - { |
|
56 | - return new self(Name::fromString($str)); |
|
57 | - } |
|
47 | + /** |
|
48 | + * Initialize from distinguished name string. |
|
49 | + * |
|
50 | + * @param string $str |
|
51 | + * |
|
52 | + * @return self |
|
53 | + */ |
|
54 | + public static function fromDNString(string $str): self |
|
55 | + { |
|
56 | + return new self(Name::fromString($str)); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * {@inheritdoc} |
|
61 | - */ |
|
62 | - public function string(): string |
|
63 | - { |
|
64 | - return $this->_dn->toString(); |
|
65 | - } |
|
59 | + /** |
|
60 | + * {@inheritdoc} |
|
61 | + */ |
|
62 | + public function string(): string |
|
63 | + { |
|
64 | + return $this->_dn->toString(); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Get directory name. |
|
69 | - * |
|
70 | - * @return Name |
|
71 | - */ |
|
72 | - public function dn(): Name |
|
73 | - { |
|
74 | - return $this->_dn; |
|
75 | - } |
|
67 | + /** |
|
68 | + * Get directory name. |
|
69 | + * |
|
70 | + * @return Name |
|
71 | + */ |
|
72 | + public function dn(): Name |
|
73 | + { |
|
74 | + return $this->_dn; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * {@inheritdoc} |
|
79 | - */ |
|
80 | - protected function _choiceASN1(): TaggedType |
|
81 | - { |
|
82 | - // Name type is itself a CHOICE, so explicit tagging must be |
|
83 | - // employed to avoid ambiguities |
|
84 | - return new ExplicitlyTaggedType($this->_tag, $this->_dn->toASN1()); |
|
85 | - } |
|
77 | + /** |
|
78 | + * {@inheritdoc} |
|
79 | + */ |
|
80 | + protected function _choiceASN1(): TaggedType |
|
81 | + { |
|
82 | + // Name type is itself a CHOICE, so explicit tagging must be |
|
83 | + // employed to avoid ambiguities |
|
84 | + return new ExplicitlyTaggedType($this->_tag, $this->_dn->toASN1()); |
|
85 | + } |
|
86 | 86 | } |
@@ -19,44 +19,44 @@ |
||
19 | 19 | */ |
20 | 20 | class X400Address extends GeneralName |
21 | 21 | { |
22 | - /** |
|
23 | - * @var \Sop\ASN1\Element |
|
24 | - */ |
|
25 | - protected $_element; |
|
26 | - |
|
27 | - /** |
|
28 | - * Constructor. |
|
29 | - */ |
|
30 | - protected function __construct() |
|
31 | - { |
|
32 | - $this->_tag = self::TAG_X400_ADDRESS; |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * {@inheritdoc} |
|
37 | - * |
|
38 | - * @return self |
|
39 | - */ |
|
40 | - public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
41 | - { |
|
42 | - $obj = new self(); |
|
43 | - $obj->_element = $el->asSequence(); |
|
44 | - return $obj; |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * {@inheritdoc} |
|
49 | - */ |
|
50 | - public function string(): string |
|
51 | - { |
|
52 | - return bin2hex($this->_element->toDER()); |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * {@inheritdoc} |
|
57 | - */ |
|
58 | - protected function _choiceASN1(): TaggedType |
|
59 | - { |
|
60 | - return new ImplicitlyTaggedType($this->_tag, $this->_element); |
|
61 | - } |
|
22 | + /** |
|
23 | + * @var \Sop\ASN1\Element |
|
24 | + */ |
|
25 | + protected $_element; |
|
26 | + |
|
27 | + /** |
|
28 | + * Constructor. |
|
29 | + */ |
|
30 | + protected function __construct() |
|
31 | + { |
|
32 | + $this->_tag = self::TAG_X400_ADDRESS; |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * {@inheritdoc} |
|
37 | + * |
|
38 | + * @return self |
|
39 | + */ |
|
40 | + public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
41 | + { |
|
42 | + $obj = new self(); |
|
43 | + $obj->_element = $el->asSequence(); |
|
44 | + return $obj; |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * {@inheritdoc} |
|
49 | + */ |
|
50 | + public function string(): string |
|
51 | + { |
|
52 | + return bin2hex($this->_element->toDER()); |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * {@inheritdoc} |
|
57 | + */ |
|
58 | + protected function _choiceASN1(): TaggedType |
|
59 | + { |
|
60 | + return new ImplicitlyTaggedType($this->_tag, $this->_element); |
|
61 | + } |
|
62 | 62 | } |
@@ -16,57 +16,57 @@ |
||
16 | 16 | */ |
17 | 17 | class RFC822Name extends GeneralName |
18 | 18 | { |
19 | - /** |
|
20 | - * Email. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $_email; |
|
19 | + /** |
|
20 | + * Email. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $_email; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Constructor. |
|
28 | - * |
|
29 | - * @param string $email |
|
30 | - */ |
|
31 | - public function __construct(string $email) |
|
32 | - { |
|
33 | - $this->_tag = self::TAG_RFC822_NAME; |
|
34 | - $this->_email = $email; |
|
35 | - } |
|
26 | + /** |
|
27 | + * Constructor. |
|
28 | + * |
|
29 | + * @param string $email |
|
30 | + */ |
|
31 | + public function __construct(string $email) |
|
32 | + { |
|
33 | + $this->_tag = self::TAG_RFC822_NAME; |
|
34 | + $this->_email = $email; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * {@inheritdoc} |
|
39 | - * |
|
40 | - * @return self |
|
41 | - */ |
|
42 | - public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
43 | - { |
|
44 | - return new self($el->asIA5String()->string()); |
|
45 | - } |
|
37 | + /** |
|
38 | + * {@inheritdoc} |
|
39 | + * |
|
40 | + * @return self |
|
41 | + */ |
|
42 | + public static function fromChosenASN1(UnspecifiedType $el): GeneralName |
|
43 | + { |
|
44 | + return new self($el->asIA5String()->string()); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * {@inheritdoc} |
|
49 | - */ |
|
50 | - public function string(): string |
|
51 | - { |
|
52 | - return $this->_email; |
|
53 | - } |
|
47 | + /** |
|
48 | + * {@inheritdoc} |
|
49 | + */ |
|
50 | + public function string(): string |
|
51 | + { |
|
52 | + return $this->_email; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Get email. |
|
57 | - * |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function email(): string |
|
61 | - { |
|
62 | - return $this->_email; |
|
63 | - } |
|
55 | + /** |
|
56 | + * Get email. |
|
57 | + * |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function email(): string |
|
61 | + { |
|
62 | + return $this->_email; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * {@inheritdoc} |
|
67 | - */ |
|
68 | - protected function _choiceASN1(): TaggedType |
|
69 | - { |
|
70 | - return new ImplicitlyTaggedType($this->_tag, new IA5String($this->_email)); |
|
71 | - } |
|
65 | + /** |
|
66 | + * {@inheritdoc} |
|
67 | + */ |
|
68 | + protected function _choiceASN1(): TaggedType |
|
69 | + { |
|
70 | + return new ImplicitlyTaggedType($this->_tag, new IA5String($this->_email)); |
|
71 | + } |
|
72 | 72 | } |