- md5
- 90098cde612c052c48806fedfb80915f
- sha1
- 8934a1f5e2a1e66de029662b746f22510253b85d
- sha256
- dfbcaf88494b916c6ae1aaf9fc680f739427753ad54b5d9e48e4733b0877e7ae
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
<?php
declare(strict_types=1);
namespace SpomkyLabs\Pki\X509\CertificationPath\PathValidation;
use function count;
use SpomkyLabs\Pki\ASN1\Element;
use SpomkyLabs\Pki\CryptoTypes\AlgorithmIdentifier\Feature\AlgorithmIdentifierType;
use SpomkyLabs\Pki\CryptoTypes\Asymmetric\PublicKeyInfo;
use SpomkyLabs\Pki\X509\Certificate\Certificate;
use SpomkyLabs\Pki\X509\Certificate\Extension\CertificatePolicy\PolicyInformation;
use SpomkyLabs\Pki\X509\CertificationPath\Policy\PolicyTree;
/**
* Result of the path validation process.
*
* @see https://tools.ietf.org/html/rfc5280#section-6.1.6
*/
final class PathValidationResult
{
/**
* Certificates in a certification path.
*
* @var Certificate[]
*/
private readonly array $certificates;
/**
* @param Certificate[] $certificates
*/
private function __construct(
array $certificates,
private readonly ?PolicyTree $policyTree,
private readonly PublicKeyInfo $publicKeyInfo,
private readonly AlgorithmIdentifierType $publicKeyAlgo,
private readonly ?Element $publicKeyParameters
) {
$this->certificates = array_values($certificates);
}
/**
* @param Certificate[] $certificates Certificates in a certification path
* @param null|PolicyTree $policyTree Valid policy tree
* @param PublicKeyInfo $publicKeyInfo Public key of the end-entity certificate
* @param AlgorithmIdentifierType $publicKeyAlgo Public key algorithm of the end-entity certificate
* @param null|Element $publicKeyParameters Algorithm parameters
*/
public static function create(
array $certificates,
?PolicyTree $policyTree,
PublicKeyInfo $publicKeyInfo,
AlgorithmIdentifierType $publicKeyAlgo,
?Element $publicKeyParameters = null
): self {
return new self($certificates, $policyTree, $publicKeyInfo, $publicKeyAlgo, $publicKeyParameters);
}
public function getPolicyTree(): ?PolicyTree
{
return $this->policyTree;
}
public function getPublicKeyInfo(): PublicKeyInfo
{
return $this->publicKeyInfo;
}
public function getPublicKeyAlgo(): AlgorithmIdentifierType
{
return $this->publicKeyAlgo;
}
public function getPublicKeyParameters(): ?Element
{
return $this->publicKeyParameters;
}
/**
* Get end-entity certificate.
*/
public function certificate(): Certificate
{
return $this->certificates[count($this->certificates) - 1];
}
/**
* Get certificate policies of the end-entity certificate.
*
* @return PolicyInformation[]
*/
public function policies(): array
{
if ($this->policyTree === null) {
return [];
}
return $this->policyTree->policiesAtDepth(count($this->certificates));
}
}
The same content is in 33 releases, Joomla 5.0.0-alpha1 to 6.3.0-alpha1. See them all, or every version of this file.