Debian Codegraph @

lib/3rdParty/composer/spomky-labs/pki-framework/src/X509/AttributeCertificate/Attribute/AccessIdentityAttributeValue.php

raw symbols SCIP
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 * Implements value for 'Access Identity' attribute.
13 *
14 * @see https://tools.ietf.org/html/rfc5755#section-4.4.2
15 */
16 final class AccessIdentityAttributeValue extends SvceAuthInfo
17 {
18 final public const OID = '1.3.6.1.5.5.7.10.2';
19
20 private function __construct(GeneralName $service, GeneralName $ident, ?string $authInfo)
21 {
22 parent::__construct(self::OID, $service, $ident, $authInfo);
23 }
24
25 public static function create(GeneralName $service, GeneralName $ident, ?string $_authInfo = null): self
26 {
27 return new self($service, $ident, $_authInfo);
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 }