@@ -9,12 +9,12 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class BinaryMatch extends MatchingRule |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * |
|
| 14 | - * {@inheritdoc} |
|
| 15 | - */ |
|
| 16 | - public function compare($assertion, $value) |
|
| 17 | - { |
|
| 18 | - return strcmp($assertion, $value) == 0; |
|
| 19 | - } |
|
| 12 | + /** |
|
| 13 | + * |
|
| 14 | + * {@inheritdoc} |
|
| 15 | + */ |
|
| 16 | + public function compare($assertion, $value) |
|
| 17 | + { |
|
| 18 | + return strcmp($assertion, $value) == 0; |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -9,13 +9,13 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | abstract class MatchingRule |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * Compare attribute value to assertion. |
|
| 14 | - * |
|
| 15 | - * @param mixed $assertion Value to assert |
|
| 16 | - * @param mixed $value Attribute value |
|
| 17 | - * @return bool|null True if value matches. Null shall be returned if match |
|
| 18 | - * evaluates to Undefined. |
|
| 19 | - */ |
|
| 20 | - abstract public function compare($assertion, $value); |
|
| 12 | + /** |
|
| 13 | + * Compare attribute value to assertion. |
|
| 14 | + * |
|
| 15 | + * @param mixed $assertion Value to assert |
|
| 16 | + * @param mixed $value Attribute value |
|
| 17 | + * @return bool|null True if value matches. Null shall be returned if match |
|
| 18 | + * evaluates to Undefined. |
|
| 19 | + */ |
|
| 20 | + abstract public function compare($assertion, $value); |
|
| 21 | 21 | } |
@@ -9,31 +9,31 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | abstract class StringPrepMatchingRule extends MatchingRule |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * String preparer. |
|
| 14 | - * |
|
| 15 | - * @var StringPreparer $_prep |
|
| 16 | - */ |
|
| 17 | - protected $_prep; |
|
| 12 | + /** |
|
| 13 | + * String preparer. |
|
| 14 | + * |
|
| 15 | + * @var StringPreparer $_prep |
|
| 16 | + */ |
|
| 17 | + protected $_prep; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Constructor. |
|
| 21 | - * |
|
| 22 | - * @param StringPreparer $preparer |
|
| 23 | - */ |
|
| 24 | - public function __construct(StringPreparer $preparer) |
|
| 25 | - { |
|
| 26 | - $this->_prep = $preparer; |
|
| 27 | - } |
|
| 19 | + /** |
|
| 20 | + * Constructor. |
|
| 21 | + * |
|
| 22 | + * @param StringPreparer $preparer |
|
| 23 | + */ |
|
| 24 | + public function __construct(StringPreparer $preparer) |
|
| 25 | + { |
|
| 26 | + $this->_prep = $preparer; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * |
|
| 31 | - * {@inheritdoc} |
|
| 32 | - */ |
|
| 33 | - public function compare($assertion, $value) |
|
| 34 | - { |
|
| 35 | - $assertion = $this->_prep->prepare($assertion); |
|
| 36 | - $value = $this->_prep->prepare($value); |
|
| 37 | - return strcmp($assertion, $value) == 0; |
|
| 38 | - } |
|
| 29 | + /** |
|
| 30 | + * |
|
| 31 | + * {@inheritdoc} |
|
| 32 | + */ |
|
| 33 | + public function compare($assertion, $value) |
|
| 34 | + { |
|
| 35 | + $assertion = $this->_prep->prepare($assertion); |
|
| 36 | + $value = $this->_prep->prepare($value); |
|
| 37 | + return strcmp($assertion, $value) == 0; |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -40,22 +40,22 @@ |
||
| 40 | 40 | { |
| 41 | 41 | switch ($this->_type) { |
| 42 | 42 | // UTF-8 string as is |
| 43 | - case Element::TYPE_UTF8_STRING: |
|
| 44 | - return $string; |
|
| 45 | - // PrintableString maps directly to UTF-8 |
|
| 46 | - case Element::TYPE_PRINTABLE_STRING: |
|
| 47 | - return $string; |
|
| 48 | - // UCS-2 to UTF-8 |
|
| 49 | - case Element::TYPE_BMP_STRING: |
|
| 50 | - return mb_convert_encoding($string, "UTF-8", "UCS-2BE"); |
|
| 51 | - // UCS-4 to UTF-8 |
|
| 52 | - case Element::TYPE_UNIVERSAL_STRING: |
|
| 53 | - return mb_convert_encoding($string, "UTF-8", "UCS-4BE"); |
|
| 54 | - // TeletexString mapping is a local matter. |
|
| 55 | - // We take a shortcut here and encode it as a hexstring. |
|
| 56 | - case Element::TYPE_T61_STRING: |
|
| 57 | - $el = new T61String($string); |
|
| 58 | - return "#" . bin2hex($el->toDER()); |
|
| 43 | + case Element::TYPE_UTF8_STRING: |
|
| 44 | + return $string; |
|
| 45 | + // PrintableString maps directly to UTF-8 |
|
| 46 | + case Element::TYPE_PRINTABLE_STRING: |
|
| 47 | + return $string; |
|
| 48 | + // UCS-2 to UTF-8 |
|
| 49 | + case Element::TYPE_BMP_STRING: |
|
| 50 | + return mb_convert_encoding($string, "UTF-8", "UCS-2BE"); |
|
| 51 | + // UCS-4 to UTF-8 |
|
| 52 | + case Element::TYPE_UNIVERSAL_STRING: |
|
| 53 | + return mb_convert_encoding($string, "UTF-8", "UCS-4BE"); |
|
| 54 | + // TeletexString mapping is a local matter. |
|
| 55 | + // We take a shortcut here and encode it as a hexstring. |
|
| 56 | + case Element::TYPE_T61_STRING: |
|
| 57 | + $el = new T61String($string); |
|
| 58 | + return "#" . bin2hex($el->toDER()); |
|
| 59 | 59 | } |
| 60 | 60 | throw new \LogicException( |
| 61 | 61 | "Unsupported string type " . Element::tagToName($this->_type) . "."); |
@@ -15,51 +15,51 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class TranscodeStep implements PrepareStep |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * ASN.1 type of the string. |
|
| 20 | - * |
|
| 21 | - * @var int $_type |
|
| 22 | - */ |
|
| 23 | - protected $_type; |
|
| 18 | + /** |
|
| 19 | + * ASN.1 type of the string. |
|
| 20 | + * |
|
| 21 | + * @var int $_type |
|
| 22 | + */ |
|
| 23 | + protected $_type; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Constructor. |
|
| 27 | - * |
|
| 28 | - * @param int $type ASN.1 type tag of the string |
|
| 29 | - */ |
|
| 30 | - public function __construct(int $type) |
|
| 31 | - { |
|
| 32 | - $this->_type = $type; |
|
| 33 | - } |
|
| 25 | + /** |
|
| 26 | + * Constructor. |
|
| 27 | + * |
|
| 28 | + * @param int $type ASN.1 type tag of the string |
|
| 29 | + */ |
|
| 30 | + public function __construct(int $type) |
|
| 31 | + { |
|
| 32 | + $this->_type = $type; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * |
|
| 37 | - * @throws \LogicException If string type is not supported |
|
| 38 | - * @param string $string String to prepare |
|
| 39 | - * @return string UTF-8 encoded string |
|
| 40 | - */ |
|
| 41 | - public function apply(string $string): string |
|
| 42 | - { |
|
| 43 | - switch ($this->_type) { |
|
| 44 | - // UTF-8 string as is |
|
| 45 | - case Element::TYPE_UTF8_STRING: |
|
| 46 | - return $string; |
|
| 47 | - // PrintableString maps directly to UTF-8 |
|
| 48 | - case Element::TYPE_PRINTABLE_STRING: |
|
| 49 | - return $string; |
|
| 50 | - // UCS-2 to UTF-8 |
|
| 51 | - case Element::TYPE_BMP_STRING: |
|
| 52 | - return mb_convert_encoding($string, "UTF-8", "UCS-2BE"); |
|
| 53 | - // UCS-4 to UTF-8 |
|
| 54 | - case Element::TYPE_UNIVERSAL_STRING: |
|
| 55 | - return mb_convert_encoding($string, "UTF-8", "UCS-4BE"); |
|
| 56 | - // TeletexString mapping is a local matter. |
|
| 57 | - // We take a shortcut here and encode it as a hexstring. |
|
| 58 | - case Element::TYPE_T61_STRING: |
|
| 59 | - $el = new T61String($string); |
|
| 60 | - return "#" . bin2hex($el->toDER()); |
|
| 61 | - } |
|
| 62 | - throw new \LogicException( |
|
| 63 | - "Unsupported string type " . Element::tagToName($this->_type) . "."); |
|
| 64 | - } |
|
| 35 | + /** |
|
| 36 | + * |
|
| 37 | + * @throws \LogicException If string type is not supported |
|
| 38 | + * @param string $string String to prepare |
|
| 39 | + * @return string UTF-8 encoded string |
|
| 40 | + */ |
|
| 41 | + public function apply(string $string): string |
|
| 42 | + { |
|
| 43 | + switch ($this->_type) { |
|
| 44 | + // UTF-8 string as is |
|
| 45 | + case Element::TYPE_UTF8_STRING: |
|
| 46 | + return $string; |
|
| 47 | + // PrintableString maps directly to UTF-8 |
|
| 48 | + case Element::TYPE_PRINTABLE_STRING: |
|
| 49 | + return $string; |
|
| 50 | + // UCS-2 to UTF-8 |
|
| 51 | + case Element::TYPE_BMP_STRING: |
|
| 52 | + return mb_convert_encoding($string, "UTF-8", "UCS-2BE"); |
|
| 53 | + // UCS-4 to UTF-8 |
|
| 54 | + case Element::TYPE_UNIVERSAL_STRING: |
|
| 55 | + return mb_convert_encoding($string, "UTF-8", "UCS-4BE"); |
|
| 56 | + // TeletexString mapping is a local matter. |
|
| 57 | + // We take a shortcut here and encode it as a hexstring. |
|
| 58 | + case Element::TYPE_T61_STRING: |
|
| 59 | + $el = new T61String($string); |
|
| 60 | + return "#" . bin2hex($el->toDER()); |
|
| 61 | + } |
|
| 62 | + throw new \LogicException( |
|
| 63 | + "Unsupported string type " . Element::tagToName($this->_type) . "."); |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -441,12 +441,12 @@ |
||
| 441 | 441 | return new UTF8String($str); |
| 442 | 442 | } |
| 443 | 443 | switch (self::MAP_ATTR_TO_STR_TYPE[$oid]) { |
| 444 | - case Element::TYPE_PRINTABLE_STRING: |
|
| 445 | - return new PrintableString($str); |
|
| 446 | - // @codeCoverageIgnoreStart |
|
| 447 | - default: |
|
| 448 | - // only reachable during development |
|
| 449 | - throw new \LogicException(); |
|
| 444 | + case Element::TYPE_PRINTABLE_STRING: |
|
| 445 | + return new PrintableString($str); |
|
| 446 | + // @codeCoverageIgnoreStart |
|
| 447 | + default: |
|
| 448 | + // only reachable during development |
|
| 449 | + throw new \LogicException(); |
|
| 450 | 450 | } |
| 451 | 451 | // @codeCoverageIgnoreEnd |
| 452 | 452 | } |
@@ -18,439 +18,439 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class AttributeType |
| 20 | 20 | { |
| 21 | - // OID's from 2.5.4 arc |
|
| 22 | - const OID_OBJECT_CLASS = "2.5.4.0"; |
|
| 23 | - const OID_ALIASED_ENTRY_NAME = "2.5.4.1"; |
|
| 24 | - const OID_KNOWLEDGE_INFORMATION = "2.5.4.2"; |
|
| 25 | - const OID_COMMON_NAME = "2.5.4.3"; |
|
| 26 | - const OID_SURNAME = "2.5.4.4"; |
|
| 27 | - const OID_SERIAL_NUMBER = "2.5.4.5"; |
|
| 28 | - const OID_COUNTRY_NAME = "2.5.4.6"; |
|
| 29 | - const OID_LOCALITY_NAME = "2.5.4.7"; |
|
| 30 | - const OID_STATE_OR_PROVINCE_NAME = "2.5.4.8"; |
|
| 31 | - const OID_STREET_ADDRESS = "2.5.4.9"; |
|
| 32 | - const OID_ORGANIZATION_NAME = "2.5.4.10"; |
|
| 33 | - const OID_ORGANIZATIONAL_UNIT_NAME = "2.5.4.11"; |
|
| 34 | - const OID_TITLE = "2.5.4.12"; |
|
| 35 | - const OID_DESCRIPTION = "2.5.4.13"; |
|
| 36 | - const OID_SEARCH_GUIDE = "2.5.4.14"; |
|
| 37 | - const OID_BUSINESS_CATEGORY = "2.5.4.15"; |
|
| 38 | - const OID_POSTAL_ADDRESS = "2.5.4.16"; |
|
| 39 | - const OID_POSTAL_CODE = "2.5.4.17"; |
|
| 40 | - const OID_POST_OFFICE_BOX = "2.5.4.18"; |
|
| 41 | - const OID_PHYSICAL_DELIVERY_OFFICE_NAME = "2.5.4.19"; |
|
| 42 | - const OID_TELEPHONE_NUMBER = "2.5.4.20"; |
|
| 43 | - const OID_TELEX_NUMBER = "2.5.4.21"; |
|
| 44 | - const OID_TELETEX_TERMINAL_IDENTIFIER = "2.5.4.22"; |
|
| 45 | - const OID_FACSIMILE_TELEPHONE_NUMBER = "2.5.4.23"; |
|
| 46 | - const OID_X121_ADDRESS = "2.5.4.24"; |
|
| 47 | - const OID_INTERNATIONAL_ISDN_NUMBER = "2.5.4.25"; |
|
| 48 | - const OID_REGISTERED_ADDRESS = "2.5.4.26"; |
|
| 49 | - const OID_DESTINATION_INDICATOR = "2.5.4.27"; |
|
| 50 | - const OID_PREFERRED_DELIVERY_METHOD = "2.5.4.28"; |
|
| 51 | - const OID_PRESENTATION_ADDRESS = "2.5.4.29"; |
|
| 52 | - const OID_SUPPORTED_APPLICATION_CONTEXT = "2.5.4.30"; |
|
| 53 | - const OID_MEMBER = "2.5.4.31"; |
|
| 54 | - const OID_OWNER = "2.5.4.32"; |
|
| 55 | - const OID_ROLE_OCCUPANT = "2.5.4.33"; |
|
| 56 | - const OID_SEE_ALSO = "2.5.4.34"; |
|
| 57 | - const OID_USER_PASSWORD = "2.5.4.35"; |
|
| 58 | - const OID_USER_CERTIFICATE = "2.5.4.36"; |
|
| 59 | - const OID_CA_CERTIFICATE = "2.5.4.37"; |
|
| 60 | - const OID_AUTHORITY_REVOCATION_LIST = "2.5.4.38"; |
|
| 61 | - const OID_CERTIFICATE_REVOCATION_LIST = "2.5.4.39"; |
|
| 62 | - const OID_CROSS_CERTIFICATE_PAIR = "2.5.4.40"; |
|
| 63 | - const OID_NAME = "2.5.4.41"; |
|
| 64 | - const OID_GIVEN_NAME = "2.5.4.42"; |
|
| 65 | - const OID_INITIALS = "2.5.4.43"; |
|
| 66 | - const OID_GENERATION_QUALIFIER = "2.5.4.44"; |
|
| 67 | - const OID_UNIQUE_IDENTIFIER = "2.5.4.45"; |
|
| 68 | - const OID_DN_QUALIFIER = "2.5.4.46"; |
|
| 69 | - const OID_ENHANCED_SEARCH_GUIDE = "2.5.4.47"; |
|
| 70 | - const OID_PROTOCOL_INFORMATION = "2.5.4.48"; |
|
| 71 | - const OID_DISTINGUISHED_NAME = "2.5.4.49"; |
|
| 72 | - const OID_UNIQUE_MEMBER = "2.5.4.50"; |
|
| 73 | - const OID_HOUSE_IDENTIFIER = "2.5.4.51"; |
|
| 74 | - const OID_SUPPORTED_ALGORITHMS = "2.5.4.52"; |
|
| 75 | - const OID_DELTA_REVOCATION_LIST = "2.5.4.53"; |
|
| 76 | - const OID_DMD_NAME = "2.5.4.54"; |
|
| 77 | - const OID_CLEARANCE = "2.5.4.55"; |
|
| 78 | - const OID_DEFAULT_DIR_QOP = "2.5.4.56"; |
|
| 79 | - const OID_ATTRIBUTE_INTEGRITY_INFO = "2.5.4.57"; |
|
| 80 | - const OID_ATTRIBUTE_CERTIFICATE = "2.5.4.58"; |
|
| 81 | - const OID_ATTRIBUTE_CERTIFICATE_REVOCATION_LIST = "2.5.4.59"; |
|
| 82 | - const OID_CONF_KEY_INFO = "2.5.4.60"; |
|
| 83 | - const OID_AA_CERTIFICATE = "2.5.4.61"; |
|
| 84 | - const OID_ATTRIBUTE_DESCRIPTOR_CERTIFICATE = "2.5.4.62"; |
|
| 85 | - const OID_ATTRIBUTE_AUTHORITY_REVOCATION_LIST = "2.5.4.63"; |
|
| 86 | - const OID_FAMILY_INFORMATION = "2.5.4.64"; |
|
| 87 | - const OID_PSEUDONYM = "2.5.4.65"; |
|
| 88 | - const OID_COMMUNICATIONS_SERVICE = "2.5.4.66"; |
|
| 89 | - const OID_COMMUNICATIONS_NETWORK = "2.5.4.67"; |
|
| 90 | - const OID_CERTIFICATION_PRACTICE_STMT = "2.5.4.68"; |
|
| 91 | - const OID_CERTIFICATE_POLICY = "2.5.4.69"; |
|
| 92 | - const OID_PKI_PATH = "2.5.4.70"; |
|
| 93 | - const OID_PRIV_POLICY = "2.5.4.71"; |
|
| 94 | - const OID_ROLE = "2.5.4.72"; |
|
| 95 | - const OID_DELEGATION_PATH = "2.5.4.73"; |
|
| 96 | - const OID_PROT_PRIV_POLICY = "2.5.4.74"; |
|
| 97 | - const OID_XML_PRIVILEGE_INFO = "2.5.4.75"; |
|
| 98 | - const OID_XML_PRIV_POLICY = "2.5.4.76"; |
|
| 99 | - const OID_UUID_PAIR = "2.5.4.77"; |
|
| 100 | - const OID_TAG_OID = "2.5.4.78"; |
|
| 101 | - const OID_UII_FORMAT = "2.5.4.79"; |
|
| 102 | - const OID_UII_IN_URH = "2.5.4.80"; |
|
| 103 | - const OID_CONTENT_URL = "2.5.4.81"; |
|
| 104 | - const OID_PERMISSION = "2.5.4.82"; |
|
| 105 | - const OID_URI = "2.5.4.83"; |
|
| 106 | - const OID_PWD_ATTRIBUTE = "2.5.4.84"; |
|
| 107 | - const OID_USER_PWD = "2.5.4.85"; |
|
| 108 | - const OID_URN = "2.5.4.86"; |
|
| 109 | - const OID_URL = "2.5.4.87"; |
|
| 110 | - const OID_UTM_COORDINATES = "2.5.4.88"; |
|
| 111 | - const OID_URNC = "2.5.4.89"; |
|
| 112 | - const OID_UII = "2.5.4.90"; |
|
| 113 | - const OID_EPC = "2.5.4.91"; |
|
| 114 | - const OID_TAG_AFI = "2.5.4.92"; |
|
| 115 | - const OID_EPC_FORMAT = "2.5.4.93"; |
|
| 116 | - const OID_EPC_IN_URN = "2.5.4.94"; |
|
| 117 | - const OID_LDAP_URL = "2.5.4.95"; |
|
| 118 | - const OID_TAG_LOCATION = "2.5.4.96"; |
|
| 119 | - const OID_ORGANIZATION_IDENTIFIER = "2.5.4.97"; |
|
| 21 | + // OID's from 2.5.4 arc |
|
| 22 | + const OID_OBJECT_CLASS = "2.5.4.0"; |
|
| 23 | + const OID_ALIASED_ENTRY_NAME = "2.5.4.1"; |
|
| 24 | + const OID_KNOWLEDGE_INFORMATION = "2.5.4.2"; |
|
| 25 | + const OID_COMMON_NAME = "2.5.4.3"; |
|
| 26 | + const OID_SURNAME = "2.5.4.4"; |
|
| 27 | + const OID_SERIAL_NUMBER = "2.5.4.5"; |
|
| 28 | + const OID_COUNTRY_NAME = "2.5.4.6"; |
|
| 29 | + const OID_LOCALITY_NAME = "2.5.4.7"; |
|
| 30 | + const OID_STATE_OR_PROVINCE_NAME = "2.5.4.8"; |
|
| 31 | + const OID_STREET_ADDRESS = "2.5.4.9"; |
|
| 32 | + const OID_ORGANIZATION_NAME = "2.5.4.10"; |
|
| 33 | + const OID_ORGANIZATIONAL_UNIT_NAME = "2.5.4.11"; |
|
| 34 | + const OID_TITLE = "2.5.4.12"; |
|
| 35 | + const OID_DESCRIPTION = "2.5.4.13"; |
|
| 36 | + const OID_SEARCH_GUIDE = "2.5.4.14"; |
|
| 37 | + const OID_BUSINESS_CATEGORY = "2.5.4.15"; |
|
| 38 | + const OID_POSTAL_ADDRESS = "2.5.4.16"; |
|
| 39 | + const OID_POSTAL_CODE = "2.5.4.17"; |
|
| 40 | + const OID_POST_OFFICE_BOX = "2.5.4.18"; |
|
| 41 | + const OID_PHYSICAL_DELIVERY_OFFICE_NAME = "2.5.4.19"; |
|
| 42 | + const OID_TELEPHONE_NUMBER = "2.5.4.20"; |
|
| 43 | + const OID_TELEX_NUMBER = "2.5.4.21"; |
|
| 44 | + const OID_TELETEX_TERMINAL_IDENTIFIER = "2.5.4.22"; |
|
| 45 | + const OID_FACSIMILE_TELEPHONE_NUMBER = "2.5.4.23"; |
|
| 46 | + const OID_X121_ADDRESS = "2.5.4.24"; |
|
| 47 | + const OID_INTERNATIONAL_ISDN_NUMBER = "2.5.4.25"; |
|
| 48 | + const OID_REGISTERED_ADDRESS = "2.5.4.26"; |
|
| 49 | + const OID_DESTINATION_INDICATOR = "2.5.4.27"; |
|
| 50 | + const OID_PREFERRED_DELIVERY_METHOD = "2.5.4.28"; |
|
| 51 | + const OID_PRESENTATION_ADDRESS = "2.5.4.29"; |
|
| 52 | + const OID_SUPPORTED_APPLICATION_CONTEXT = "2.5.4.30"; |
|
| 53 | + const OID_MEMBER = "2.5.4.31"; |
|
| 54 | + const OID_OWNER = "2.5.4.32"; |
|
| 55 | + const OID_ROLE_OCCUPANT = "2.5.4.33"; |
|
| 56 | + const OID_SEE_ALSO = "2.5.4.34"; |
|
| 57 | + const OID_USER_PASSWORD = "2.5.4.35"; |
|
| 58 | + const OID_USER_CERTIFICATE = "2.5.4.36"; |
|
| 59 | + const OID_CA_CERTIFICATE = "2.5.4.37"; |
|
| 60 | + const OID_AUTHORITY_REVOCATION_LIST = "2.5.4.38"; |
|
| 61 | + const OID_CERTIFICATE_REVOCATION_LIST = "2.5.4.39"; |
|
| 62 | + const OID_CROSS_CERTIFICATE_PAIR = "2.5.4.40"; |
|
| 63 | + const OID_NAME = "2.5.4.41"; |
|
| 64 | + const OID_GIVEN_NAME = "2.5.4.42"; |
|
| 65 | + const OID_INITIALS = "2.5.4.43"; |
|
| 66 | + const OID_GENERATION_QUALIFIER = "2.5.4.44"; |
|
| 67 | + const OID_UNIQUE_IDENTIFIER = "2.5.4.45"; |
|
| 68 | + const OID_DN_QUALIFIER = "2.5.4.46"; |
|
| 69 | + const OID_ENHANCED_SEARCH_GUIDE = "2.5.4.47"; |
|
| 70 | + const OID_PROTOCOL_INFORMATION = "2.5.4.48"; |
|
| 71 | + const OID_DISTINGUISHED_NAME = "2.5.4.49"; |
|
| 72 | + const OID_UNIQUE_MEMBER = "2.5.4.50"; |
|
| 73 | + const OID_HOUSE_IDENTIFIER = "2.5.4.51"; |
|
| 74 | + const OID_SUPPORTED_ALGORITHMS = "2.5.4.52"; |
|
| 75 | + const OID_DELTA_REVOCATION_LIST = "2.5.4.53"; |
|
| 76 | + const OID_DMD_NAME = "2.5.4.54"; |
|
| 77 | + const OID_CLEARANCE = "2.5.4.55"; |
|
| 78 | + const OID_DEFAULT_DIR_QOP = "2.5.4.56"; |
|
| 79 | + const OID_ATTRIBUTE_INTEGRITY_INFO = "2.5.4.57"; |
|
| 80 | + const OID_ATTRIBUTE_CERTIFICATE = "2.5.4.58"; |
|
| 81 | + const OID_ATTRIBUTE_CERTIFICATE_REVOCATION_LIST = "2.5.4.59"; |
|
| 82 | + const OID_CONF_KEY_INFO = "2.5.4.60"; |
|
| 83 | + const OID_AA_CERTIFICATE = "2.5.4.61"; |
|
| 84 | + const OID_ATTRIBUTE_DESCRIPTOR_CERTIFICATE = "2.5.4.62"; |
|
| 85 | + const OID_ATTRIBUTE_AUTHORITY_REVOCATION_LIST = "2.5.4.63"; |
|
| 86 | + const OID_FAMILY_INFORMATION = "2.5.4.64"; |
|
| 87 | + const OID_PSEUDONYM = "2.5.4.65"; |
|
| 88 | + const OID_COMMUNICATIONS_SERVICE = "2.5.4.66"; |
|
| 89 | + const OID_COMMUNICATIONS_NETWORK = "2.5.4.67"; |
|
| 90 | + const OID_CERTIFICATION_PRACTICE_STMT = "2.5.4.68"; |
|
| 91 | + const OID_CERTIFICATE_POLICY = "2.5.4.69"; |
|
| 92 | + const OID_PKI_PATH = "2.5.4.70"; |
|
| 93 | + const OID_PRIV_POLICY = "2.5.4.71"; |
|
| 94 | + const OID_ROLE = "2.5.4.72"; |
|
| 95 | + const OID_DELEGATION_PATH = "2.5.4.73"; |
|
| 96 | + const OID_PROT_PRIV_POLICY = "2.5.4.74"; |
|
| 97 | + const OID_XML_PRIVILEGE_INFO = "2.5.4.75"; |
|
| 98 | + const OID_XML_PRIV_POLICY = "2.5.4.76"; |
|
| 99 | + const OID_UUID_PAIR = "2.5.4.77"; |
|
| 100 | + const OID_TAG_OID = "2.5.4.78"; |
|
| 101 | + const OID_UII_FORMAT = "2.5.4.79"; |
|
| 102 | + const OID_UII_IN_URH = "2.5.4.80"; |
|
| 103 | + const OID_CONTENT_URL = "2.5.4.81"; |
|
| 104 | + const OID_PERMISSION = "2.5.4.82"; |
|
| 105 | + const OID_URI = "2.5.4.83"; |
|
| 106 | + const OID_PWD_ATTRIBUTE = "2.5.4.84"; |
|
| 107 | + const OID_USER_PWD = "2.5.4.85"; |
|
| 108 | + const OID_URN = "2.5.4.86"; |
|
| 109 | + const OID_URL = "2.5.4.87"; |
|
| 110 | + const OID_UTM_COORDINATES = "2.5.4.88"; |
|
| 111 | + const OID_URNC = "2.5.4.89"; |
|
| 112 | + const OID_UII = "2.5.4.90"; |
|
| 113 | + const OID_EPC = "2.5.4.91"; |
|
| 114 | + const OID_TAG_AFI = "2.5.4.92"; |
|
| 115 | + const OID_EPC_FORMAT = "2.5.4.93"; |
|
| 116 | + const OID_EPC_IN_URN = "2.5.4.94"; |
|
| 117 | + const OID_LDAP_URL = "2.5.4.95"; |
|
| 118 | + const OID_TAG_LOCATION = "2.5.4.96"; |
|
| 119 | + const OID_ORGANIZATION_IDENTIFIER = "2.5.4.97"; |
|
| 120 | 120 | |
| 121 | - // Miscellany attribute OID's |
|
| 122 | - const OID_CLEARANCE_X501 = "2.5.1.5.55"; |
|
| 121 | + // Miscellany attribute OID's |
|
| 122 | + const OID_CLEARANCE_X501 = "2.5.1.5.55"; |
|
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * Default ASN.1 string types for attributes. |
|
| 126 | - * |
|
| 127 | - * Attributes not mapped here shall use UTF8String as a default type. |
|
| 128 | - * |
|
| 129 | - * @internal |
|
| 130 | - * |
|
| 131 | - * @var array |
|
| 132 | - */ |
|
| 133 | - const MAP_ATTR_TO_STR_TYPE = array( |
|
| 134 | - /* @formatter:off */ |
|
| 135 | - self::OID_DN_QUALIFIER => Element::TYPE_PRINTABLE_STRING, |
|
| 136 | - self::OID_COUNTRY_NAME => Element::TYPE_PRINTABLE_STRING, |
|
| 137 | - self::OID_SERIAL_NUMBER => Element::TYPE_PRINTABLE_STRING |
|
| 138 | - /* @formatter:on */ |
|
| 139 | - ); |
|
| 124 | + /** |
|
| 125 | + * Default ASN.1 string types for attributes. |
|
| 126 | + * |
|
| 127 | + * Attributes not mapped here shall use UTF8String as a default type. |
|
| 128 | + * |
|
| 129 | + * @internal |
|
| 130 | + * |
|
| 131 | + * @var array |
|
| 132 | + */ |
|
| 133 | + const MAP_ATTR_TO_STR_TYPE = array( |
|
| 134 | + /* @formatter:off */ |
|
| 135 | + self::OID_DN_QUALIFIER => Element::TYPE_PRINTABLE_STRING, |
|
| 136 | + self::OID_COUNTRY_NAME => Element::TYPE_PRINTABLE_STRING, |
|
| 137 | + self::OID_SERIAL_NUMBER => Element::TYPE_PRINTABLE_STRING |
|
| 138 | + /* @formatter:on */ |
|
| 139 | + ); |
|
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * OID to attribute names mapping. |
|
| 143 | - * |
|
| 144 | - * First name is the primary name. If there's more than one name, others may |
|
| 145 | - * be used as an alias. |
|
| 146 | - * |
|
| 147 | - * Generated using ldap-attribs.py. |
|
| 148 | - * |
|
| 149 | - * @internal |
|
| 150 | - * |
|
| 151 | - * @var array |
|
| 152 | - */ |
|
| 153 | - const MAP_OID_TO_NAME = array( |
|
| 154 | - /* @formatter:off */ |
|
| 155 | - "0.9.2342.19200300.100.1.1" => ["uid", "userid"], |
|
| 156 | - "0.9.2342.19200300.100.1.2" => ["textEncodedORAddress"], |
|
| 157 | - "0.9.2342.19200300.100.1.3" => ["mail", "rfc822Mailbox"], |
|
| 158 | - "0.9.2342.19200300.100.1.4" => ["info"], |
|
| 159 | - "0.9.2342.19200300.100.1.5" => ["drink", "favouriteDrink"], |
|
| 160 | - "0.9.2342.19200300.100.1.6" => ["roomNumber"], |
|
| 161 | - "0.9.2342.19200300.100.1.7" => ["photo"], |
|
| 162 | - "0.9.2342.19200300.100.1.8" => ["userClass"], |
|
| 163 | - "0.9.2342.19200300.100.1.9" => ["host"], |
|
| 164 | - "0.9.2342.19200300.100.1.10" => ["manager"], |
|
| 165 | - "0.9.2342.19200300.100.1.11" => ["documentIdentifier"], |
|
| 166 | - "0.9.2342.19200300.100.1.12" => ["documentTitle"], |
|
| 167 | - "0.9.2342.19200300.100.1.13" => ["documentVersion"], |
|
| 168 | - "0.9.2342.19200300.100.1.14" => ["documentAuthor"], |
|
| 169 | - "0.9.2342.19200300.100.1.15" => ["documentLocation"], |
|
| 170 | - "0.9.2342.19200300.100.1.20" => ["homePhone", "homeTelephoneNumber"], |
|
| 171 | - "0.9.2342.19200300.100.1.21" => ["secretary"], |
|
| 172 | - "0.9.2342.19200300.100.1.22" => ["otherMailbox"], |
|
| 173 | - "0.9.2342.19200300.100.1.25" => ["dc", "domainComponent"], |
|
| 174 | - "0.9.2342.19200300.100.1.26" => ["aRecord"], |
|
| 175 | - "0.9.2342.19200300.100.1.27" => ["mDRecord"], |
|
| 176 | - "0.9.2342.19200300.100.1.28" => ["mXRecord"], |
|
| 177 | - "0.9.2342.19200300.100.1.29" => ["nSRecord"], |
|
| 178 | - "0.9.2342.19200300.100.1.30" => ["sOARecord"], |
|
| 179 | - "0.9.2342.19200300.100.1.31" => ["cNAMERecord"], |
|
| 180 | - "0.9.2342.19200300.100.1.37" => ["associatedDomain"], |
|
| 181 | - "0.9.2342.19200300.100.1.38" => ["associatedName"], |
|
| 182 | - "0.9.2342.19200300.100.1.39" => ["homePostalAddress"], |
|
| 183 | - "0.9.2342.19200300.100.1.40" => ["personalTitle"], |
|
| 184 | - "0.9.2342.19200300.100.1.41" => ["mobile", "mobileTelephoneNumber"], |
|
| 185 | - "0.9.2342.19200300.100.1.42" => ["pager", "pagerTelephoneNumber"], |
|
| 186 | - "0.9.2342.19200300.100.1.43" => ["co", "friendlyCountryName"], |
|
| 187 | - "0.9.2342.19200300.100.1.44" => ["uniqueIdentifier"], |
|
| 188 | - "0.9.2342.19200300.100.1.45" => ["organizationalStatus"], |
|
| 189 | - "0.9.2342.19200300.100.1.46" => ["janetMailbox"], |
|
| 190 | - "0.9.2342.19200300.100.1.47" => ["mailPreferenceOption"], |
|
| 191 | - "0.9.2342.19200300.100.1.48" => ["buildingName"], |
|
| 192 | - "0.9.2342.19200300.100.1.49" => ["dSAQuality"], |
|
| 193 | - "0.9.2342.19200300.100.1.50" => ["singleLevelQuality"], |
|
| 194 | - "0.9.2342.19200300.100.1.51" => ["subtreeMinimumQuality"], |
|
| 195 | - "0.9.2342.19200300.100.1.52" => ["subtreeMaximumQuality"], |
|
| 196 | - "0.9.2342.19200300.100.1.53" => ["personalSignature"], |
|
| 197 | - "0.9.2342.19200300.100.1.54" => ["dITRedirect"], |
|
| 198 | - "0.9.2342.19200300.100.1.55" => ["audio"], |
|
| 199 | - "0.9.2342.19200300.100.1.56" => ["documentPublisher"], |
|
| 200 | - "0.9.2342.19200300.100.1.60" => ["jpegPhoto"], |
|
| 201 | - "1.2.840.113549.1.9.1" => ["email", "emailAddress", "pkcs9email"], |
|
| 202 | - "1.2.840.113556.1.2.102" => ["memberOf"], |
|
| 203 | - "1.3.6.1.1.1.1.0" => ["uidNumber"], |
|
| 204 | - "1.3.6.1.1.1.1.1" => ["gidNumber"], |
|
| 205 | - "1.3.6.1.1.1.1.2" => ["gecos"], |
|
| 206 | - "1.3.6.1.1.1.1.3" => ["homeDirectory"], |
|
| 207 | - "1.3.6.1.1.1.1.4" => ["loginShell"], |
|
| 208 | - "1.3.6.1.1.1.1.5" => ["shadowLastChange"], |
|
| 209 | - "1.3.6.1.1.1.1.6" => ["shadowMin"], |
|
| 210 | - "1.3.6.1.1.1.1.7" => ["shadowMax"], |
|
| 211 | - "1.3.6.1.1.1.1.8" => ["shadowWarning"], |
|
| 212 | - "1.3.6.1.1.1.1.9" => ["shadowInactive"], |
|
| 213 | - "1.3.6.1.1.1.1.10" => ["shadowExpire"], |
|
| 214 | - "1.3.6.1.1.1.1.11" => ["shadowFlag"], |
|
| 215 | - "1.3.6.1.1.1.1.12" => ["memberUid"], |
|
| 216 | - "1.3.6.1.1.1.1.13" => ["memberNisNetgroup"], |
|
| 217 | - "1.3.6.1.1.1.1.14" => ["nisNetgroupTriple"], |
|
| 218 | - "1.3.6.1.1.1.1.15" => ["ipServicePort"], |
|
| 219 | - "1.3.6.1.1.1.1.16" => ["ipServiceProtocol"], |
|
| 220 | - "1.3.6.1.1.1.1.17" => ["ipProtocolNumber"], |
|
| 221 | - "1.3.6.1.1.1.1.18" => ["oncRpcNumber"], |
|
| 222 | - "1.3.6.1.1.1.1.19" => ["ipHostNumber"], |
|
| 223 | - "1.3.6.1.1.1.1.20" => ["ipNetworkNumber"], |
|
| 224 | - "1.3.6.1.1.1.1.21" => ["ipNetmaskNumber"], |
|
| 225 | - "1.3.6.1.1.1.1.22" => ["macAddress"], |
|
| 226 | - "1.3.6.1.1.1.1.23" => ["bootParameter"], |
|
| 227 | - "1.3.6.1.1.1.1.24" => ["bootFile"], |
|
| 228 | - "1.3.6.1.1.1.1.26" => ["nisMapName"], |
|
| 229 | - "1.3.6.1.1.1.1.27" => ["nisMapEntry"], |
|
| 230 | - "1.3.6.1.1.4" => ["vendorName"], |
|
| 231 | - "1.3.6.1.1.5" => ["vendorVersion"], |
|
| 232 | - "1.3.6.1.1.16.4" => ["entryUUID"], |
|
| 233 | - "1.3.6.1.1.20" => ["entryDN"], |
|
| 234 | - "2.5.4.0" => ["objectClass"], |
|
| 235 | - "2.5.4.1" => ["aliasedObjectName", "aliasedEntryName"], |
|
| 236 | - "2.5.4.2" => ["knowledgeInformation"], |
|
| 237 | - "2.5.4.3" => ["cn", "commonName"], |
|
| 238 | - "2.5.4.4" => ["sn", "surname"], |
|
| 239 | - "2.5.4.5" => ["serialNumber"], |
|
| 240 | - "2.5.4.6" => ["c", "countryName"], |
|
| 241 | - "2.5.4.7" => ["l", "localityName"], |
|
| 242 | - "2.5.4.8" => ["st", "stateOrProvinceName"], |
|
| 243 | - "2.5.4.9" => ["street", "streetAddress"], |
|
| 244 | - "2.5.4.10" => ["o", "organizationName"], |
|
| 245 | - "2.5.4.11" => ["ou", "organizationalUnitName"], |
|
| 246 | - "2.5.4.12" => ["title"], |
|
| 247 | - "2.5.4.13" => ["description"], |
|
| 248 | - "2.5.4.14" => ["searchGuide"], |
|
| 249 | - "2.5.4.15" => ["businessCategory"], |
|
| 250 | - "2.5.4.16" => ["postalAddress"], |
|
| 251 | - "2.5.4.17" => ["postalCode"], |
|
| 252 | - "2.5.4.18" => ["postOfficeBox"], |
|
| 253 | - "2.5.4.19" => ["physicalDeliveryOfficeName"], |
|
| 254 | - "2.5.4.20" => ["telephoneNumber"], |
|
| 255 | - "2.5.4.21" => ["telexNumber"], |
|
| 256 | - "2.5.4.22" => ["teletexTerminalIdentifier"], |
|
| 257 | - "2.5.4.23" => ["facsimileTelephoneNumber", "fax"], |
|
| 258 | - "2.5.4.24" => ["x121Address"], |
|
| 259 | - "2.5.4.25" => ["internationaliSDNNumber"], |
|
| 260 | - "2.5.4.26" => ["registeredAddress"], |
|
| 261 | - "2.5.4.27" => ["destinationIndicator"], |
|
| 262 | - "2.5.4.28" => ["preferredDeliveryMethod"], |
|
| 263 | - "2.5.4.29" => ["presentationAddress"], |
|
| 264 | - "2.5.4.30" => ["supportedApplicationContext"], |
|
| 265 | - "2.5.4.31" => ["member"], |
|
| 266 | - "2.5.4.32" => ["owner"], |
|
| 267 | - "2.5.4.33" => ["roleOccupant"], |
|
| 268 | - "2.5.4.34" => ["seeAlso"], |
|
| 269 | - "2.5.4.35" => ["userPassword"], |
|
| 270 | - "2.5.4.36" => ["userCertificate"], |
|
| 271 | - "2.5.4.37" => ["cACertificate"], |
|
| 272 | - "2.5.4.38" => ["authorityRevocationList"], |
|
| 273 | - "2.5.4.39" => ["certificateRevocationList"], |
|
| 274 | - "2.5.4.40" => ["crossCertificatePair"], |
|
| 275 | - "2.5.4.41" => ["name"], |
|
| 276 | - "2.5.4.42" => ["givenName", "gn"], |
|
| 277 | - "2.5.4.43" => ["initials"], |
|
| 278 | - "2.5.4.44" => ["generationQualifier"], |
|
| 279 | - "2.5.4.45" => ["x500UniqueIdentifier"], |
|
| 280 | - "2.5.4.46" => ["dnQualifier"], |
|
| 281 | - "2.5.4.47" => ["enhancedSearchGuide"], |
|
| 282 | - "2.5.4.48" => ["protocolInformation"], |
|
| 283 | - "2.5.4.49" => ["distinguishedName"], |
|
| 284 | - "2.5.4.50" => ["uniqueMember"], |
|
| 285 | - "2.5.4.51" => ["houseIdentifier"], |
|
| 286 | - "2.5.4.52" => ["supportedAlgorithms"], |
|
| 287 | - "2.5.4.53" => ["deltaRevocationList"], |
|
| 288 | - "2.5.4.54" => ["dmdName"], |
|
| 289 | - "2.5.4.65" => ["pseudonym"], |
|
| 290 | - "2.5.18.1" => ["createTimestamp"], |
|
| 291 | - "2.5.18.2" => ["modifyTimestamp"], |
|
| 292 | - "2.5.18.3" => ["creatorsName"], |
|
| 293 | - "2.5.18.4" => ["modifiersName"], |
|
| 294 | - "2.5.18.5" => ["administrativeRole"], |
|
| 295 | - "2.5.18.6" => ["subtreeSpecification"], |
|
| 296 | - "2.5.18.9" => ["hasSubordinates"], |
|
| 297 | - "2.5.18.10" => ["subschemaSubentry"], |
|
| 298 | - "2.5.21.1" => ["dITStructureRules"], |
|
| 299 | - "2.5.21.2" => ["dITContentRules"], |
|
| 300 | - "2.5.21.4" => ["matchingRules"], |
|
| 301 | - "2.5.21.5" => ["attributeTypes"], |
|
| 302 | - "2.5.21.6" => ["objectClasses"], |
|
| 303 | - "2.5.21.7" => ["nameForms"], |
|
| 304 | - "2.5.21.8" => ["matchingRuleUse"], |
|
| 305 | - "2.5.21.9" => ["structuralObjectClass"], |
|
| 306 | - "2.16.840.1.113730.3.1.1" => ["carLicense"], |
|
| 307 | - "2.16.840.1.113730.3.1.2" => ["departmentNumber"], |
|
| 308 | - "2.16.840.1.113730.3.1.3" => ["employeeNumber"], |
|
| 309 | - "2.16.840.1.113730.3.1.4" => ["employeeType"], |
|
| 310 | - "2.16.840.1.113730.3.1.34" => ["ref"], |
|
| 311 | - "2.16.840.1.113730.3.1.39" => ["preferredLanguage"], |
|
| 312 | - "2.16.840.1.113730.3.1.40" => ["userSMIMECertificate"], |
|
| 313 | - "2.16.840.1.113730.3.1.216" => ["userPKCS12"], |
|
| 314 | - "2.16.840.1.113730.3.1.241" => ["displayName"] |
|
| 315 | - /* @formatter:on */ |
|
| 316 | - ); |
|
| 141 | + /** |
|
| 142 | + * OID to attribute names mapping. |
|
| 143 | + * |
|
| 144 | + * First name is the primary name. If there's more than one name, others may |
|
| 145 | + * be used as an alias. |
|
| 146 | + * |
|
| 147 | + * Generated using ldap-attribs.py. |
|
| 148 | + * |
|
| 149 | + * @internal |
|
| 150 | + * |
|
| 151 | + * @var array |
|
| 152 | + */ |
|
| 153 | + const MAP_OID_TO_NAME = array( |
|
| 154 | + /* @formatter:off */ |
|
| 155 | + "0.9.2342.19200300.100.1.1" => ["uid", "userid"], |
|
| 156 | + "0.9.2342.19200300.100.1.2" => ["textEncodedORAddress"], |
|
| 157 | + "0.9.2342.19200300.100.1.3" => ["mail", "rfc822Mailbox"], |
|
| 158 | + "0.9.2342.19200300.100.1.4" => ["info"], |
|
| 159 | + "0.9.2342.19200300.100.1.5" => ["drink", "favouriteDrink"], |
|
| 160 | + "0.9.2342.19200300.100.1.6" => ["roomNumber"], |
|
| 161 | + "0.9.2342.19200300.100.1.7" => ["photo"], |
|
| 162 | + "0.9.2342.19200300.100.1.8" => ["userClass"], |
|
| 163 | + "0.9.2342.19200300.100.1.9" => ["host"], |
|
| 164 | + "0.9.2342.19200300.100.1.10" => ["manager"], |
|
| 165 | + "0.9.2342.19200300.100.1.11" => ["documentIdentifier"], |
|
| 166 | + "0.9.2342.19200300.100.1.12" => ["documentTitle"], |
|
| 167 | + "0.9.2342.19200300.100.1.13" => ["documentVersion"], |
|
| 168 | + "0.9.2342.19200300.100.1.14" => ["documentAuthor"], |
|
| 169 | + "0.9.2342.19200300.100.1.15" => ["documentLocation"], |
|
| 170 | + "0.9.2342.19200300.100.1.20" => ["homePhone", "homeTelephoneNumber"], |
|
| 171 | + "0.9.2342.19200300.100.1.21" => ["secretary"], |
|
| 172 | + "0.9.2342.19200300.100.1.22" => ["otherMailbox"], |
|
| 173 | + "0.9.2342.19200300.100.1.25" => ["dc", "domainComponent"], |
|
| 174 | + "0.9.2342.19200300.100.1.26" => ["aRecord"], |
|
| 175 | + "0.9.2342.19200300.100.1.27" => ["mDRecord"], |
|
| 176 | + "0.9.2342.19200300.100.1.28" => ["mXRecord"], |
|
| 177 | + "0.9.2342.19200300.100.1.29" => ["nSRecord"], |
|
| 178 | + "0.9.2342.19200300.100.1.30" => ["sOARecord"], |
|
| 179 | + "0.9.2342.19200300.100.1.31" => ["cNAMERecord"], |
|
| 180 | + "0.9.2342.19200300.100.1.37" => ["associatedDomain"], |
|
| 181 | + "0.9.2342.19200300.100.1.38" => ["associatedName"], |
|
| 182 | + "0.9.2342.19200300.100.1.39" => ["homePostalAddress"], |
|
| 183 | + "0.9.2342.19200300.100.1.40" => ["personalTitle"], |
|
| 184 | + "0.9.2342.19200300.100.1.41" => ["mobile", "mobileTelephoneNumber"], |
|
| 185 | + "0.9.2342.19200300.100.1.42" => ["pager", "pagerTelephoneNumber"], |
|
| 186 | + "0.9.2342.19200300.100.1.43" => ["co", "friendlyCountryName"], |
|
| 187 | + "0.9.2342.19200300.100.1.44" => ["uniqueIdentifier"], |
|
| 188 | + "0.9.2342.19200300.100.1.45" => ["organizationalStatus"], |
|
| 189 | + "0.9.2342.19200300.100.1.46" => ["janetMailbox"], |
|
| 190 | + "0.9.2342.19200300.100.1.47" => ["mailPreferenceOption"], |
|
| 191 | + "0.9.2342.19200300.100.1.48" => ["buildingName"], |
|
| 192 | + "0.9.2342.19200300.100.1.49" => ["dSAQuality"], |
|
| 193 | + "0.9.2342.19200300.100.1.50" => ["singleLevelQuality"], |
|
| 194 | + "0.9.2342.19200300.100.1.51" => ["subtreeMinimumQuality"], |
|
| 195 | + "0.9.2342.19200300.100.1.52" => ["subtreeMaximumQuality"], |
|
| 196 | + "0.9.2342.19200300.100.1.53" => ["personalSignature"], |
|
| 197 | + "0.9.2342.19200300.100.1.54" => ["dITRedirect"], |
|
| 198 | + "0.9.2342.19200300.100.1.55" => ["audio"], |
|
| 199 | + "0.9.2342.19200300.100.1.56" => ["documentPublisher"], |
|
| 200 | + "0.9.2342.19200300.100.1.60" => ["jpegPhoto"], |
|
| 201 | + "1.2.840.113549.1.9.1" => ["email", "emailAddress", "pkcs9email"], |
|
| 202 | + "1.2.840.113556.1.2.102" => ["memberOf"], |
|
| 203 | + "1.3.6.1.1.1.1.0" => ["uidNumber"], |
|
| 204 | + "1.3.6.1.1.1.1.1" => ["gidNumber"], |
|
| 205 | + "1.3.6.1.1.1.1.2" => ["gecos"], |
|
| 206 | + "1.3.6.1.1.1.1.3" => ["homeDirectory"], |
|
| 207 | + "1.3.6.1.1.1.1.4" => ["loginShell"], |
|
| 208 | + "1.3.6.1.1.1.1.5" => ["shadowLastChange"], |
|
| 209 | + "1.3.6.1.1.1.1.6" => ["shadowMin"], |
|
| 210 | + "1.3.6.1.1.1.1.7" => ["shadowMax"], |
|
| 211 | + "1.3.6.1.1.1.1.8" => ["shadowWarning"], |
|
| 212 | + "1.3.6.1.1.1.1.9" => ["shadowInactive"], |
|
| 213 | + "1.3.6.1.1.1.1.10" => ["shadowExpire"], |
|
| 214 | + "1.3.6.1.1.1.1.11" => ["shadowFlag"], |
|
| 215 | + "1.3.6.1.1.1.1.12" => ["memberUid"], |
|
| 216 | + "1.3.6.1.1.1.1.13" => ["memberNisNetgroup"], |
|
| 217 | + "1.3.6.1.1.1.1.14" => ["nisNetgroupTriple"], |
|
| 218 | + "1.3.6.1.1.1.1.15" => ["ipServicePort"], |
|
| 219 | + "1.3.6.1.1.1.1.16" => ["ipServiceProtocol"], |
|
| 220 | + "1.3.6.1.1.1.1.17" => ["ipProtocolNumber"], |
|
| 221 | + "1.3.6.1.1.1.1.18" => ["oncRpcNumber"], |
|
| 222 | + "1.3.6.1.1.1.1.19" => ["ipHostNumber"], |
|
| 223 | + "1.3.6.1.1.1.1.20" => ["ipNetworkNumber"], |
|
| 224 | + "1.3.6.1.1.1.1.21" => ["ipNetmaskNumber"], |
|
| 225 | + "1.3.6.1.1.1.1.22" => ["macAddress"], |
|
| 226 | + "1.3.6.1.1.1.1.23" => ["bootParameter"], |
|
| 227 | + "1.3.6.1.1.1.1.24" => ["bootFile"], |
|
| 228 | + "1.3.6.1.1.1.1.26" => ["nisMapName"], |
|
| 229 | + "1.3.6.1.1.1.1.27" => ["nisMapEntry"], |
|
| 230 | + "1.3.6.1.1.4" => ["vendorName"], |
|
| 231 | + "1.3.6.1.1.5" => ["vendorVersion"], |
|
| 232 | + "1.3.6.1.1.16.4" => ["entryUUID"], |
|
| 233 | + "1.3.6.1.1.20" => ["entryDN"], |
|
| 234 | + "2.5.4.0" => ["objectClass"], |
|
| 235 | + "2.5.4.1" => ["aliasedObjectName", "aliasedEntryName"], |
|
| 236 | + "2.5.4.2" => ["knowledgeInformation"], |
|
| 237 | + "2.5.4.3" => ["cn", "commonName"], |
|
| 238 | + "2.5.4.4" => ["sn", "surname"], |
|
| 239 | + "2.5.4.5" => ["serialNumber"], |
|
| 240 | + "2.5.4.6" => ["c", "countryName"], |
|
| 241 | + "2.5.4.7" => ["l", "localityName"], |
|
| 242 | + "2.5.4.8" => ["st", "stateOrProvinceName"], |
|
| 243 | + "2.5.4.9" => ["street", "streetAddress"], |
|
| 244 | + "2.5.4.10" => ["o", "organizationName"], |
|
| 245 | + "2.5.4.11" => ["ou", "organizationalUnitName"], |
|
| 246 | + "2.5.4.12" => ["title"], |
|
| 247 | + "2.5.4.13" => ["description"], |
|
| 248 | + "2.5.4.14" => ["searchGuide"], |
|
| 249 | + "2.5.4.15" => ["businessCategory"], |
|
| 250 | + "2.5.4.16" => ["postalAddress"], |
|
| 251 | + "2.5.4.17" => ["postalCode"], |
|
| 252 | + "2.5.4.18" => ["postOfficeBox"], |
|
| 253 | + "2.5.4.19" => ["physicalDeliveryOfficeName"], |
|
| 254 | + "2.5.4.20" => ["telephoneNumber"], |
|
| 255 | + "2.5.4.21" => ["telexNumber"], |
|
| 256 | + "2.5.4.22" => ["teletexTerminalIdentifier"], |
|
| 257 | + "2.5.4.23" => ["facsimileTelephoneNumber", "fax"], |
|
| 258 | + "2.5.4.24" => ["x121Address"], |
|
| 259 | + "2.5.4.25" => ["internationaliSDNNumber"], |
|
| 260 | + "2.5.4.26" => ["registeredAddress"], |
|
| 261 | + "2.5.4.27" => ["destinationIndicator"], |
|
| 262 | + "2.5.4.28" => ["preferredDeliveryMethod"], |
|
| 263 | + "2.5.4.29" => ["presentationAddress"], |
|
| 264 | + "2.5.4.30" => ["supportedApplicationContext"], |
|
| 265 | + "2.5.4.31" => ["member"], |
|
| 266 | + "2.5.4.32" => ["owner"], |
|
| 267 | + "2.5.4.33" => ["roleOccupant"], |
|
| 268 | + "2.5.4.34" => ["seeAlso"], |
|
| 269 | + "2.5.4.35" => ["userPassword"], |
|
| 270 | + "2.5.4.36" => ["userCertificate"], |
|
| 271 | + "2.5.4.37" => ["cACertificate"], |
|
| 272 | + "2.5.4.38" => ["authorityRevocationList"], |
|
| 273 | + "2.5.4.39" => ["certificateRevocationList"], |
|
| 274 | + "2.5.4.40" => ["crossCertificatePair"], |
|
| 275 | + "2.5.4.41" => ["name"], |
|
| 276 | + "2.5.4.42" => ["givenName", "gn"], |
|
| 277 | + "2.5.4.43" => ["initials"], |
|
| 278 | + "2.5.4.44" => ["generationQualifier"], |
|
| 279 | + "2.5.4.45" => ["x500UniqueIdentifier"], |
|
| 280 | + "2.5.4.46" => ["dnQualifier"], |
|
| 281 | + "2.5.4.47" => ["enhancedSearchGuide"], |
|
| 282 | + "2.5.4.48" => ["protocolInformation"], |
|
| 283 | + "2.5.4.49" => ["distinguishedName"], |
|
| 284 | + "2.5.4.50" => ["uniqueMember"], |
|
| 285 | + "2.5.4.51" => ["houseIdentifier"], |
|
| 286 | + "2.5.4.52" => ["supportedAlgorithms"], |
|
| 287 | + "2.5.4.53" => ["deltaRevocationList"], |
|
| 288 | + "2.5.4.54" => ["dmdName"], |
|
| 289 | + "2.5.4.65" => ["pseudonym"], |
|
| 290 | + "2.5.18.1" => ["createTimestamp"], |
|
| 291 | + "2.5.18.2" => ["modifyTimestamp"], |
|
| 292 | + "2.5.18.3" => ["creatorsName"], |
|
| 293 | + "2.5.18.4" => ["modifiersName"], |
|
| 294 | + "2.5.18.5" => ["administrativeRole"], |
|
| 295 | + "2.5.18.6" => ["subtreeSpecification"], |
|
| 296 | + "2.5.18.9" => ["hasSubordinates"], |
|
| 297 | + "2.5.18.10" => ["subschemaSubentry"], |
|
| 298 | + "2.5.21.1" => ["dITStructureRules"], |
|
| 299 | + "2.5.21.2" => ["dITContentRules"], |
|
| 300 | + "2.5.21.4" => ["matchingRules"], |
|
| 301 | + "2.5.21.5" => ["attributeTypes"], |
|
| 302 | + "2.5.21.6" => ["objectClasses"], |
|
| 303 | + "2.5.21.7" => ["nameForms"], |
|
| 304 | + "2.5.21.8" => ["matchingRuleUse"], |
|
| 305 | + "2.5.21.9" => ["structuralObjectClass"], |
|
| 306 | + "2.16.840.1.113730.3.1.1" => ["carLicense"], |
|
| 307 | + "2.16.840.1.113730.3.1.2" => ["departmentNumber"], |
|
| 308 | + "2.16.840.1.113730.3.1.3" => ["employeeNumber"], |
|
| 309 | + "2.16.840.1.113730.3.1.4" => ["employeeType"], |
|
| 310 | + "2.16.840.1.113730.3.1.34" => ["ref"], |
|
| 311 | + "2.16.840.1.113730.3.1.39" => ["preferredLanguage"], |
|
| 312 | + "2.16.840.1.113730.3.1.40" => ["userSMIMECertificate"], |
|
| 313 | + "2.16.840.1.113730.3.1.216" => ["userPKCS12"], |
|
| 314 | + "2.16.840.1.113730.3.1.241" => ["displayName"] |
|
| 315 | + /* @formatter:on */ |
|
| 316 | + ); |
|
| 317 | 317 | |
| 318 | - /** |
|
| 319 | - * OID of the attribute. |
|
| 320 | - * |
|
| 321 | - * @var string $_oid |
|
| 322 | - */ |
|
| 323 | - protected $_oid; |
|
| 318 | + /** |
|
| 319 | + * OID of the attribute. |
|
| 320 | + * |
|
| 321 | + * @var string $_oid |
|
| 322 | + */ |
|
| 323 | + protected $_oid; |
|
| 324 | 324 | |
| 325 | - /** |
|
| 326 | - * Constructor. |
|
| 327 | - * |
|
| 328 | - * @param string $oid OID in dotted format. |
|
| 329 | - */ |
|
| 330 | - public function __construct(string $oid) |
|
| 331 | - { |
|
| 332 | - $this->_oid = $oid; |
|
| 333 | - } |
|
| 325 | + /** |
|
| 326 | + * Constructor. |
|
| 327 | + * |
|
| 328 | + * @param string $oid OID in dotted format. |
|
| 329 | + */ |
|
| 330 | + public function __construct(string $oid) |
|
| 331 | + { |
|
| 332 | + $this->_oid = $oid; |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | - /** |
|
| 336 | - * Initialize from ASN.1. |
|
| 337 | - * |
|
| 338 | - * @param ObjectIdentifier $oi |
|
| 339 | - * @return self |
|
| 340 | - */ |
|
| 341 | - public static function fromASN1(ObjectIdentifier $oi): self |
|
| 342 | - { |
|
| 343 | - return new self($oi->oid()); |
|
| 344 | - } |
|
| 335 | + /** |
|
| 336 | + * Initialize from ASN.1. |
|
| 337 | + * |
|
| 338 | + * @param ObjectIdentifier $oi |
|
| 339 | + * @return self |
|
| 340 | + */ |
|
| 341 | + public static function fromASN1(ObjectIdentifier $oi): self |
|
| 342 | + { |
|
| 343 | + return new self($oi->oid()); |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | - /** |
|
| 347 | - * Initialize from attribute name. |
|
| 348 | - * |
|
| 349 | - * @param string $name |
|
| 350 | - * @return self |
|
| 351 | - */ |
|
| 352 | - public static function fromName(string $name): self |
|
| 353 | - { |
|
| 354 | - $oid = self::attrNameToOID($name); |
|
| 355 | - return new self($oid); |
|
| 356 | - } |
|
| 346 | + /** |
|
| 347 | + * Initialize from attribute name. |
|
| 348 | + * |
|
| 349 | + * @param string $name |
|
| 350 | + * @return self |
|
| 351 | + */ |
|
| 352 | + public static function fromName(string $name): self |
|
| 353 | + { |
|
| 354 | + $oid = self::attrNameToOID($name); |
|
| 355 | + return new self($oid); |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | - /** |
|
| 359 | - * Get OID of the attribute. |
|
| 360 | - * |
|
| 361 | - * @return string OID in dotted format |
|
| 362 | - */ |
|
| 363 | - public function oid(): string |
|
| 364 | - { |
|
| 365 | - return $this->_oid; |
|
| 366 | - } |
|
| 358 | + /** |
|
| 359 | + * Get OID of the attribute. |
|
| 360 | + * |
|
| 361 | + * @return string OID in dotted format |
|
| 362 | + */ |
|
| 363 | + public function oid(): string |
|
| 364 | + { |
|
| 365 | + return $this->_oid; |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | - /** |
|
| 369 | - * Get name of the attribute. |
|
| 370 | - * |
|
| 371 | - * @return string |
|
| 372 | - */ |
|
| 373 | - public function typeName(): string |
|
| 374 | - { |
|
| 375 | - if (array_key_exists($this->_oid, self::MAP_OID_TO_NAME)) { |
|
| 376 | - return self::MAP_OID_TO_NAME[$this->_oid][0]; |
|
| 377 | - } |
|
| 378 | - return $this->_oid; |
|
| 379 | - } |
|
| 368 | + /** |
|
| 369 | + * Get name of the attribute. |
|
| 370 | + * |
|
| 371 | + * @return string |
|
| 372 | + */ |
|
| 373 | + public function typeName(): string |
|
| 374 | + { |
|
| 375 | + if (array_key_exists($this->_oid, self::MAP_OID_TO_NAME)) { |
|
| 376 | + return self::MAP_OID_TO_NAME[$this->_oid][0]; |
|
| 377 | + } |
|
| 378 | + return $this->_oid; |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | - /** |
|
| 382 | - * Generate ASN.1 element. |
|
| 383 | - * |
|
| 384 | - * @return ObjectIdentifier |
|
| 385 | - */ |
|
| 386 | - public function toASN1(): ObjectIdentifier |
|
| 387 | - { |
|
| 388 | - return new ObjectIdentifier($this->_oid); |
|
| 389 | - } |
|
| 381 | + /** |
|
| 382 | + * Generate ASN.1 element. |
|
| 383 | + * |
|
| 384 | + * @return ObjectIdentifier |
|
| 385 | + */ |
|
| 386 | + public function toASN1(): ObjectIdentifier |
|
| 387 | + { |
|
| 388 | + return new ObjectIdentifier($this->_oid); |
|
| 389 | + } |
|
| 390 | 390 | |
| 391 | - /** |
|
| 392 | - * Get name to OID lookup map. |
|
| 393 | - * |
|
| 394 | - * @return array |
|
| 395 | - */ |
|
| 396 | - private static function _oidReverseMap(): array |
|
| 397 | - { |
|
| 398 | - static $map; |
|
| 399 | - if (!isset($map)) { |
|
| 400 | - $map = array(); |
|
| 401 | - // for eatch attribute type |
|
| 402 | - foreach (self::MAP_OID_TO_NAME as $oid => $names) { |
|
| 403 | - // for primary name and aliases |
|
| 404 | - foreach ($names as $name) { |
|
| 405 | - $map[strtolower($name)] = $oid; |
|
| 406 | - } |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - return $map; |
|
| 410 | - } |
|
| 391 | + /** |
|
| 392 | + * Get name to OID lookup map. |
|
| 393 | + * |
|
| 394 | + * @return array |
|
| 395 | + */ |
|
| 396 | + private static function _oidReverseMap(): array |
|
| 397 | + { |
|
| 398 | + static $map; |
|
| 399 | + if (!isset($map)) { |
|
| 400 | + $map = array(); |
|
| 401 | + // for eatch attribute type |
|
| 402 | + foreach (self::MAP_OID_TO_NAME as $oid => $names) { |
|
| 403 | + // for primary name and aliases |
|
| 404 | + foreach ($names as $name) { |
|
| 405 | + $map[strtolower($name)] = $oid; |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + return $map; |
|
| 410 | + } |
|
| 411 | 411 | |
| 412 | - /** |
|
| 413 | - * Convert attribute name to OID. |
|
| 414 | - * |
|
| 415 | - * @param string $name Primary attribute name or an alias |
|
| 416 | - * @throws \OutOfBoundsException |
|
| 417 | - * @return string OID in dotted format |
|
| 418 | - */ |
|
| 419 | - public static function attrNameToOID(string $name): string |
|
| 420 | - { |
|
| 421 | - // if already in OID form |
|
| 422 | - if (preg_match('/^[0-9]+(?:\.[0-9]+)*$/', $name)) { |
|
| 423 | - return $name; |
|
| 424 | - } |
|
| 425 | - $map = self::_oidReverseMap(); |
|
| 426 | - $k = strtolower($name); |
|
| 427 | - if (!isset($map[$k])) { |
|
| 428 | - throw new \OutOfBoundsException("No OID for $name."); |
|
| 429 | - } |
|
| 430 | - return $map[$k]; |
|
| 431 | - } |
|
| 412 | + /** |
|
| 413 | + * Convert attribute name to OID. |
|
| 414 | + * |
|
| 415 | + * @param string $name Primary attribute name or an alias |
|
| 416 | + * @throws \OutOfBoundsException |
|
| 417 | + * @return string OID in dotted format |
|
| 418 | + */ |
|
| 419 | + public static function attrNameToOID(string $name): string |
|
| 420 | + { |
|
| 421 | + // if already in OID form |
|
| 422 | + if (preg_match('/^[0-9]+(?:\.[0-9]+)*$/', $name)) { |
|
| 423 | + return $name; |
|
| 424 | + } |
|
| 425 | + $map = self::_oidReverseMap(); |
|
| 426 | + $k = strtolower($name); |
|
| 427 | + if (!isset($map[$k])) { |
|
| 428 | + throw new \OutOfBoundsException("No OID for $name."); |
|
| 429 | + } |
|
| 430 | + return $map[$k]; |
|
| 431 | + } |
|
| 432 | 432 | |
| 433 | - /** |
|
| 434 | - * Get ASN.1 string for given attribute type. |
|
| 435 | - * |
|
| 436 | - * @param string $oid Attribute OID |
|
| 437 | - * @param string $str String |
|
| 438 | - * @throws \LogicException |
|
| 439 | - * @return \ASN1\Type\StringType |
|
| 440 | - */ |
|
| 441 | - public static function asn1StringForType(string $oid, string $str): StringType |
|
| 442 | - { |
|
| 443 | - if (!array_key_exists($oid, self::MAP_ATTR_TO_STR_TYPE)) { |
|
| 444 | - return new UTF8String($str); |
|
| 445 | - } |
|
| 446 | - switch (self::MAP_ATTR_TO_STR_TYPE[$oid]) { |
|
| 447 | - case Element::TYPE_PRINTABLE_STRING: |
|
| 448 | - return new PrintableString($str); |
|
| 449 | - // @codeCoverageIgnoreStart |
|
| 450 | - default: |
|
| 451 | - // only reachable during development |
|
| 452 | - throw new \LogicException(); |
|
| 453 | - } |
|
| 454 | - // @codeCoverageIgnoreEnd |
|
| 455 | - } |
|
| 433 | + /** |
|
| 434 | + * Get ASN.1 string for given attribute type. |
|
| 435 | + * |
|
| 436 | + * @param string $oid Attribute OID |
|
| 437 | + * @param string $str String |
|
| 438 | + * @throws \LogicException |
|
| 439 | + * @return \ASN1\Type\StringType |
|
| 440 | + */ |
|
| 441 | + public static function asn1StringForType(string $oid, string $str): StringType |
|
| 442 | + { |
|
| 443 | + if (!array_key_exists($oid, self::MAP_ATTR_TO_STR_TYPE)) { |
|
| 444 | + return new UTF8String($str); |
|
| 445 | + } |
|
| 446 | + switch (self::MAP_ATTR_TO_STR_TYPE[$oid]) { |
|
| 447 | + case Element::TYPE_PRINTABLE_STRING: |
|
| 448 | + return new PrintableString($str); |
|
| 449 | + // @codeCoverageIgnoreStart |
|
| 450 | + default: |
|
| 451 | + // only reachable during development |
|
| 452 | + throw new \LogicException(); |
|
| 453 | + } |
|
| 454 | + // @codeCoverageIgnoreEnd |
|
| 455 | + } |
|
| 456 | 456 | } |
@@ -13,14 +13,14 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class CaseIgnoreMatch extends StringPrepMatchingRule |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Constructor. |
|
| 18 | - * |
|
| 19 | - * @param int $string_type ASN.1 string type tag |
|
| 20 | - */ |
|
| 21 | - public function __construct(int $string_type) |
|
| 22 | - { |
|
| 23 | - parent::__construct( |
|
| 24 | - StringPreparer::forStringType($string_type)->withCaseFolding(true)); |
|
| 25 | - } |
|
| 16 | + /** |
|
| 17 | + * Constructor. |
|
| 18 | + * |
|
| 19 | + * @param int $string_type ASN.1 string type tag |
|
| 20 | + */ |
|
| 21 | + public function __construct(int $string_type) |
|
| 22 | + { |
|
| 23 | + parent::__construct( |
|
| 24 | + StringPreparer::forStringType($string_type)->withCaseFolding(true)); |
|
| 25 | + } |
|
| 26 | 26 | } |
@@ -13,13 +13,13 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class CaseExactMatch extends StringPrepMatchingRule |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Constructor. |
|
| 18 | - * |
|
| 19 | - * @param int $string_type ASN.1 string type tag |
|
| 20 | - */ |
|
| 21 | - public function __construct(int $string_type) |
|
| 22 | - { |
|
| 23 | - parent::__construct(StringPreparer::forStringType($string_type)); |
|
| 24 | - } |
|
| 16 | + /** |
|
| 17 | + * Constructor. |
|
| 18 | + * |
|
| 19 | + * @param int $string_type ASN.1 string type tag |
|
| 20 | + */ |
|
| 21 | + public function __construct(int $string_type) |
|
| 22 | + { |
|
| 23 | + parent::__construct(StringPreparer::forStringType($string_type)); |
|
| 24 | + } |
|
| 25 | 25 | } |
@@ -15,390 +15,390 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class DNParser |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * DN string. |
|
| 20 | - * |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - private $_dn; |
|
| 18 | + /** |
|
| 19 | + * DN string. |
|
| 20 | + * |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + private $_dn; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * DN string length. |
|
| 27 | - * |
|
| 28 | - * @var int |
|
| 29 | - */ |
|
| 30 | - private $_len; |
|
| 25 | + /** |
|
| 26 | + * DN string length. |
|
| 27 | + * |
|
| 28 | + * @var int |
|
| 29 | + */ |
|
| 30 | + private $_len; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * RFC 2253 special characters. |
|
| 34 | - * |
|
| 35 | - * @var string |
|
| 36 | - */ |
|
| 37 | - const SPECIAL_CHARS = ",=+<>#;"; |
|
| 32 | + /** |
|
| 33 | + * RFC 2253 special characters. |
|
| 34 | + * |
|
| 35 | + * @var string |
|
| 36 | + */ |
|
| 37 | + const SPECIAL_CHARS = ",=+<>#;"; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Parse distinguished name string to name-components. |
|
| 41 | - * |
|
| 42 | - * @param string $dn |
|
| 43 | - * @return array |
|
| 44 | - */ |
|
| 45 | - public static function parseString(string $dn): array |
|
| 46 | - { |
|
| 47 | - $parser = new self($dn); |
|
| 48 | - return $parser->parse(); |
|
| 49 | - } |
|
| 39 | + /** |
|
| 40 | + * Parse distinguished name string to name-components. |
|
| 41 | + * |
|
| 42 | + * @param string $dn |
|
| 43 | + * @return array |
|
| 44 | + */ |
|
| 45 | + public static function parseString(string $dn): array |
|
| 46 | + { |
|
| 47 | + $parser = new self($dn); |
|
| 48 | + return $parser->parse(); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Escape a AttributeValue string conforming to RFC 2253. |
|
| 53 | - * |
|
| 54 | - * @link https://tools.ietf.org/html/rfc2253#section-2.4 |
|
| 55 | - * @param string $str |
|
| 56 | - * @return string |
|
| 57 | - */ |
|
| 58 | - public static function escapeString(string $str): string |
|
| 59 | - { |
|
| 60 | - // one of the characters ",", "+", """, "\", "<", ">" or ";" |
|
| 61 | - $str = preg_replace('/([,\+"\\\<\>;])/u', '\\\\$1', $str); |
|
| 62 | - // a space character occurring at the end of the string |
|
| 63 | - $str = preg_replace('/( )$/u', '\\\\$1', $str); |
|
| 64 | - // a space or "#" character occurring at the beginning of the string |
|
| 65 | - $str = preg_replace('/^([ #])/u', '\\\\$1', $str); |
|
| 66 | - // implementation specific special characters |
|
| 67 | - $str = preg_replace_callback('/([\pC])/u', |
|
| 68 | - function ($m) { |
|
| 69 | - $octets = str_split(bin2hex($m[1]), 2); |
|
| 70 | - return implode("", |
|
| 71 | - array_map( |
|
| 72 | - function ($octet) { |
|
| 73 | - return '\\' . strtoupper($octet); |
|
| 74 | - }, $octets)); |
|
| 75 | - }, $str); |
|
| 76 | - return $str; |
|
| 77 | - } |
|
| 51 | + /** |
|
| 52 | + * Escape a AttributeValue string conforming to RFC 2253. |
|
| 53 | + * |
|
| 54 | + * @link https://tools.ietf.org/html/rfc2253#section-2.4 |
|
| 55 | + * @param string $str |
|
| 56 | + * @return string |
|
| 57 | + */ |
|
| 58 | + public static function escapeString(string $str): string |
|
| 59 | + { |
|
| 60 | + // one of the characters ",", "+", """, "\", "<", ">" or ";" |
|
| 61 | + $str = preg_replace('/([,\+"\\\<\>;])/u', '\\\\$1', $str); |
|
| 62 | + // a space character occurring at the end of the string |
|
| 63 | + $str = preg_replace('/( )$/u', '\\\\$1', $str); |
|
| 64 | + // a space or "#" character occurring at the beginning of the string |
|
| 65 | + $str = preg_replace('/^([ #])/u', '\\\\$1', $str); |
|
| 66 | + // implementation specific special characters |
|
| 67 | + $str = preg_replace_callback('/([\pC])/u', |
|
| 68 | + function ($m) { |
|
| 69 | + $octets = str_split(bin2hex($m[1]), 2); |
|
| 70 | + return implode("", |
|
| 71 | + array_map( |
|
| 72 | + function ($octet) { |
|
| 73 | + return '\\' . strtoupper($octet); |
|
| 74 | + }, $octets)); |
|
| 75 | + }, $str); |
|
| 76 | + return $str; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Constructor. |
|
| 81 | - * |
|
| 82 | - * @param string $dn Distinguised name |
|
| 83 | - */ |
|
| 84 | - protected function __construct(string $dn) |
|
| 85 | - { |
|
| 86 | - $this->_dn = $dn; |
|
| 87 | - $this->_len = strlen($dn); |
|
| 88 | - } |
|
| 79 | + /** |
|
| 80 | + * Constructor. |
|
| 81 | + * |
|
| 82 | + * @param string $dn Distinguised name |
|
| 83 | + */ |
|
| 84 | + protected function __construct(string $dn) |
|
| 85 | + { |
|
| 86 | + $this->_dn = $dn; |
|
| 87 | + $this->_len = strlen($dn); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Parse DN to name-components. |
|
| 92 | - * |
|
| 93 | - * @throws \RuntimeException |
|
| 94 | - * @return array |
|
| 95 | - */ |
|
| 96 | - protected function parse(): array |
|
| 97 | - { |
|
| 98 | - $offset = 0; |
|
| 99 | - $name = $this->_parseName($offset); |
|
| 100 | - if ($offset < $this->_len) { |
|
| 101 | - $remains = substr($this->_dn, $offset); |
|
| 102 | - throw new \UnexpectedValueException( |
|
| 103 | - "Parser finished before the end of string" . |
|
| 104 | - ", remaining: '$remains'."); |
|
| 105 | - } |
|
| 106 | - return $name; |
|
| 107 | - } |
|
| 90 | + /** |
|
| 91 | + * Parse DN to name-components. |
|
| 92 | + * |
|
| 93 | + * @throws \RuntimeException |
|
| 94 | + * @return array |
|
| 95 | + */ |
|
| 96 | + protected function parse(): array |
|
| 97 | + { |
|
| 98 | + $offset = 0; |
|
| 99 | + $name = $this->_parseName($offset); |
|
| 100 | + if ($offset < $this->_len) { |
|
| 101 | + $remains = substr($this->_dn, $offset); |
|
| 102 | + throw new \UnexpectedValueException( |
|
| 103 | + "Parser finished before the end of string" . |
|
| 104 | + ", remaining: '$remains'."); |
|
| 105 | + } |
|
| 106 | + return $name; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Parse 'name'. |
|
| 111 | - * |
|
| 112 | - * name-component *("," name-component) |
|
| 113 | - * |
|
| 114 | - * @param int $offset |
|
| 115 | - * @return array Array of name-components |
|
| 116 | - */ |
|
| 117 | - private function _parseName(int &$offset): array |
|
| 118 | - { |
|
| 119 | - $idx = $offset; |
|
| 120 | - $names = array(); |
|
| 121 | - while ($idx < $this->_len) { |
|
| 122 | - $names[] = $this->_parseNameComponent($idx); |
|
| 123 | - if ($idx >= $this->_len) { |
|
| 124 | - break; |
|
| 125 | - } |
|
| 126 | - $this->_skipWs($idx); |
|
| 127 | - if ("," != $this->_dn[$idx] && ";" != $this->_dn[$idx]) { |
|
| 128 | - break; |
|
| 129 | - } |
|
| 130 | - $idx++; |
|
| 131 | - $this->_skipWs($idx); |
|
| 132 | - } |
|
| 133 | - $offset = $idx; |
|
| 134 | - return array_reverse($names); |
|
| 135 | - } |
|
| 109 | + /** |
|
| 110 | + * Parse 'name'. |
|
| 111 | + * |
|
| 112 | + * name-component *("," name-component) |
|
| 113 | + * |
|
| 114 | + * @param int $offset |
|
| 115 | + * @return array Array of name-components |
|
| 116 | + */ |
|
| 117 | + private function _parseName(int &$offset): array |
|
| 118 | + { |
|
| 119 | + $idx = $offset; |
|
| 120 | + $names = array(); |
|
| 121 | + while ($idx < $this->_len) { |
|
| 122 | + $names[] = $this->_parseNameComponent($idx); |
|
| 123 | + if ($idx >= $this->_len) { |
|
| 124 | + break; |
|
| 125 | + } |
|
| 126 | + $this->_skipWs($idx); |
|
| 127 | + if ("," != $this->_dn[$idx] && ";" != $this->_dn[$idx]) { |
|
| 128 | + break; |
|
| 129 | + } |
|
| 130 | + $idx++; |
|
| 131 | + $this->_skipWs($idx); |
|
| 132 | + } |
|
| 133 | + $offset = $idx; |
|
| 134 | + return array_reverse($names); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Parse 'name-component'. |
|
| 139 | - * |
|
| 140 | - * attributeTypeAndValue *("+" attributeTypeAndValue) |
|
| 141 | - * |
|
| 142 | - * @param int $offset |
|
| 143 | - * @return array Array of [type, value] tuples |
|
| 144 | - */ |
|
| 145 | - private function _parseNameComponent(int &$offset): array |
|
| 146 | - { |
|
| 147 | - $idx = $offset; |
|
| 148 | - $tvpairs = array(); |
|
| 149 | - while ($idx < $this->_len) { |
|
| 150 | - $tvpairs[] = $this->_parseAttrTypeAndValue($idx); |
|
| 151 | - $this->_skipWs($idx); |
|
| 152 | - if ($idx >= $this->_len || "+" != $this->_dn[$idx]) { |
|
| 153 | - break; |
|
| 154 | - } |
|
| 155 | - ++$idx; |
|
| 156 | - $this->_skipWs($idx); |
|
| 157 | - } |
|
| 158 | - $offset = $idx; |
|
| 159 | - return $tvpairs; |
|
| 160 | - } |
|
| 137 | + /** |
|
| 138 | + * Parse 'name-component'. |
|
| 139 | + * |
|
| 140 | + * attributeTypeAndValue *("+" attributeTypeAndValue) |
|
| 141 | + * |
|
| 142 | + * @param int $offset |
|
| 143 | + * @return array Array of [type, value] tuples |
|
| 144 | + */ |
|
| 145 | + private function _parseNameComponent(int &$offset): array |
|
| 146 | + { |
|
| 147 | + $idx = $offset; |
|
| 148 | + $tvpairs = array(); |
|
| 149 | + while ($idx < $this->_len) { |
|
| 150 | + $tvpairs[] = $this->_parseAttrTypeAndValue($idx); |
|
| 151 | + $this->_skipWs($idx); |
|
| 152 | + if ($idx >= $this->_len || "+" != $this->_dn[$idx]) { |
|
| 153 | + break; |
|
| 154 | + } |
|
| 155 | + ++$idx; |
|
| 156 | + $this->_skipWs($idx); |
|
| 157 | + } |
|
| 158 | + $offset = $idx; |
|
| 159 | + return $tvpairs; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * Parse 'attributeTypeAndValue'. |
|
| 164 | - * |
|
| 165 | - * attributeType "=" attributeValue |
|
| 166 | - * |
|
| 167 | - * @param int $offset |
|
| 168 | - * @throws \UnexpectedValueException |
|
| 169 | - * @return array A tuple of [type, value]. Value may be either a string or |
|
| 170 | - * an Element, if it's encoded as hexstring. |
|
| 171 | - */ |
|
| 172 | - private function _parseAttrTypeAndValue(int &$offset): array |
|
| 173 | - { |
|
| 174 | - $idx = $offset; |
|
| 175 | - $type = $this->_parseAttrType($idx); |
|
| 176 | - $this->_skipWs($idx); |
|
| 177 | - if ($idx >= $this->_len || "=" != $this->_dn[$idx++]) { |
|
| 178 | - throw new \UnexpectedValueException("Invalid type and value pair."); |
|
| 179 | - } |
|
| 180 | - $this->_skipWs($idx); |
|
| 181 | - // hexstring |
|
| 182 | - if ($idx < $this->_len && "#" == $this->_dn[$idx]) { |
|
| 183 | - ++$idx; |
|
| 184 | - $data = $this->_parseAttrHexValue($idx); |
|
| 185 | - try { |
|
| 186 | - $value = Element::fromDER($data); |
|
| 187 | - } catch (DecodeException $e) { |
|
| 188 | - throw new \UnexpectedValueException( |
|
| 189 | - "Invalid DER encoding from hexstring.", 0, $e); |
|
| 190 | - } |
|
| 191 | - } else { |
|
| 192 | - $value = $this->_parseAttrStringValue($idx); |
|
| 193 | - } |
|
| 194 | - $offset = $idx; |
|
| 195 | - return array($type, $value); |
|
| 196 | - } |
|
| 162 | + /** |
|
| 163 | + * Parse 'attributeTypeAndValue'. |
|
| 164 | + * |
|
| 165 | + * attributeType "=" attributeValue |
|
| 166 | + * |
|
| 167 | + * @param int $offset |
|
| 168 | + * @throws \UnexpectedValueException |
|
| 169 | + * @return array A tuple of [type, value]. Value may be either a string or |
|
| 170 | + * an Element, if it's encoded as hexstring. |
|
| 171 | + */ |
|
| 172 | + private function _parseAttrTypeAndValue(int &$offset): array |
|
| 173 | + { |
|
| 174 | + $idx = $offset; |
|
| 175 | + $type = $this->_parseAttrType($idx); |
|
| 176 | + $this->_skipWs($idx); |
|
| 177 | + if ($idx >= $this->_len || "=" != $this->_dn[$idx++]) { |
|
| 178 | + throw new \UnexpectedValueException("Invalid type and value pair."); |
|
| 179 | + } |
|
| 180 | + $this->_skipWs($idx); |
|
| 181 | + // hexstring |
|
| 182 | + if ($idx < $this->_len && "#" == $this->_dn[$idx]) { |
|
| 183 | + ++$idx; |
|
| 184 | + $data = $this->_parseAttrHexValue($idx); |
|
| 185 | + try { |
|
| 186 | + $value = Element::fromDER($data); |
|
| 187 | + } catch (DecodeException $e) { |
|
| 188 | + throw new \UnexpectedValueException( |
|
| 189 | + "Invalid DER encoding from hexstring.", 0, $e); |
|
| 190 | + } |
|
| 191 | + } else { |
|
| 192 | + $value = $this->_parseAttrStringValue($idx); |
|
| 193 | + } |
|
| 194 | + $offset = $idx; |
|
| 195 | + return array($type, $value); |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - /** |
|
| 199 | - * Parse 'attributeType'. |
|
| 200 | - * |
|
| 201 | - * (ALPHA 1*keychar) / oid |
|
| 202 | - * |
|
| 203 | - * @param int $offset |
|
| 204 | - * @throws \UnexpectedValueException |
|
| 205 | - * @return string |
|
| 206 | - */ |
|
| 207 | - private function _parseAttrType(int &$offset): string |
|
| 208 | - { |
|
| 209 | - $idx = $offset; |
|
| 210 | - // dotted OID |
|
| 211 | - $type = $this->_regexMatch('/^(?:oid\.)?([0-9]+(?:\.[0-9]+)*)/i', $idx); |
|
| 212 | - if (null === $type) { |
|
| 213 | - // name |
|
| 214 | - $type = $this->_regexMatch('/^[a-z][a-z0-9\-]*/i', $idx); |
|
| 215 | - if (null === $type) { |
|
| 216 | - throw new \UnexpectedValueException("Invalid attribute type."); |
|
| 217 | - } |
|
| 218 | - } |
|
| 219 | - $offset = $idx; |
|
| 220 | - return $type; |
|
| 221 | - } |
|
| 198 | + /** |
|
| 199 | + * Parse 'attributeType'. |
|
| 200 | + * |
|
| 201 | + * (ALPHA 1*keychar) / oid |
|
| 202 | + * |
|
| 203 | + * @param int $offset |
|
| 204 | + * @throws \UnexpectedValueException |
|
| 205 | + * @return string |
|
| 206 | + */ |
|
| 207 | + private function _parseAttrType(int &$offset): string |
|
| 208 | + { |
|
| 209 | + $idx = $offset; |
|
| 210 | + // dotted OID |
|
| 211 | + $type = $this->_regexMatch('/^(?:oid\.)?([0-9]+(?:\.[0-9]+)*)/i', $idx); |
|
| 212 | + if (null === $type) { |
|
| 213 | + // name |
|
| 214 | + $type = $this->_regexMatch('/^[a-z][a-z0-9\-]*/i', $idx); |
|
| 215 | + if (null === $type) { |
|
| 216 | + throw new \UnexpectedValueException("Invalid attribute type."); |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | + $offset = $idx; |
|
| 220 | + return $type; |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - /** |
|
| 224 | - * Parse 'attributeValue' of string type. |
|
| 225 | - * |
|
| 226 | - * @param int $offset |
|
| 227 | - * @throws \UnexpectedValueException |
|
| 228 | - * @return string |
|
| 229 | - */ |
|
| 230 | - private function _parseAttrStringValue(int &$offset): string |
|
| 231 | - { |
|
| 232 | - $idx = $offset; |
|
| 233 | - if ($idx >= $this->_len) { |
|
| 234 | - return ""; |
|
| 235 | - } |
|
| 236 | - if ('"' == $this->_dn[$idx]) { // quoted string |
|
| 237 | - $val = $this->_parseQuotedAttrString($idx); |
|
| 238 | - } else { // string |
|
| 239 | - $val = $this->_parseAttrString($idx); |
|
| 240 | - } |
|
| 241 | - $offset = $idx; |
|
| 242 | - return $val; |
|
| 243 | - } |
|
| 223 | + /** |
|
| 224 | + * Parse 'attributeValue' of string type. |
|
| 225 | + * |
|
| 226 | + * @param int $offset |
|
| 227 | + * @throws \UnexpectedValueException |
|
| 228 | + * @return string |
|
| 229 | + */ |
|
| 230 | + private function _parseAttrStringValue(int &$offset): string |
|
| 231 | + { |
|
| 232 | + $idx = $offset; |
|
| 233 | + if ($idx >= $this->_len) { |
|
| 234 | + return ""; |
|
| 235 | + } |
|
| 236 | + if ('"' == $this->_dn[$idx]) { // quoted string |
|
| 237 | + $val = $this->_parseQuotedAttrString($idx); |
|
| 238 | + } else { // string |
|
| 239 | + $val = $this->_parseAttrString($idx); |
|
| 240 | + } |
|
| 241 | + $offset = $idx; |
|
| 242 | + return $val; |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - /** |
|
| 246 | - * Parse plain 'attributeValue' string. |
|
| 247 | - * |
|
| 248 | - * @param int $offset |
|
| 249 | - * @throws \UnexpectedValueException |
|
| 250 | - * @return string |
|
| 251 | - */ |
|
| 252 | - private function _parseAttrString(int &$offset): string |
|
| 253 | - { |
|
| 254 | - $idx = $offset; |
|
| 255 | - $val = ""; |
|
| 256 | - $wsidx = null; |
|
| 257 | - while ($idx < $this->_len) { |
|
| 258 | - $c = $this->_dn[$idx]; |
|
| 259 | - // pair (escape sequence) |
|
| 260 | - if ("\\" == $c) { |
|
| 261 | - ++$idx; |
|
| 262 | - $val .= $this->_parsePairAfterSlash($idx); |
|
| 263 | - $wsidx = null; |
|
| 264 | - continue; |
|
| 265 | - } else if ('"' == $c) { |
|
| 266 | - throw new \UnexpectedValueException("Unexpected quotation."); |
|
| 267 | - } else if (false !== strpos(self::SPECIAL_CHARS, $c)) { |
|
| 268 | - break; |
|
| 269 | - } |
|
| 270 | - // keep track of the first consecutive whitespace |
|
| 271 | - if (' ' == $c) { |
|
| 272 | - if (null === $wsidx) { |
|
| 273 | - $wsidx = $idx; |
|
| 274 | - } |
|
| 275 | - } else { |
|
| 276 | - $wsidx = null; |
|
| 277 | - } |
|
| 278 | - // stringchar |
|
| 279 | - $val .= $c; |
|
| 280 | - ++$idx; |
|
| 281 | - } |
|
| 282 | - // if there was non-escaped whitespace in the end of the value |
|
| 283 | - if (null !== $wsidx) { |
|
| 284 | - $val = substr($val, 0, -($idx - $wsidx)); |
|
| 285 | - } |
|
| 286 | - $offset = $idx; |
|
| 287 | - return $val; |
|
| 288 | - } |
|
| 245 | + /** |
|
| 246 | + * Parse plain 'attributeValue' string. |
|
| 247 | + * |
|
| 248 | + * @param int $offset |
|
| 249 | + * @throws \UnexpectedValueException |
|
| 250 | + * @return string |
|
| 251 | + */ |
|
| 252 | + private function _parseAttrString(int &$offset): string |
|
| 253 | + { |
|
| 254 | + $idx = $offset; |
|
| 255 | + $val = ""; |
|
| 256 | + $wsidx = null; |
|
| 257 | + while ($idx < $this->_len) { |
|
| 258 | + $c = $this->_dn[$idx]; |
|
| 259 | + // pair (escape sequence) |
|
| 260 | + if ("\\" == $c) { |
|
| 261 | + ++$idx; |
|
| 262 | + $val .= $this->_parsePairAfterSlash($idx); |
|
| 263 | + $wsidx = null; |
|
| 264 | + continue; |
|
| 265 | + } else if ('"' == $c) { |
|
| 266 | + throw new \UnexpectedValueException("Unexpected quotation."); |
|
| 267 | + } else if (false !== strpos(self::SPECIAL_CHARS, $c)) { |
|
| 268 | + break; |
|
| 269 | + } |
|
| 270 | + // keep track of the first consecutive whitespace |
|
| 271 | + if (' ' == $c) { |
|
| 272 | + if (null === $wsidx) { |
|
| 273 | + $wsidx = $idx; |
|
| 274 | + } |
|
| 275 | + } else { |
|
| 276 | + $wsidx = null; |
|
| 277 | + } |
|
| 278 | + // stringchar |
|
| 279 | + $val .= $c; |
|
| 280 | + ++$idx; |
|
| 281 | + } |
|
| 282 | + // if there was non-escaped whitespace in the end of the value |
|
| 283 | + if (null !== $wsidx) { |
|
| 284 | + $val = substr($val, 0, -($idx - $wsidx)); |
|
| 285 | + } |
|
| 286 | + $offset = $idx; |
|
| 287 | + return $val; |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - /** |
|
| 291 | - * Parse quoted 'attributeValue' string. |
|
| 292 | - * |
|
| 293 | - * @param int $offset Offset to starting quote |
|
| 294 | - * @throws \UnexpectedValueException |
|
| 295 | - * @return string |
|
| 296 | - */ |
|
| 297 | - private function _parseQuotedAttrString(int &$offset): string |
|
| 298 | - { |
|
| 299 | - $idx = $offset + 1; |
|
| 300 | - $val = ""; |
|
| 301 | - while ($idx < $this->_len) { |
|
| 302 | - $c = $this->_dn[$idx]; |
|
| 303 | - if ("\\" == $c) { // pair |
|
| 304 | - ++$idx; |
|
| 305 | - $val .= $this->_parsePairAfterSlash($idx); |
|
| 306 | - continue; |
|
| 307 | - } else if ('"' == $c) { |
|
| 308 | - ++$idx; |
|
| 309 | - break; |
|
| 310 | - } |
|
| 311 | - $val .= $c; |
|
| 312 | - ++$idx; |
|
| 313 | - } |
|
| 314 | - $offset = $idx; |
|
| 315 | - return $val; |
|
| 316 | - } |
|
| 290 | + /** |
|
| 291 | + * Parse quoted 'attributeValue' string. |
|
| 292 | + * |
|
| 293 | + * @param int $offset Offset to starting quote |
|
| 294 | + * @throws \UnexpectedValueException |
|
| 295 | + * @return string |
|
| 296 | + */ |
|
| 297 | + private function _parseQuotedAttrString(int &$offset): string |
|
| 298 | + { |
|
| 299 | + $idx = $offset + 1; |
|
| 300 | + $val = ""; |
|
| 301 | + while ($idx < $this->_len) { |
|
| 302 | + $c = $this->_dn[$idx]; |
|
| 303 | + if ("\\" == $c) { // pair |
|
| 304 | + ++$idx; |
|
| 305 | + $val .= $this->_parsePairAfterSlash($idx); |
|
| 306 | + continue; |
|
| 307 | + } else if ('"' == $c) { |
|
| 308 | + ++$idx; |
|
| 309 | + break; |
|
| 310 | + } |
|
| 311 | + $val .= $c; |
|
| 312 | + ++$idx; |
|
| 313 | + } |
|
| 314 | + $offset = $idx; |
|
| 315 | + return $val; |
|
| 316 | + } |
|
| 317 | 317 | |
| 318 | - /** |
|
| 319 | - * Parse 'attributeValue' of binary type. |
|
| 320 | - * |
|
| 321 | - * @param int $offset |
|
| 322 | - * @throws \UnexpectedValueException |
|
| 323 | - * @return string |
|
| 324 | - */ |
|
| 325 | - private function _parseAttrHexValue(int &$offset): string |
|
| 326 | - { |
|
| 327 | - $idx = $offset; |
|
| 328 | - $hexstr = $this->_regexMatch('/^(?:[0-9a-f]{2})+/i', $idx); |
|
| 329 | - if (null === $hexstr) { |
|
| 330 | - throw new \UnexpectedValueException("Invalid hexstring."); |
|
| 331 | - } |
|
| 332 | - $data = hex2bin($hexstr); |
|
| 333 | - $offset = $idx; |
|
| 334 | - return $data; |
|
| 335 | - } |
|
| 318 | + /** |
|
| 319 | + * Parse 'attributeValue' of binary type. |
|
| 320 | + * |
|
| 321 | + * @param int $offset |
|
| 322 | + * @throws \UnexpectedValueException |
|
| 323 | + * @return string |
|
| 324 | + */ |
|
| 325 | + private function _parseAttrHexValue(int &$offset): string |
|
| 326 | + { |
|
| 327 | + $idx = $offset; |
|
| 328 | + $hexstr = $this->_regexMatch('/^(?:[0-9a-f]{2})+/i', $idx); |
|
| 329 | + if (null === $hexstr) { |
|
| 330 | + throw new \UnexpectedValueException("Invalid hexstring."); |
|
| 331 | + } |
|
| 332 | + $data = hex2bin($hexstr); |
|
| 333 | + $offset = $idx; |
|
| 334 | + return $data; |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | - /** |
|
| 338 | - * Parse 'pair' after leading slash. |
|
| 339 | - * |
|
| 340 | - * @param int $offset |
|
| 341 | - * @throws \UnexpectedValueException |
|
| 342 | - * @return string |
|
| 343 | - */ |
|
| 344 | - private function _parsePairAfterSlash(int &$offset): string |
|
| 345 | - { |
|
| 346 | - $idx = $offset; |
|
| 347 | - if ($idx >= $this->_len) { |
|
| 348 | - throw new \UnexpectedValueException( |
|
| 349 | - "Unexpected end of escape sequence."); |
|
| 350 | - } |
|
| 351 | - $c = $this->_dn[$idx++]; |
|
| 352 | - // special | \ | " | SPACE |
|
| 353 | - if (false !== strpos(self::SPECIAL_CHARS . '\\" ', $c)) { |
|
| 354 | - $val = $c; |
|
| 355 | - } else { // hexpair |
|
| 356 | - if ($idx >= $this->_len) { |
|
| 357 | - throw new \UnexpectedValueException("Unexpected end of hexpair."); |
|
| 358 | - } |
|
| 359 | - $val = @hex2bin($c . $this->_dn[$idx++]); |
|
| 360 | - if (false === $val) { |
|
| 361 | - throw new \UnexpectedValueException("Invalid hexpair."); |
|
| 362 | - } |
|
| 363 | - } |
|
| 364 | - $offset = $idx; |
|
| 365 | - return $val; |
|
| 366 | - } |
|
| 337 | + /** |
|
| 338 | + * Parse 'pair' after leading slash. |
|
| 339 | + * |
|
| 340 | + * @param int $offset |
|
| 341 | + * @throws \UnexpectedValueException |
|
| 342 | + * @return string |
|
| 343 | + */ |
|
| 344 | + private function _parsePairAfterSlash(int &$offset): string |
|
| 345 | + { |
|
| 346 | + $idx = $offset; |
|
| 347 | + if ($idx >= $this->_len) { |
|
| 348 | + throw new \UnexpectedValueException( |
|
| 349 | + "Unexpected end of escape sequence."); |
|
| 350 | + } |
|
| 351 | + $c = $this->_dn[$idx++]; |
|
| 352 | + // special | \ | " | SPACE |
|
| 353 | + if (false !== strpos(self::SPECIAL_CHARS . '\\" ', $c)) { |
|
| 354 | + $val = $c; |
|
| 355 | + } else { // hexpair |
|
| 356 | + if ($idx >= $this->_len) { |
|
| 357 | + throw new \UnexpectedValueException("Unexpected end of hexpair."); |
|
| 358 | + } |
|
| 359 | + $val = @hex2bin($c . $this->_dn[$idx++]); |
|
| 360 | + if (false === $val) { |
|
| 361 | + throw new \UnexpectedValueException("Invalid hexpair."); |
|
| 362 | + } |
|
| 363 | + } |
|
| 364 | + $offset = $idx; |
|
| 365 | + return $val; |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | - /** |
|
| 369 | - * Match DN to pattern and extract the last capture group. |
|
| 370 | - * |
|
| 371 | - * Updates offset to fully matched pattern. |
|
| 372 | - * |
|
| 373 | - * @param string $pattern |
|
| 374 | - * @param int $offset |
|
| 375 | - * @return string|null Null if pattern doesn't match |
|
| 376 | - */ |
|
| 377 | - private function _regexMatch(string $pattern, int &$offset) |
|
| 378 | - { |
|
| 379 | - $idx = $offset; |
|
| 380 | - if (!preg_match($pattern, substr($this->_dn, $idx), $match)) { |
|
| 381 | - return null; |
|
| 382 | - } |
|
| 383 | - $idx += strlen($match[0]); |
|
| 384 | - $offset = $idx; |
|
| 385 | - return end($match); |
|
| 386 | - } |
|
| 368 | + /** |
|
| 369 | + * Match DN to pattern and extract the last capture group. |
|
| 370 | + * |
|
| 371 | + * Updates offset to fully matched pattern. |
|
| 372 | + * |
|
| 373 | + * @param string $pattern |
|
| 374 | + * @param int $offset |
|
| 375 | + * @return string|null Null if pattern doesn't match |
|
| 376 | + */ |
|
| 377 | + private function _regexMatch(string $pattern, int &$offset) |
|
| 378 | + { |
|
| 379 | + $idx = $offset; |
|
| 380 | + if (!preg_match($pattern, substr($this->_dn, $idx), $match)) { |
|
| 381 | + return null; |
|
| 382 | + } |
|
| 383 | + $idx += strlen($match[0]); |
|
| 384 | + $offset = $idx; |
|
| 385 | + return end($match); |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | - /** |
|
| 389 | - * Skip consecutive spaces. |
|
| 390 | - * |
|
| 391 | - * @param int $offset |
|
| 392 | - */ |
|
| 393 | - private function _skipWs(int &$offset) |
|
| 394 | - { |
|
| 395 | - $idx = $offset; |
|
| 396 | - while ($idx < $this->_len) { |
|
| 397 | - if (" " != $this->_dn[$idx]) { |
|
| 398 | - break; |
|
| 399 | - } |
|
| 400 | - ++$idx; |
|
| 401 | - } |
|
| 402 | - $offset = $idx; |
|
| 403 | - } |
|
| 388 | + /** |
|
| 389 | + * Skip consecutive spaces. |
|
| 390 | + * |
|
| 391 | + * @param int $offset |
|
| 392 | + */ |
|
| 393 | + private function _skipWs(int &$offset) |
|
| 394 | + { |
|
| 395 | + $idx = $offset; |
|
| 396 | + while ($idx < $this->_len) { |
|
| 397 | + if (" " != $this->_dn[$idx]) { |
|
| 398 | + break; |
|
| 399 | + } |
|
| 400 | + ++$idx; |
|
| 401 | + } |
|
| 402 | + $offset = $idx; |
|
| 403 | + } |
|
| 404 | 404 | } |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | $str = preg_replace('/^([ #])/u', '\\\\$1', $str); |
| 66 | 66 | // implementation specific special characters |
| 67 | 67 | $str = preg_replace_callback('/([\pC])/u', |
| 68 | - function ($m) { |
|
| 68 | + function($m) { |
|
| 69 | 69 | $octets = str_split(bin2hex($m[1]), 2); |
| 70 | 70 | return implode("", |
| 71 | 71 | array_map( |
| 72 | - function ($octet) { |
|
| 72 | + function($octet) { |
|
| 73 | 73 | return '\\' . strtoupper($octet); |
| 74 | 74 | }, $octets)); |
| 75 | 75 | }, $str); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * @param int $offset |
| 115 | 115 | * @return array Array of name-components |
| 116 | 116 | */ |
| 117 | - private function _parseName(int &$offset): array |
|
| 117 | + private function _parseName(int & $offset): array |
|
| 118 | 118 | { |
| 119 | 119 | $idx = $offset; |
| 120 | 120 | $names = array(); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param int $offset |
| 143 | 143 | * @return array Array of [type, value] tuples |
| 144 | 144 | */ |
| 145 | - private function _parseNameComponent(int &$offset): array |
|
| 145 | + private function _parseNameComponent(int & $offset): array |
|
| 146 | 146 | { |
| 147 | 147 | $idx = $offset; |
| 148 | 148 | $tvpairs = array(); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @return array A tuple of [type, value]. Value may be either a string or |
| 170 | 170 | * an Element, if it's encoded as hexstring. |
| 171 | 171 | */ |
| 172 | - private function _parseAttrTypeAndValue(int &$offset): array |
|
| 172 | + private function _parseAttrTypeAndValue(int & $offset): array |
|
| 173 | 173 | { |
| 174 | 174 | $idx = $offset; |
| 175 | 175 | $type = $this->_parseAttrType($idx); |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * @throws \UnexpectedValueException |
| 205 | 205 | * @return string |
| 206 | 206 | */ |
| 207 | - private function _parseAttrType(int &$offset): string |
|
| 207 | + private function _parseAttrType(int & $offset): string |
|
| 208 | 208 | { |
| 209 | 209 | $idx = $offset; |
| 210 | 210 | // dotted OID |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * @throws \UnexpectedValueException |
| 228 | 228 | * @return string |
| 229 | 229 | */ |
| 230 | - private function _parseAttrStringValue(int &$offset): string |
|
| 230 | + private function _parseAttrStringValue(int & $offset): string |
|
| 231 | 231 | { |
| 232 | 232 | $idx = $offset; |
| 233 | 233 | if ($idx >= $this->_len) { |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * @throws \UnexpectedValueException |
| 250 | 250 | * @return string |
| 251 | 251 | */ |
| 252 | - private function _parseAttrString(int &$offset): string |
|
| 252 | + private function _parseAttrString(int & $offset): string |
|
| 253 | 253 | { |
| 254 | 254 | $idx = $offset; |
| 255 | 255 | $val = ""; |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | * @throws \UnexpectedValueException |
| 295 | 295 | * @return string |
| 296 | 296 | */ |
| 297 | - private function _parseQuotedAttrString(int &$offset): string |
|
| 297 | + private function _parseQuotedAttrString(int & $offset): string |
|
| 298 | 298 | { |
| 299 | 299 | $idx = $offset + 1; |
| 300 | 300 | $val = ""; |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | * @throws \UnexpectedValueException |
| 323 | 323 | * @return string |
| 324 | 324 | */ |
| 325 | - private function _parseAttrHexValue(int &$offset): string |
|
| 325 | + private function _parseAttrHexValue(int & $offset): string |
|
| 326 | 326 | { |
| 327 | 327 | $idx = $offset; |
| 328 | 328 | $hexstr = $this->_regexMatch('/^(?:[0-9a-f]{2})+/i', $idx); |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | * @throws \UnexpectedValueException |
| 342 | 342 | * @return string |
| 343 | 343 | */ |
| 344 | - private function _parsePairAfterSlash(int &$offset): string |
|
| 344 | + private function _parsePairAfterSlash(int & $offset): string |
|
| 345 | 345 | { |
| 346 | 346 | $idx = $offset; |
| 347 | 347 | if ($idx >= $this->_len) { |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | * @param int $offset |
| 375 | 375 | * @return string|null Null if pattern doesn't match |
| 376 | 376 | */ |
| 377 | - private function _regexMatch(string $pattern, int &$offset) |
|
| 377 | + private function _regexMatch(string $pattern, int & $offset) |
|
| 378 | 378 | { |
| 379 | 379 | $idx = $offset; |
| 380 | 380 | if (!preg_match($pattern, substr($this->_dn, $idx), $match)) { |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | * |
| 391 | 391 | * @param int $offset |
| 392 | 392 | */ |
| 393 | - private function _skipWs(int &$offset) |
|
| 393 | + private function _skipWs(int & $offset) |
|
| 394 | 394 | { |
| 395 | 395 | $idx = $offset; |
| 396 | 396 | while ($idx < $this->_len) { |
@@ -11,77 +11,77 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class StringPreparer |
| 13 | 13 | { |
| 14 | - const STEP_TRANSCODE = 1; |
|
| 15 | - const STEP_MAP = 2; |
|
| 16 | - const STEP_NORMALIZE = 3; |
|
| 17 | - const STEP_PROHIBIT = 4; |
|
| 18 | - const STEP_CHECK_BIDI = 5; |
|
| 19 | - const STEP_INSIGNIFICANT_CHARS = 6; |
|
| 14 | + const STEP_TRANSCODE = 1; |
|
| 15 | + const STEP_MAP = 2; |
|
| 16 | + const STEP_NORMALIZE = 3; |
|
| 17 | + const STEP_PROHIBIT = 4; |
|
| 18 | + const STEP_CHECK_BIDI = 5; |
|
| 19 | + const STEP_INSIGNIFICANT_CHARS = 6; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Preparation steps. |
|
| 23 | - * |
|
| 24 | - * @var PrepareStep[] $_steps |
|
| 25 | - */ |
|
| 26 | - protected $_steps; |
|
| 21 | + /** |
|
| 22 | + * Preparation steps. |
|
| 23 | + * |
|
| 24 | + * @var PrepareStep[] $_steps |
|
| 25 | + */ |
|
| 26 | + protected $_steps; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Constructor. |
|
| 30 | - * |
|
| 31 | - * @param PrepareStep[] $steps Preparation steps to apply |
|
| 32 | - */ |
|
| 33 | - protected function __construct(array $steps) |
|
| 34 | - { |
|
| 35 | - $this->_steps = $steps; |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * Constructor. |
|
| 30 | + * |
|
| 31 | + * @param PrepareStep[] $steps Preparation steps to apply |
|
| 32 | + */ |
|
| 33 | + protected function __construct(array $steps) |
|
| 34 | + { |
|
| 35 | + $this->_steps = $steps; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Get default instance for given string type. |
|
| 40 | - * |
|
| 41 | - * @param int $string_type ASN.1 string type tag. |
|
| 42 | - * @return self |
|
| 43 | - */ |
|
| 44 | - public static function forStringType(int $string_type): self |
|
| 45 | - { |
|
| 46 | - $steps = array( |
|
| 47 | - /* @formatter:off */ |
|
| 48 | - self::STEP_TRANSCODE => new TranscodeStep($string_type), |
|
| 49 | - self::STEP_MAP => new MapStep(), |
|
| 50 | - self::STEP_NORMALIZE => new NormalizeStep(), |
|
| 51 | - self::STEP_PROHIBIT => new ProhibitStep(), |
|
| 52 | - self::STEP_CHECK_BIDI => new CheckBidiStep(), |
|
| 53 | - // @todo Vary by string type |
|
| 54 | - self::STEP_INSIGNIFICANT_CHARS => |
|
| 55 | - new InsignificantNonSubstringSpaceStep() |
|
| 56 | - /* @formatter:on */ |
|
| 57 | - ); |
|
| 58 | - return new self($steps); |
|
| 59 | - } |
|
| 38 | + /** |
|
| 39 | + * Get default instance for given string type. |
|
| 40 | + * |
|
| 41 | + * @param int $string_type ASN.1 string type tag. |
|
| 42 | + * @return self |
|
| 43 | + */ |
|
| 44 | + public static function forStringType(int $string_type): self |
|
| 45 | + { |
|
| 46 | + $steps = array( |
|
| 47 | + /* @formatter:off */ |
|
| 48 | + self::STEP_TRANSCODE => new TranscodeStep($string_type), |
|
| 49 | + self::STEP_MAP => new MapStep(), |
|
| 50 | + self::STEP_NORMALIZE => new NormalizeStep(), |
|
| 51 | + self::STEP_PROHIBIT => new ProhibitStep(), |
|
| 52 | + self::STEP_CHECK_BIDI => new CheckBidiStep(), |
|
| 53 | + // @todo Vary by string type |
|
| 54 | + self::STEP_INSIGNIFICANT_CHARS => |
|
| 55 | + new InsignificantNonSubstringSpaceStep() |
|
| 56 | + /* @formatter:on */ |
|
| 57 | + ); |
|
| 58 | + return new self($steps); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Get self with case folding set. |
|
| 63 | - * |
|
| 64 | - * @param bool $fold True to apply case folding |
|
| 65 | - * @return self |
|
| 66 | - */ |
|
| 67 | - public function withCaseFolding(bool $fold): self |
|
| 68 | - { |
|
| 69 | - $obj = clone $this; |
|
| 70 | - $obj->_steps[self::STEP_MAP] = new MapStep($fold); |
|
| 71 | - return $obj; |
|
| 72 | - } |
|
| 61 | + /** |
|
| 62 | + * Get self with case folding set. |
|
| 63 | + * |
|
| 64 | + * @param bool $fold True to apply case folding |
|
| 65 | + * @return self |
|
| 66 | + */ |
|
| 67 | + public function withCaseFolding(bool $fold): self |
|
| 68 | + { |
|
| 69 | + $obj = clone $this; |
|
| 70 | + $obj->_steps[self::STEP_MAP] = new MapStep($fold); |
|
| 71 | + return $obj; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Prepare string. |
|
| 76 | - * |
|
| 77 | - * @param string $string |
|
| 78 | - * @return string |
|
| 79 | - */ |
|
| 80 | - public function prepare(string $string): string |
|
| 81 | - { |
|
| 82 | - foreach ($this->_steps as $step) { |
|
| 83 | - $string = $step->apply($string); |
|
| 84 | - } |
|
| 85 | - return $string; |
|
| 86 | - } |
|
| 74 | + /** |
|
| 75 | + * Prepare string. |
|
| 76 | + * |
|
| 77 | + * @param string $string |
|
| 78 | + * @return string |
|
| 79 | + */ |
|
| 80 | + public function prepare(string $string): string |
|
| 81 | + { |
|
| 82 | + foreach ($this->_steps as $step) { |
|
| 83 | + $string = $step->apply($string); |
|
| 84 | + } |
|
| 85 | + return $string; |
|
| 86 | + } |
|
| 87 | 87 | } |