| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace SpomkyLabs\Pki\X509\AttributeCertificate\Attribute; |
| 6 |
|
| 7 |
use SpomkyLabs\Pki\ASN1\Element; |
| 8 |
use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType; |
| 9 |
use SpomkyLabs\Pki\X509\GeneralName\GeneralName; |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
final class AuthenticationInfoAttributeValue extends SvceAuthInfo |
| 17 |
{ |
| 18 |
final public const OID = '1.3.6.1.5.5.7.10.1'; |
| 19 |
|
| 20 |
private function __construct(GeneralName $service, GeneralName $ident, ?string $auth_info) |
| 21 |
{ |
| 22 |
parent::__construct(self::OID, $service, $ident, $auth_info); |
| 23 |
} |
| 24 |
|
| 25 |
public static function create(GeneralName $service, GeneralName $ident, ?string $auth_info = null): self |
| 26 |
{ |
| 27 |
return new self($service, $ident, $auth_info); |
| 28 |
} |
| 29 |
|
| 30 |
public static function fromASN1(UnspecifiedType $el): static |
| 31 |
{ |
| 32 |
$seq = $el->asSequence(); |
| 33 |
$service = GeneralName::fromASN1($seq->at(0)->asTagged()); |
| 34 |
$ident = GeneralName::fromASN1($seq->at(1)->asTagged()); |
| 35 |
$auth_info = null; |
| 36 |
if ($seq->has(2, Element::TYPE_OCTET_STRING)) { |
| 37 |
$auth_info = $seq->at(2) |
| 38 |
->asString() |
| 39 |
->string(); |
| 40 |
} |
| 41 |
return static::create($service, $ident, $auth_info); |
| 42 |
} |
| 43 |
} |