| 1 | <?php |
||
| 17 | */ |
||
| 18 | abstract class PolicyQualifierInfo |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * OID for the CPS Pointer qualifier. |
||
| 22 | * |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | const OID_CPS = '1.3.6.1.5.5.7.2.1'; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * OID for the user notice qualifier. |
||
| 29 | * |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | const OID_UNOTICE = '1.3.6.1.5.5.7.2.2'; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Qualifier identifier. |
||
| 36 | * |
||
| 37 | * @var string |
||
| 38 | */ |
||
| 39 | protected $_oid; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Initialize from qualifier ASN.1 element. |
||
| 43 | * |
||
| 44 | * @param UnspecifiedType $el |
||
| 45 | * |
||
| 46 | * @return self |
||
| 47 | */ |
||
| 48 | 1 | public static function fromQualifierASN1(UnspecifiedType $el): PolicyQualifierInfo |
|
|
1 ignored issue
–
show
|
|||
| 49 | { |
||
| 50 | 1 | throw new \BadMethodCallException( |
|
| 51 | 1 | __FUNCTION__ . ' must be implemented in the derived class.'); |
|
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Initialize from ASN.1. |
||
| 56 | * |
||
| 57 | * @param Sequence $seq |
||
| 58 | * |
||
| 59 | * @throws \UnexpectedValueException |
||
| 60 | * |
||
| 61 | * @return self |
||
| 62 | */ |
||
| 63 | 14 | public static function fromASN1(Sequence $seq): self |
|
| 64 | { |
||
| 65 | 14 | $oid = $seq->at(0)->asObjectIdentifier()->oid(); |
|
| 66 | switch ($oid) { |
||
| 67 | 14 | case self::OID_CPS: |
|
| 68 | 12 | return CPSQualifier::fromQualifierASN1($seq->at(1)); |
|
| 69 | 12 | case self::OID_UNOTICE: |
|
| 70 | 11 | return UserNoticeQualifier::fromQualifierASN1($seq->at(1)); |
|
| 71 | } |
||
| 72 | 1 | throw new \UnexpectedValueException("Qualifier {$oid} not supported."); |
|
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Get qualifier identifier. |
||
| 77 | * |
||
| 78 | * @return string |
||
| 79 | */ |
||
| 80 | 17 | public function oid(): string |
|
| 81 | { |
||
| 82 | 17 | return $this->_oid; |
|
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Generate ASN.1 structure. |
||
| 87 | * |
||
| 88 | * @return Sequence |
||
| 89 | */ |
||
| 90 | 20 | public function toASN1(): Sequence |
|
| 94 | } |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Generate ASN.1 for the 'qualifier' field. |
||
| 98 | * |
||
| 99 | * @return Element |
||
| 100 | */ |
||
| 101 | abstract protected function _qualifierASN1(): Element; |
||
| 103 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.