CoreFiles by mySites.guru
DirectoryName.php65 lines, 1,565 bytes, from Joomla_5.2.3-Stable-Full_Package.zip
Raw History Compare with 5.2.2
md5
62c4aaf282dd7feafbe6321cdf9025d1
sha1
e6f116d776ae706e5a4cb0578cd9d259436c2ed0
sha256
5599cf58c99f9af609c115309cc6f5febfebfdc0400b46684682c704341ac42d
<?php

declare(strict_types=1);

namespace SpomkyLabs\Pki\X509\GeneralName;

use SpomkyLabs\Pki\ASN1\Type\Tagged\ExplicitlyTaggedType;
use SpomkyLabs\Pki\ASN1\Type\TaggedType;
use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType;
use SpomkyLabs\Pki\X501\ASN1\Name;

/**
 * Implements *directoryName* CHOICE type of *GeneralName*.
 *
 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.6
 */
final class DirectoryName extends GeneralName
{
    private function __construct(
        private readonly Name $directoryName
    ) {
        parent::__construct(self::TAG_DIRECTORY_NAME);
    }

    public static function create(Name $directoryName): self
    {
        return new self($directoryName);
    }

    /**
     * @return self
     */
    public static function fromChosenASN1(UnspecifiedType $el): GeneralName
    {
        return self::create(Name::fromASN1($el->asSequence()));
    }

    /**
     * Initialize from distinguished name string.
     */
    public static function fromDNString(string $str): self
    {
        return self::create(Name::fromString($str));
    }

    public function string(): string
    {
        return $this->directoryName->toString();
    }

    /**
     * Get directory name.
     */
    public function dn(): Name
    {
        return $this->directoryName;
    }

    protected function choiceASN1(): TaggedType
    {
        // Name type is itself a CHOICE, so explicit tagging must be
        // employed to avoid ambiguities
        return ExplicitlyTaggedType::create($this->tag, $this->directoryName->toASN1());
    }
}

The same content is in 158 releases, Joomla 5.0.0-alpha1 to 6.3.0-alpha1. See them all, or every version of this file.