- md5
- 92707942b89acc4fcc997d07a89e663e
- sha1
- 9d4ecac99ed0a325a2723de48ea60fa516343b21
- sha256
- 89a956d02ad37b4dbead1553c8ba312a53beb62f5fe36ef50bf6c5ca9d83e22e
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
<?php
declare(strict_types=1);
namespace SpomkyLabs\Pki\X509\AttributeCertificate;
use SpomkyLabs\Pki\ASN1\Element;
use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType;
use SpomkyLabs\Pki\X501\ASN1\Name;
use SpomkyLabs\Pki\X509\Certificate\Certificate;
use SpomkyLabs\Pki\X509\GeneralName\DirectoryName;
use SpomkyLabs\Pki\X509\GeneralName\GeneralNames;
use UnexpectedValueException;
/**
* Base class implementing *AttCertIssuer* ASN.1 CHOICE type.
*
* @see https://tools.ietf.org/html/rfc5755#section-4.1
*/
abstract class AttCertIssuer
{
/**
* Generate ASN.1 element.
*/
abstract public function toASN1(): Element;
/**
* Check whether AttCertIssuer identifies given certificate.
*/
abstract public function identifiesPKC(Certificate $cert): bool;
/**
* Initialize from distinguished name.
*
* This conforms to RFC 5755 which states that only v2Form must be used, and issuerName must contain exactly one
* GeneralName of DirectoryName type.
*
* @see https://tools.ietf.org/html/rfc5755#section-4.2.3
*/
public static function fromName(Name $name): self
{
return V2Form::create(GeneralNames::create(DirectoryName::create($name)));
}
/**
* Initialize from an issuer's public key certificate.
*/
public static function fromPKC(Certificate $cert): self
{
return self::fromName($cert->tbsCertificate()->subject());
}
/**
* Initialize from ASN.1.
*
* @param UnspecifiedType $el CHOICE
*/
public static function fromASN1(UnspecifiedType $el): self
{
if (! $el->isTagged()) {
throw new UnexpectedValueException('v1Form issuer not supported.');
}
$tagged = $el->asTagged();
return match ($tagged->tag()) {
0 => V2Form::fromV2ASN1($tagged->asImplicit(Element::TYPE_SEQUENCE)->asSequence()),
default => throw new UnexpectedValueException('Unsupported issuer type.'),
};
}
}
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.