| @@ 15-54 (lines=40) @@ | ||
| 12 | * |
|
| 13 | * @link https://tools.ietf.org/html/rfc5755#section-4.3.2 |
|
| 14 | */ |
|
| 15 | class TargetGroup extends Target |
|
| 16 | { |
|
| 17 | /** |
|
| 18 | * Group name. |
|
| 19 | * |
|
| 20 | * @var GeneralName $_name |
|
| 21 | */ |
|
| 22 | protected $_name; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Constructor |
|
| 26 | * |
|
| 27 | * @param GeneralName $name |
|
| 28 | */ |
|
| 29 | public function __construct(GeneralName $name) { |
|
| 30 | $this->_name = $name; |
|
| 31 | $this->_type = self::TYPE_GROUP; |
|
| 32 | } |
|
| 33 | ||
| 34 | public static function fromChosenASN1(TaggedType $el) { |
|
| 35 | return new self(GeneralName::fromASN1($el)); |
|
| 36 | } |
|
| 37 | ||
| 38 | public function string() { |
|
| 39 | return $this->_name->string(); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * Get group name. |
|
| 44 | * |
|
| 45 | * @return GeneralName |
|
| 46 | */ |
|
| 47 | public function name() { |
|
| 48 | return $this->_name; |
|
| 49 | } |
|
| 50 | ||
| 51 | public function toASN1() { |
|
| 52 | return new ExplicitlyTaggedType($this->_type, $this->_name->toASN1()); |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| @@ 15-54 (lines=40) @@ | ||
| 12 | * |
|
| 13 | * @link https://tools.ietf.org/html/rfc5755#section-4.3.2 |
|
| 14 | */ |
|
| 15 | class TargetName extends Target |
|
| 16 | { |
|
| 17 | /** |
|
| 18 | * Name. |
|
| 19 | * |
|
| 20 | * @var GeneralName $_name |
|
| 21 | */ |
|
| 22 | protected $_name; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Constructor |
|
| 26 | * |
|
| 27 | * @param GeneralName $name |
|
| 28 | */ |
|
| 29 | public function __construct(GeneralName $name) { |
|
| 30 | $this->_name = $name; |
|
| 31 | $this->_type = self::TYPE_NAME; |
|
| 32 | } |
|
| 33 | ||
| 34 | public static function fromChosenASN1(TaggedType $el) { |
|
| 35 | return new self(GeneralName::fromASN1($el)); |
|
| 36 | } |
|
| 37 | ||
| 38 | public function string() { |
|
| 39 | return $this->_name->string(); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * Get name. |
|
| 44 | * |
|
| 45 | * @return GeneralName |
|
| 46 | */ |
|
| 47 | public function name() { |
|
| 48 | return $this->_name; |
|
| 49 | } |
|
| 50 | ||
| 51 | public function toASN1() { |
|
| 52 | return new ExplicitlyTaggedType($this->_type, $this->_name->toASN1()); |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| @@ 15-72 (lines=58) @@ | ||
| 12 | * |
|
| 13 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.6 |
|
| 14 | */ |
|
| 15 | class DirectoryName extends GeneralName |
|
| 16 | { |
|
| 17 | /** |
|
| 18 | * Directory name. |
|
| 19 | * |
|
| 20 | * @var Name $_dn |
|
| 21 | */ |
|
| 22 | protected $_dn; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Constructor |
|
| 26 | * |
|
| 27 | * @param Name $dn |
|
| 28 | */ |
|
| 29 | public function __construct(Name $dn) { |
|
| 30 | $this->_tag = self::TAG_DIRECTORY_NAME; |
|
| 31 | $this->_dn = $dn; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Initialize from ASN.1. |
|
| 36 | * |
|
| 37 | * @param Sequence $seq |
|
| 38 | * @return self |
|
| 39 | */ |
|
| 40 | protected static function _fromASN1(Sequence $seq) { |
|
| 41 | return new self(Name::fromASN1($seq)); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * Initialize from distinguished name string. |
|
| 46 | * |
|
| 47 | * @param string $str |
|
| 48 | * @return self |
|
| 49 | */ |
|
| 50 | public static function fromDNString($str) { |
|
| 51 | return new self(Name::fromString($str)); |
|
| 52 | } |
|
| 53 | ||
| 54 | public function string() { |
|
| 55 | return $this->_dn->toString(); |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Get directory name. |
|
| 60 | * |
|
| 61 | * @return Name |
|
| 62 | */ |
|
| 63 | public function dn() { |
|
| 64 | return $this->_dn; |
|
| 65 | } |
|
| 66 | ||
| 67 | protected function _choiceASN1() { |
|
| 68 | // Name type is itself a CHOICE, so explicit tagging must be |
|
| 69 | // employed to avoid ambiguities |
|
| 70 | return new ExplicitlyTaggedType($this->_tag, $this->_dn->toASN1()); |
|
| 71 | } |
|
| 72 | } |
|
| 73 | ||