@@ -13,15 +13,15 @@ |
||
13 | 13 | */ |
14 | 14 | class PseudonymValue extends DirectoryString |
15 | 15 | { |
16 | - /** |
|
17 | - * Constructor. |
|
18 | - * |
|
19 | - * @param string $value String value |
|
20 | - * @param int $string_tag Syntax choice |
|
21 | - */ |
|
22 | - public function __construct($value, $string_tag = DirectoryString::UTF8) |
|
23 | - { |
|
24 | - $this->_oid = AttributeType::OID_PSEUDONYM; |
|
25 | - parent::__construct($value, $string_tag); |
|
26 | - } |
|
16 | + /** |
|
17 | + * Constructor. |
|
18 | + * |
|
19 | + * @param string $value String value |
|
20 | + * @param int $string_tag Syntax choice |
|
21 | + */ |
|
22 | + public function __construct($value, $string_tag = DirectoryString::UTF8) |
|
23 | + { |
|
24 | + $this->_oid = AttributeType::OID_PSEUDONYM; |
|
25 | + parent::__construct($value, $string_tag); |
|
26 | + } |
|
27 | 27 | } |
@@ -23,167 +23,167 @@ |
||
23 | 23 | */ |
24 | 24 | abstract class DirectoryString extends AttributeValue |
25 | 25 | { |
26 | - /** |
|
27 | - * Teletex string syntax. |
|
28 | - * |
|
29 | - * @var int |
|
30 | - */ |
|
31 | - const TELETEX = Element::TYPE_T61_STRING; |
|
26 | + /** |
|
27 | + * Teletex string syntax. |
|
28 | + * |
|
29 | + * @var int |
|
30 | + */ |
|
31 | + const TELETEX = Element::TYPE_T61_STRING; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Printable string syntax. |
|
35 | - * |
|
36 | - * @var int |
|
37 | - */ |
|
38 | - const PRINTABLE = Element::TYPE_PRINTABLE_STRING; |
|
33 | + /** |
|
34 | + * Printable string syntax. |
|
35 | + * |
|
36 | + * @var int |
|
37 | + */ |
|
38 | + const PRINTABLE = Element::TYPE_PRINTABLE_STRING; |
|
39 | 39 | |
40 | - /** |
|
41 | - * BMP string syntax. |
|
42 | - * |
|
43 | - * @var int |
|
44 | - */ |
|
45 | - const BMP = Element::TYPE_BMP_STRING; |
|
40 | + /** |
|
41 | + * BMP string syntax. |
|
42 | + * |
|
43 | + * @var int |
|
44 | + */ |
|
45 | + const BMP = Element::TYPE_BMP_STRING; |
|
46 | 46 | |
47 | - /** |
|
48 | - * Universal string syntax. |
|
49 | - * |
|
50 | - * @var int |
|
51 | - */ |
|
52 | - const UNIVERSAL = Element::TYPE_UNIVERSAL_STRING; |
|
47 | + /** |
|
48 | + * Universal string syntax. |
|
49 | + * |
|
50 | + * @var int |
|
51 | + */ |
|
52 | + const UNIVERSAL = Element::TYPE_UNIVERSAL_STRING; |
|
53 | 53 | |
54 | - /** |
|
55 | - * UTF-8 string syntax. |
|
56 | - * |
|
57 | - * @var int |
|
58 | - */ |
|
59 | - const UTF8 = Element::TYPE_UTF8_STRING; |
|
54 | + /** |
|
55 | + * UTF-8 string syntax. |
|
56 | + * |
|
57 | + * @var int |
|
58 | + */ |
|
59 | + const UTF8 = Element::TYPE_UTF8_STRING; |
|
60 | 60 | |
61 | - /** |
|
62 | - * Mapping from syntax enumeration to ASN.1 class name. |
|
63 | - * |
|
64 | - * @internal |
|
65 | - * |
|
66 | - * @var array |
|
67 | - */ |
|
68 | - const MAP_TAG_TO_CLASS = array( |
|
69 | - /* @formatter:off */ |
|
70 | - self::TELETEX => T61String::class, |
|
71 | - self::PRINTABLE => PrintableString::class, |
|
72 | - self::UNIVERSAL => UniversalString::class, |
|
73 | - self::UTF8 => UTF8String::class, |
|
74 | - self::BMP => BMPString::class |
|
75 | - /* @formatter:on */ |
|
76 | - ); |
|
61 | + /** |
|
62 | + * Mapping from syntax enumeration to ASN.1 class name. |
|
63 | + * |
|
64 | + * @internal |
|
65 | + * |
|
66 | + * @var array |
|
67 | + */ |
|
68 | + const MAP_TAG_TO_CLASS = array( |
|
69 | + /* @formatter:off */ |
|
70 | + self::TELETEX => T61String::class, |
|
71 | + self::PRINTABLE => PrintableString::class, |
|
72 | + self::UNIVERSAL => UniversalString::class, |
|
73 | + self::UTF8 => UTF8String::class, |
|
74 | + self::BMP => BMPString::class |
|
75 | + /* @formatter:on */ |
|
76 | + ); |
|
77 | 77 | |
78 | - /** |
|
79 | - * ASN.1 type tag for the chosen syntax. |
|
80 | - * |
|
81 | - * @var int $_stringTag |
|
82 | - */ |
|
83 | - protected $_stringTag; |
|
78 | + /** |
|
79 | + * ASN.1 type tag for the chosen syntax. |
|
80 | + * |
|
81 | + * @var int $_stringTag |
|
82 | + */ |
|
83 | + protected $_stringTag; |
|
84 | 84 | |
85 | - /** |
|
86 | - * String value. |
|
87 | - * |
|
88 | - * @var string $_string |
|
89 | - */ |
|
90 | - protected $_string; |
|
85 | + /** |
|
86 | + * String value. |
|
87 | + * |
|
88 | + * @var string $_string |
|
89 | + */ |
|
90 | + protected $_string; |
|
91 | 91 | |
92 | - /** |
|
93 | - * Constructor. |
|
94 | - * |
|
95 | - * @param string $value String value |
|
96 | - * @param int $string_tag Syntax choice |
|
97 | - */ |
|
98 | - public function __construct($value, $string_tag) |
|
99 | - { |
|
100 | - $this->_string = $value; |
|
101 | - $this->_stringTag = $string_tag; |
|
102 | - } |
|
92 | + /** |
|
93 | + * Constructor. |
|
94 | + * |
|
95 | + * @param string $value String value |
|
96 | + * @param int $string_tag Syntax choice |
|
97 | + */ |
|
98 | + public function __construct($value, $string_tag) |
|
99 | + { |
|
100 | + $this->_string = $value; |
|
101 | + $this->_stringTag = $string_tag; |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * |
|
106 | - * @see AttributeValue::fromASN1 |
|
107 | - * @param UnspecifiedType $el |
|
108 | - * @return self |
|
109 | - */ |
|
110 | - public static function fromASN1(UnspecifiedType $el) |
|
111 | - { |
|
112 | - $tag = $el->tag(); |
|
113 | - self::_tagToASN1Class($tag); |
|
114 | - return new static($el->asString()->string(), $tag); |
|
115 | - } |
|
104 | + /** |
|
105 | + * |
|
106 | + * @see AttributeValue::fromASN1 |
|
107 | + * @param UnspecifiedType $el |
|
108 | + * @return self |
|
109 | + */ |
|
110 | + public static function fromASN1(UnspecifiedType $el) |
|
111 | + { |
|
112 | + $tag = $el->tag(); |
|
113 | + self::_tagToASN1Class($tag); |
|
114 | + return new static($el->asString()->string(), $tag); |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * |
|
119 | - * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1() |
|
120 | - * @return Element |
|
121 | - */ |
|
122 | - public function toASN1() |
|
123 | - { |
|
124 | - $cls = self::_tagToASN1Class($this->_stringTag); |
|
125 | - return new $cls($this->_string); |
|
126 | - } |
|
117 | + /** |
|
118 | + * |
|
119 | + * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1() |
|
120 | + * @return Element |
|
121 | + */ |
|
122 | + public function toASN1() |
|
123 | + { |
|
124 | + $cls = self::_tagToASN1Class($this->_stringTag); |
|
125 | + return new $cls($this->_string); |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * Get ASN.1 class name for given DirectoryString type tag. |
|
130 | - * |
|
131 | - * @param int $tag |
|
132 | - * @throws \UnexpectedValueException |
|
133 | - * @return string |
|
134 | - */ |
|
135 | - private static function _tagToASN1Class($tag) |
|
136 | - { |
|
137 | - if (!array_key_exists($tag, self::MAP_TAG_TO_CLASS)) { |
|
138 | - throw new \UnexpectedValueException( |
|
139 | - "Type " . Element::tagToName($tag) . |
|
140 | - " is not valid DirectoryString."); |
|
141 | - } |
|
142 | - return self::MAP_TAG_TO_CLASS[$tag]; |
|
143 | - } |
|
128 | + /** |
|
129 | + * Get ASN.1 class name for given DirectoryString type tag. |
|
130 | + * |
|
131 | + * @param int $tag |
|
132 | + * @throws \UnexpectedValueException |
|
133 | + * @return string |
|
134 | + */ |
|
135 | + private static function _tagToASN1Class($tag) |
|
136 | + { |
|
137 | + if (!array_key_exists($tag, self::MAP_TAG_TO_CLASS)) { |
|
138 | + throw new \UnexpectedValueException( |
|
139 | + "Type " . Element::tagToName($tag) . |
|
140 | + " is not valid DirectoryString."); |
|
141 | + } |
|
142 | + return self::MAP_TAG_TO_CLASS[$tag]; |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * |
|
147 | - * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue() |
|
148 | - * @return string |
|
149 | - */ |
|
150 | - public function stringValue() |
|
151 | - { |
|
152 | - return $this->_string; |
|
153 | - } |
|
145 | + /** |
|
146 | + * |
|
147 | + * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue() |
|
148 | + * @return string |
|
149 | + */ |
|
150 | + public function stringValue() |
|
151 | + { |
|
152 | + return $this->_string; |
|
153 | + } |
|
154 | 154 | |
155 | - /** |
|
156 | - * |
|
157 | - * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule() |
|
158 | - * @return CaseIgnoreMatch |
|
159 | - */ |
|
160 | - public function equalityMatchingRule() |
|
161 | - { |
|
162 | - return new CaseIgnoreMatch($this->_stringTag); |
|
163 | - } |
|
155 | + /** |
|
156 | + * |
|
157 | + * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule() |
|
158 | + * @return CaseIgnoreMatch |
|
159 | + */ |
|
160 | + public function equalityMatchingRule() |
|
161 | + { |
|
162 | + return new CaseIgnoreMatch($this->_stringTag); |
|
163 | + } |
|
164 | 164 | |
165 | - /** |
|
166 | - * |
|
167 | - * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String() |
|
168 | - * @return string |
|
169 | - */ |
|
170 | - public function rfc2253String() |
|
171 | - { |
|
172 | - // TeletexString is encoded as binary |
|
173 | - if ($this->_stringTag == self::TELETEX) { |
|
174 | - return $this->_transcodedString(); |
|
175 | - } |
|
176 | - return DNParser::escapeString($this->_transcodedString()); |
|
177 | - } |
|
165 | + /** |
|
166 | + * |
|
167 | + * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String() |
|
168 | + * @return string |
|
169 | + */ |
|
170 | + public function rfc2253String() |
|
171 | + { |
|
172 | + // TeletexString is encoded as binary |
|
173 | + if ($this->_stringTag == self::TELETEX) { |
|
174 | + return $this->_transcodedString(); |
|
175 | + } |
|
176 | + return DNParser::escapeString($this->_transcodedString()); |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * |
|
181 | - * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString() |
|
182 | - * @return string |
|
183 | - */ |
|
184 | - protected function _transcodedString() |
|
185 | - { |
|
186 | - $step = new TranscodeStep($this->_stringTag); |
|
187 | - return $step->apply($this->_string); |
|
188 | - } |
|
179 | + /** |
|
180 | + * |
|
181 | + * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString() |
|
182 | + * @return string |
|
183 | + */ |
|
184 | + protected function _transcodedString() |
|
185 | + { |
|
186 | + $step = new TranscodeStep($this->_stringTag); |
|
187 | + return $step->apply($this->_string); |
|
188 | + } |
|
189 | 189 | } |
@@ -14,83 +14,83 @@ |
||
14 | 14 | */ |
15 | 15 | abstract class PrintableStringValue extends AttributeValue |
16 | 16 | { |
17 | - /** |
|
18 | - * String value. |
|
19 | - * |
|
20 | - * @var string $_string |
|
21 | - */ |
|
22 | - protected $_string; |
|
17 | + /** |
|
18 | + * String value. |
|
19 | + * |
|
20 | + * @var string $_string |
|
21 | + */ |
|
22 | + protected $_string; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Constructor |
|
26 | - * |
|
27 | - * @param string $value String value |
|
28 | - */ |
|
29 | - public function __construct($value) |
|
30 | - { |
|
31 | - $this->_string = $value; |
|
32 | - } |
|
24 | + /** |
|
25 | + * Constructor |
|
26 | + * |
|
27 | + * @param string $value String value |
|
28 | + */ |
|
29 | + public function __construct($value) |
|
30 | + { |
|
31 | + $this->_string = $value; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * |
|
36 | - * @see AttributeValue::fromASN1 |
|
37 | - * @param UnspecifiedType $el |
|
38 | - * @return self |
|
39 | - */ |
|
40 | - public static function fromASN1(UnspecifiedType $el) |
|
41 | - { |
|
42 | - return new static($el->asPrintableString()->string()); |
|
43 | - } |
|
34 | + /** |
|
35 | + * |
|
36 | + * @see AttributeValue::fromASN1 |
|
37 | + * @param UnspecifiedType $el |
|
38 | + * @return self |
|
39 | + */ |
|
40 | + public static function fromASN1(UnspecifiedType $el) |
|
41 | + { |
|
42 | + return new static($el->asPrintableString()->string()); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * |
|
47 | - * @see AttributeValue::toASN1 |
|
48 | - * @return PrintableString |
|
49 | - */ |
|
50 | - public function toASN1() |
|
51 | - { |
|
52 | - return new PrintableString($this->_string); |
|
53 | - } |
|
45 | + /** |
|
46 | + * |
|
47 | + * @see AttributeValue::toASN1 |
|
48 | + * @return PrintableString |
|
49 | + */ |
|
50 | + public function toASN1() |
|
51 | + { |
|
52 | + return new PrintableString($this->_string); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * |
|
57 | - * @see AttributeValue::stringValue |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function stringValue() |
|
61 | - { |
|
62 | - return $this->_string; |
|
63 | - } |
|
55 | + /** |
|
56 | + * |
|
57 | + * @see AttributeValue::stringValue |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function stringValue() |
|
61 | + { |
|
62 | + return $this->_string; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * |
|
67 | - * @see AttributeValue::equalityMatchingRule |
|
68 | - * @return CaseIgnoreMatch |
|
69 | - */ |
|
70 | - public function equalityMatchingRule() |
|
71 | - { |
|
72 | - // default to caseIgnoreMatch |
|
73 | - return new CaseIgnoreMatch(Element::TYPE_PRINTABLE_STRING); |
|
74 | - } |
|
65 | + /** |
|
66 | + * |
|
67 | + * @see AttributeValue::equalityMatchingRule |
|
68 | + * @return CaseIgnoreMatch |
|
69 | + */ |
|
70 | + public function equalityMatchingRule() |
|
71 | + { |
|
72 | + // default to caseIgnoreMatch |
|
73 | + return new CaseIgnoreMatch(Element::TYPE_PRINTABLE_STRING); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * |
|
78 | - * @see AttributeValue::rfc2253String |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function rfc2253String() |
|
82 | - { |
|
83 | - return DNParser::escapeString($this->_transcodedString()); |
|
84 | - } |
|
76 | + /** |
|
77 | + * |
|
78 | + * @see AttributeValue::rfc2253String |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function rfc2253String() |
|
82 | + { |
|
83 | + return DNParser::escapeString($this->_transcodedString()); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * |
|
88 | - * @see AttributeValue::_transcodedString |
|
89 | - * @return string |
|
90 | - */ |
|
91 | - protected function _transcodedString() |
|
92 | - { |
|
93 | - // PrintableString maps directly to UTF-8 |
|
94 | - return $this->_string; |
|
95 | - } |
|
86 | + /** |
|
87 | + * |
|
88 | + * @see AttributeValue::_transcodedString |
|
89 | + * @return string |
|
90 | + */ |
|
91 | + protected function _transcodedString() |
|
92 | + { |
|
93 | + // PrintableString maps directly to UTF-8 |
|
94 | + return $this->_string; |
|
95 | + } |
|
96 | 96 | } |
@@ -15,154 +15,154 @@ |
||
15 | 15 | */ |
16 | 16 | abstract class AttributeValue |
17 | 17 | { |
18 | - /** |
|
19 | - * Mapping from attribute type OID to attribute value class name. |
|
20 | - * |
|
21 | - * @internal |
|
22 | - * |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - const MAP_OID_TO_CLASS = array( |
|
26 | - /* @formatter:off */ |
|
27 | - AttributeType::OID_COMMON_NAME => CommonNameValue::class, |
|
28 | - AttributeType::OID_SURNAME => SurnameValue::class, |
|
29 | - AttributeType::OID_SERIAL_NUMBER => SerialNumberValue::class, |
|
30 | - AttributeType::OID_COUNTRY_NAME => CountryNameValue::class, |
|
31 | - AttributeType::OID_LOCALITY_NAME => LocalityNameValue::class, |
|
32 | - AttributeType::OID_STATE_OR_PROVINCE_NAME => StateOrProvinceNameValue::class, |
|
33 | - AttributeType::OID_ORGANIZATION_NAME => OrganizationNameValue::class, |
|
34 | - AttributeType::OID_ORGANIZATIONAL_UNIT_NAME => OrganizationalUnitNameValue::class, |
|
35 | - AttributeType::OID_TITLE => TitleValue::class, |
|
36 | - AttributeType::OID_DESCRIPTION => DescriptionValue::class, |
|
37 | - AttributeType::OID_NAME => NameValue::class, |
|
38 | - AttributeType::OID_GIVEN_NAME => GivenNameValue::class, |
|
39 | - AttributeType::OID_PSEUDONYM => PseudonymValue::class |
|
40 | - /* @formatter:on */ |
|
41 | - ); |
|
18 | + /** |
|
19 | + * Mapping from attribute type OID to attribute value class name. |
|
20 | + * |
|
21 | + * @internal |
|
22 | + * |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + const MAP_OID_TO_CLASS = array( |
|
26 | + /* @formatter:off */ |
|
27 | + AttributeType::OID_COMMON_NAME => CommonNameValue::class, |
|
28 | + AttributeType::OID_SURNAME => SurnameValue::class, |
|
29 | + AttributeType::OID_SERIAL_NUMBER => SerialNumberValue::class, |
|
30 | + AttributeType::OID_COUNTRY_NAME => CountryNameValue::class, |
|
31 | + AttributeType::OID_LOCALITY_NAME => LocalityNameValue::class, |
|
32 | + AttributeType::OID_STATE_OR_PROVINCE_NAME => StateOrProvinceNameValue::class, |
|
33 | + AttributeType::OID_ORGANIZATION_NAME => OrganizationNameValue::class, |
|
34 | + AttributeType::OID_ORGANIZATIONAL_UNIT_NAME => OrganizationalUnitNameValue::class, |
|
35 | + AttributeType::OID_TITLE => TitleValue::class, |
|
36 | + AttributeType::OID_DESCRIPTION => DescriptionValue::class, |
|
37 | + AttributeType::OID_NAME => NameValue::class, |
|
38 | + AttributeType::OID_GIVEN_NAME => GivenNameValue::class, |
|
39 | + AttributeType::OID_PSEUDONYM => PseudonymValue::class |
|
40 | + /* @formatter:on */ |
|
41 | + ); |
|
42 | 42 | |
43 | - /** |
|
44 | - * OID of the attribute type. |
|
45 | - * |
|
46 | - * @var string $_oid |
|
47 | - */ |
|
48 | - protected $_oid; |
|
43 | + /** |
|
44 | + * OID of the attribute type. |
|
45 | + * |
|
46 | + * @var string $_oid |
|
47 | + */ |
|
48 | + protected $_oid; |
|
49 | 49 | |
50 | - /** |
|
51 | - * Generate ASN.1 element. |
|
52 | - * |
|
53 | - * @return \ASN1\Element |
|
54 | - */ |
|
55 | - abstract public function toASN1(); |
|
50 | + /** |
|
51 | + * Generate ASN.1 element. |
|
52 | + * |
|
53 | + * @return \ASN1\Element |
|
54 | + */ |
|
55 | + abstract public function toASN1(); |
|
56 | 56 | |
57 | - /** |
|
58 | - * Get attribute value as a string |
|
59 | - * |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - abstract public function stringValue(); |
|
57 | + /** |
|
58 | + * Get attribute value as a string |
|
59 | + * |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + abstract public function stringValue(); |
|
63 | 63 | |
64 | - /** |
|
65 | - * Get matching rule for equality comparison. |
|
66 | - * |
|
67 | - * @return \X501\MatchingRule\MatchingRule |
|
68 | - */ |
|
69 | - abstract public function equalityMatchingRule(); |
|
64 | + /** |
|
65 | + * Get matching rule for equality comparison. |
|
66 | + * |
|
67 | + * @return \X501\MatchingRule\MatchingRule |
|
68 | + */ |
|
69 | + abstract public function equalityMatchingRule(); |
|
70 | 70 | |
71 | - /** |
|
72 | - * Get attribute value as a string conforming to RFC 2253. |
|
73 | - * |
|
74 | - * @link https://tools.ietf.org/html/rfc2253#section-2.4 |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - abstract public function rfc2253String(); |
|
71 | + /** |
|
72 | + * Get attribute value as a string conforming to RFC 2253. |
|
73 | + * |
|
74 | + * @link https://tools.ietf.org/html/rfc2253#section-2.4 |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + abstract public function rfc2253String(); |
|
78 | 78 | |
79 | - /** |
|
80 | - * Get attribute value as an UTF-8 string conforming to RFC 4518. |
|
81 | - * |
|
82 | - * @link https://tools.ietf.org/html/rfc4518#section-2.1 |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - abstract protected function _transcodedString(); |
|
79 | + /** |
|
80 | + * Get attribute value as an UTF-8 string conforming to RFC 4518. |
|
81 | + * |
|
82 | + * @link https://tools.ietf.org/html/rfc4518#section-2.1 |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + abstract protected function _transcodedString(); |
|
86 | 86 | |
87 | - /** |
|
88 | - * Initialize from ASN.1. |
|
89 | - * |
|
90 | - * @param UnspecifiedType $el |
|
91 | - * @return self |
|
92 | - */ |
|
93 | - public static function fromASN1(UnspecifiedType $el) |
|
94 | - { |
|
95 | - throw new \BadMethodCallException( |
|
96 | - "ASN.1 parsing must be implemented in a concrete class."); |
|
97 | - } |
|
87 | + /** |
|
88 | + * Initialize from ASN.1. |
|
89 | + * |
|
90 | + * @param UnspecifiedType $el |
|
91 | + * @return self |
|
92 | + */ |
|
93 | + public static function fromASN1(UnspecifiedType $el) |
|
94 | + { |
|
95 | + throw new \BadMethodCallException( |
|
96 | + "ASN.1 parsing must be implemented in a concrete class."); |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * Initialize from ASN.1 with given OID hint. |
|
101 | - * |
|
102 | - * @param string $oid Attribute's OID |
|
103 | - * @param UnspecifiedType $el |
|
104 | - * @return self |
|
105 | - */ |
|
106 | - public static function fromASN1ByOID($oid, UnspecifiedType $el) |
|
107 | - { |
|
108 | - if (!array_key_exists($oid, self::MAP_OID_TO_CLASS)) { |
|
109 | - return new UnknownAttributeValue($oid, $el->asElement()); |
|
110 | - } |
|
111 | - $cls = self::MAP_OID_TO_CLASS[$oid]; |
|
112 | - return $cls::fromASN1($el); |
|
113 | - } |
|
99 | + /** |
|
100 | + * Initialize from ASN.1 with given OID hint. |
|
101 | + * |
|
102 | + * @param string $oid Attribute's OID |
|
103 | + * @param UnspecifiedType $el |
|
104 | + * @return self |
|
105 | + */ |
|
106 | + public static function fromASN1ByOID($oid, UnspecifiedType $el) |
|
107 | + { |
|
108 | + if (!array_key_exists($oid, self::MAP_OID_TO_CLASS)) { |
|
109 | + return new UnknownAttributeValue($oid, $el->asElement()); |
|
110 | + } |
|
111 | + $cls = self::MAP_OID_TO_CLASS[$oid]; |
|
112 | + return $cls::fromASN1($el); |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * Initialize from another AttributeValue. |
|
117 | - * |
|
118 | - * This method is generally used to cast UnknownAttributeValue to |
|
119 | - * specific object when class is declared outside this package. |
|
120 | - * |
|
121 | - * @param self $obj Instance of AttributeValue |
|
122 | - * @return self |
|
123 | - */ |
|
124 | - public static function fromSelf(self $obj) |
|
125 | - { |
|
126 | - return static::fromASN1($obj->toASN1()->asUnspecified()); |
|
127 | - } |
|
115 | + /** |
|
116 | + * Initialize from another AttributeValue. |
|
117 | + * |
|
118 | + * This method is generally used to cast UnknownAttributeValue to |
|
119 | + * specific object when class is declared outside this package. |
|
120 | + * |
|
121 | + * @param self $obj Instance of AttributeValue |
|
122 | + * @return self |
|
123 | + */ |
|
124 | + public static function fromSelf(self $obj) |
|
125 | + { |
|
126 | + return static::fromASN1($obj->toASN1()->asUnspecified()); |
|
127 | + } |
|
128 | 128 | |
129 | - /** |
|
130 | - * Get attribute type's OID. |
|
131 | - * |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public function oid() |
|
135 | - { |
|
136 | - return $this->_oid; |
|
137 | - } |
|
129 | + /** |
|
130 | + * Get attribute type's OID. |
|
131 | + * |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public function oid() |
|
135 | + { |
|
136 | + return $this->_oid; |
|
137 | + } |
|
138 | 138 | |
139 | - /** |
|
140 | - * Get Attribute object with this as a single value. |
|
141 | - * |
|
142 | - * @return Attribute |
|
143 | - */ |
|
144 | - public function toAttribute() |
|
145 | - { |
|
146 | - return Attribute::fromAttributeValues($this); |
|
147 | - } |
|
139 | + /** |
|
140 | + * Get Attribute object with this as a single value. |
|
141 | + * |
|
142 | + * @return Attribute |
|
143 | + */ |
|
144 | + public function toAttribute() |
|
145 | + { |
|
146 | + return Attribute::fromAttributeValues($this); |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * Get AttributeTypeAndValue object with this as a value. |
|
151 | - * |
|
152 | - * @return AttributeTypeAndValue |
|
153 | - */ |
|
154 | - public function toAttributeTypeAndValue() |
|
155 | - { |
|
156 | - return AttributeTypeAndValue::fromAttributeValue($this); |
|
157 | - } |
|
149 | + /** |
|
150 | + * Get AttributeTypeAndValue object with this as a value. |
|
151 | + * |
|
152 | + * @return AttributeTypeAndValue |
|
153 | + */ |
|
154 | + public function toAttributeTypeAndValue() |
|
155 | + { |
|
156 | + return AttributeTypeAndValue::fromAttributeValue($this); |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * Get attribute value as an UTF-8 encoded string. |
|
161 | - * |
|
162 | - * @return string |
|
163 | - */ |
|
164 | - public function __toString() |
|
165 | - { |
|
166 | - return $this->_transcodedString(); |
|
167 | - } |
|
159 | + /** |
|
160 | + * Get attribute value as an UTF-8 encoded string. |
|
161 | + * |
|
162 | + * @return string |
|
163 | + */ |
|
164 | + public function __toString() |
|
165 | + { |
|
166 | + return $this->_transcodedString(); |
|
167 | + } |
|
168 | 168 | } |
@@ -13,14 +13,14 @@ |
||
13 | 13 | */ |
14 | 14 | class CountryNameValue extends PrintableStringValue |
15 | 15 | { |
16 | - /** |
|
17 | - * Constructor. |
|
18 | - * |
|
19 | - * @param string $value String value |
|
20 | - */ |
|
21 | - public function __construct($value) |
|
22 | - { |
|
23 | - $this->_oid = AttributeType::OID_COUNTRY_NAME; |
|
24 | - parent::__construct($value); |
|
25 | - } |
|
16 | + /** |
|
17 | + * Constructor. |
|
18 | + * |
|
19 | + * @param string $value String value |
|
20 | + */ |
|
21 | + public function __construct($value) |
|
22 | + { |
|
23 | + $this->_oid = AttributeType::OID_COUNTRY_NAME; |
|
24 | + parent::__construct($value); |
|
25 | + } |
|
26 | 26 | } |
@@ -13,15 +13,15 @@ |
||
13 | 13 | */ |
14 | 14 | class StateOrProvinceNameValue extends DirectoryString |
15 | 15 | { |
16 | - /** |
|
17 | - * Constructor. |
|
18 | - * |
|
19 | - * @param string $value String value |
|
20 | - * @param int $string_tag Syntax choice |
|
21 | - */ |
|
22 | - public function __construct($value, $string_tag = DirectoryString::UTF8) |
|
23 | - { |
|
24 | - $this->_oid = AttributeType::OID_STATE_OR_PROVINCE_NAME; |
|
25 | - parent::__construct($value, $string_tag); |
|
26 | - } |
|
16 | + /** |
|
17 | + * Constructor. |
|
18 | + * |
|
19 | + * @param string $value String value |
|
20 | + * @param int $string_tag Syntax choice |
|
21 | + */ |
|
22 | + public function __construct($value, $string_tag = DirectoryString::UTF8) |
|
23 | + { |
|
24 | + $this->_oid = AttributeType::OID_STATE_OR_PROVINCE_NAME; |
|
25 | + parent::__construct($value, $string_tag); |
|
26 | + } |
|
27 | 27 | } |
@@ -13,15 +13,15 @@ |
||
13 | 13 | */ |
14 | 14 | class LocalityNameValue extends DirectoryString |
15 | 15 | { |
16 | - /** |
|
17 | - * Constructor. |
|
18 | - * |
|
19 | - * @param string $value String value |
|
20 | - * @param int $string_tag Syntax choice |
|
21 | - */ |
|
22 | - public function __construct($value, $string_tag = DirectoryString::UTF8) |
|
23 | - { |
|
24 | - $this->_oid = AttributeType::OID_LOCALITY_NAME; |
|
25 | - parent::__construct($value, $string_tag); |
|
26 | - } |
|
16 | + /** |
|
17 | + * Constructor. |
|
18 | + * |
|
19 | + * @param string $value String value |
|
20 | + * @param int $string_tag Syntax choice |
|
21 | + */ |
|
22 | + public function __construct($value, $string_tag = DirectoryString::UTF8) |
|
23 | + { |
|
24 | + $this->_oid = AttributeType::OID_LOCALITY_NAME; |
|
25 | + parent::__construct($value, $string_tag); |
|
26 | + } |
|
27 | 27 | } |
@@ -13,15 +13,15 @@ |
||
13 | 13 | */ |
14 | 14 | class OrganizationNameValue extends DirectoryString |
15 | 15 | { |
16 | - /** |
|
17 | - * Constructor. |
|
18 | - * |
|
19 | - * @param string $value String value |
|
20 | - * @param int $string_tag Syntax choice |
|
21 | - */ |
|
22 | - public function __construct($value, $string_tag = DirectoryString::UTF8) |
|
23 | - { |
|
24 | - $this->_oid = AttributeType::OID_ORGANIZATION_NAME; |
|
25 | - parent::__construct($value, $string_tag); |
|
26 | - } |
|
16 | + /** |
|
17 | + * Constructor. |
|
18 | + * |
|
19 | + * @param string $value String value |
|
20 | + * @param int $string_tag Syntax choice |
|
21 | + */ |
|
22 | + public function __construct($value, $string_tag = DirectoryString::UTF8) |
|
23 | + { |
|
24 | + $this->_oid = AttributeType::OID_ORGANIZATION_NAME; |
|
25 | + parent::__construct($value, $string_tag); |
|
26 | + } |
|
27 | 27 | } |
@@ -10,73 +10,73 @@ |
||
10 | 10 | */ |
11 | 11 | class UnknownAttributeValue extends AttributeValue |
12 | 12 | { |
13 | - /** |
|
14 | - * ASN.1 element. |
|
15 | - * |
|
16 | - * @var Element $_element |
|
17 | - */ |
|
18 | - protected $_element; |
|
13 | + /** |
|
14 | + * ASN.1 element. |
|
15 | + * |
|
16 | + * @var Element $_element |
|
17 | + */ |
|
18 | + protected $_element; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Constructor. |
|
22 | - * |
|
23 | - * @param string $oid |
|
24 | - * @param Element $el |
|
25 | - */ |
|
26 | - public function __construct($oid, Element $el) |
|
27 | - { |
|
28 | - $this->_oid = $oid; |
|
29 | - $this->_element = $el; |
|
30 | - } |
|
20 | + /** |
|
21 | + * Constructor. |
|
22 | + * |
|
23 | + * @param string $oid |
|
24 | + * @param Element $el |
|
25 | + */ |
|
26 | + public function __construct($oid, Element $el) |
|
27 | + { |
|
28 | + $this->_oid = $oid; |
|
29 | + $this->_element = $el; |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * |
|
34 | - * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1() |
|
35 | - * @return Element |
|
36 | - */ |
|
37 | - public function toASN1() |
|
38 | - { |
|
39 | - return $this->_element; |
|
40 | - } |
|
32 | + /** |
|
33 | + * |
|
34 | + * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1() |
|
35 | + * @return Element |
|
36 | + */ |
|
37 | + public function toASN1() |
|
38 | + { |
|
39 | + return $this->_element; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * |
|
44 | - * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue() |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function stringValue() |
|
48 | - { |
|
49 | - // return DER encoding as a hexstring |
|
50 | - return "#" . bin2hex($this->_element->toDER()); |
|
51 | - } |
|
42 | + /** |
|
43 | + * |
|
44 | + * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue() |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function stringValue() |
|
48 | + { |
|
49 | + // return DER encoding as a hexstring |
|
50 | + return "#" . bin2hex($this->_element->toDER()); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * |
|
55 | - * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule() |
|
56 | - * @return BinaryMatch |
|
57 | - */ |
|
58 | - public function equalityMatchingRule() |
|
59 | - { |
|
60 | - return new BinaryMatch(); |
|
61 | - } |
|
53 | + /** |
|
54 | + * |
|
55 | + * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule() |
|
56 | + * @return BinaryMatch |
|
57 | + */ |
|
58 | + public function equalityMatchingRule() |
|
59 | + { |
|
60 | + return new BinaryMatch(); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * |
|
65 | - * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String() |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function rfc2253String() |
|
69 | - { |
|
70 | - return $this->stringValue(); |
|
71 | - } |
|
63 | + /** |
|
64 | + * |
|
65 | + * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String() |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function rfc2253String() |
|
69 | + { |
|
70 | + return $this->stringValue(); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * |
|
75 | - * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString() |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - protected function _transcodedString() |
|
79 | - { |
|
80 | - return $this->stringValue(); |
|
81 | - } |
|
73 | + /** |
|
74 | + * |
|
75 | + * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString() |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + protected function _transcodedString() |
|
79 | + { |
|
80 | + return $this->stringValue(); |
|
81 | + } |
|
82 | 82 | } |