Debian Codegraph @

lib/3rdParty/composer/spomky-labs/pki-framework/src/X509/Certificate/Extension/AccessDescription/AccessDescription.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace SpomkyLabs\Pki\X509\Certificate\Extension\AccessDescription;
6
7 use SpomkyLabs\Pki\ASN1\Type\Constructed\Sequence;
8 use SpomkyLabs\Pki\ASN1\Type\Primitive\ObjectIdentifier;
9 use SpomkyLabs\Pki\X509\GeneralName\GeneralName;
10
11 /**
12 * Base class implementing *AccessDescription* ASN.1 type for 'Authority Information Access' and 'Subject Information
13 * Access' certificate extensions.
14 *
15 * @see https://tools.ietf.org/html/rfc5280#section-4.2.2.1
16 */
17 abstract class AccessDescription
18 {
19 /**
20 * @param string $accessMethod Access method OID
21 * @param GeneralName $accessLocation Access location
22 */
23 protected function __construct(
24 protected readonly string $accessMethod,
25 protected readonly GeneralName $accessLocation
26 ) {
27 }
28
29 /**
30 * Initialize from ASN.1.
31 */
32 abstract public static function fromASN1(Sequence $seq): static;
33
34 /**
35 * Get the access method OID.
36 */
37 public function accessMethod(): string
38 {
39 return $this->accessMethod;
40 }
41
42 /**
43 * Get the access location.
44 */
45 public function accessLocation(): GeneralName
46 {
47 return $this->accessLocation;
48 }
49
50 /**
51 * Generate ASN.1 structure.
52 */
53 public function toASN1(): Sequence
54 {
55 return Sequence::create(ObjectIdentifier::create($this->accessMethod), $this->accessLocation->toASN1());
56 }
57 }