예제 #1
0
파일: Name.php 프로젝트: sop/x501
 /**
  * Initialize from distinguished name string.
  *
  * @link https://tools.ietf.org/html/rfc1779
  * @param string $str
  * @return self
  */
 public static function fromString($str)
 {
     $rdns = array();
     foreach (DNParser::parseString($str) as $nameComponent) {
         $attribs = array();
         foreach ($nameComponent as list($name, $val)) {
             $type = AttributeType::fromName($name);
             // hexstrings are parsed to ASN.1 elements
             if ($val instanceof Element) {
                 $el = $val;
             } else {
                 $el = AttributeType::asn1StringForType($type->oid(), $val);
             }
             $value = AttributeValue::fromASN1ByOID($type->oid(), $el->asUnspecified());
             $attribs[] = new AttributeTypeAndValue($type, $value);
         }
         $rdns[] = new RDN(...$attribs);
     }
     return new self(...$rdns);
 }
예제 #2
0
 /**
  *
  * @see AttributeValue::rfc2253String
  * @return string
  */
 public function rfc2253String()
 {
     return DNParser::escapeString($this->_transcodedString());
 }
예제 #3
0
 /**
  *
  * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String()
  * @return string
  */
 public function rfc2253String()
 {
     // TeletexString is encoded as binary
     if ($this->_stringTag == self::TELETEX) {
         return $this->_transcodedString();
     }
     return DNParser::escapeString($this->_transcodedString());
 }