__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
<?php

declare(strict_types=1);

namespace SpomkyLabs\Pki\X509\GeneralName;

use ArrayIterator;
use Countable;
use IteratorAggregate;
use LogicException;
use RuntimeException;
use SpomkyLabs\Pki\ASN1\Type\Constructed\Sequence;
use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType;
use SpomkyLabs\Pki\X501\ASN1\Name;
use UnexpectedValueException;
use function count;

/**
 * Implements *GeneralNames* ASN.1 type.
 *
 * Provides convenience methods to retrieve the first value of commonly used CHOICE types.
 *
 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.6
 */
final class GeneralNames implements Countable, IteratorAggregate
{
    /**
     * GeneralName objects.
     *
     * @var GeneralName[]
     */
    private readonly array $_names;

    /**
     * @param GeneralName ...$names One or more GeneralName objects
     */
    private function __construct(GeneralName ...$names)
    {
        $this->_names = $names;
    }

    public static function create(GeneralName ...$names): self
    {
        return new self(...$names);
    }

    /**
     * Initialize from ASN.1.
     */
    public static function fromASN1(Sequence $seq): self
    {
        if (count($seq) === 0) {
            throw new UnexpectedValueException('GeneralNames must have at least one GeneralName.');
        }
        $names = array_map(static fn (UnspecifiedType $el) => GeneralName::fromASN1($el->asTagged()), $seq->elements());
        return self::create(...$names);
    }

    /**
     * Check whether GeneralNames contains a GeneralName of given type.
     *
     * @param int $tag One of `GeneralName::TAG_*` enumerations
     */
    public function has(int $tag): bool
    {
        return $this->findFirst($tag) !== null;
    }

    /**
     * Get first GeneralName of given type.
     *
     * @param int $tag One of `GeneralName::TAG_*` enumerations
     */
    public function firstOf(int $tag): GeneralName
    {
        $name = $this->findFirst($tag);
        if ($name === null) {
            throw new UnexpectedValueException("No GeneralName by tag {$tag}.");
        }
        return $name;
    }

    /**
     * Get all GeneralName objects of given type.
     *
     * @param int $tag One of `GeneralName::TAG_*` enumerations
     *
     * @return GeneralName[]
     */
    public function allOf(int $tag): array
    {
        $names = array_filter($this->_names, fn (GeneralName $name) => $name->tag() === $tag);
        return array_values($names);
    }

    /**
     * Get value of the first 'dNSName' type.
     */
    public function firstDNS(): string
    {
        $gn = $this->firstOf(GeneralName::TAG_DNS_NAME);
        if (! $gn instanceof DNSName) {
            throw new RuntimeException(DNSName::class . ' expected, got ' . $gn::class);
        }
        return $gn->name();
    }

    /**
     * Get value of the first 'directoryName' type.
     */
    public function firstDN(): Name
    {
        $gn = $this->firstOf(GeneralName::TAG_DIRECTORY_NAME);
        if (! $gn instanceof DirectoryName) {
            throw new RuntimeException(DirectoryName::class . ' expected, got ' . $gn::class);
        }
        return $gn->dn();
    }

    /**
     * Get value of the first 'uniformResourceIdentifier' type.
     */
    public function firstURI(): string
    {
        $gn = $this->firstOf(GeneralName::TAG_URI);
        if (! $gn instanceof UniformResourceIdentifier) {
            throw new RuntimeException(UniformResourceIdentifier::class . ' expected, got ' . $gn::class);
        }
        return $gn->uri();
    }

    /**
     * Generate ASN.1 structure.
     */
    public function toASN1(): Sequence
    {
        if (count($this->_names) === 0) {
            throw new LogicException('GeneralNames must have at least one GeneralName.');
        }
        $elements = array_map(static fn (GeneralName $name) => $name->toASN1(), $this->_names);
        return Sequence::create(...$elements);
    }

    /**
     * @see \Countable::count()
     */
    public function count(): int
    {
        return count($this->_names);
    }

    /**
     * Get iterator for GeneralName objects.
     *
     * @see \IteratorAggregate::getIterator()
     */
    public function getIterator(): ArrayIterator
    {
        return new ArrayIterator($this->_names);
    }

    /**
     * Find first GeneralName by given tag.
     */
    private function findFirst(int $tag): ?GeneralName
    {
        foreach ($this->_names as $name) {
            if ($name->tag() === $tag) {
                return $name;
            }
        }
        return null;
    }
}

Filemanager

Name Type Size Permission Actions
DNSName.php File 1.23 KB 0664
DirectoryName.php File 1.53 KB 0664
EDIPartyName.php File 1.17 KB 0664
GeneralName.php File 3.27 KB 0664
GeneralNames.php File 4.47 KB 0664
IPAddress.php File 2.1 KB 0664
IPv4Address.php File 1.26 KB 0664
IPv6Address.php File 1.61 KB 0664
OtherName.php File 1.9 KB 0664
RFC822Name.php File 1.15 KB 0664
RegisteredID.php File 1.32 KB 0664
UniformResourceIdentifier.php File 1.16 KB 0664
X400Address.php File 1.13 KB 0664
Filemanager