[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/fgrosse/phpasn1/lib/X509/ -> CertificateSubject.php (source)

   1  <?php
   2  /*
   3   * This file is part of the PHPASN1 library.
   4   *
   5   * Copyright © Friedrich Große <[email protected]>
   6   *
   7   * For the full copyright and license information, please view the LICENSE
   8   * file that was distributed with this source code.
   9   */
  10  
  11  namespace FG\X509;
  12  
  13  use FG\ASN1\Composite\RelativeDistinguishedName;
  14  use FG\ASN1\Identifier;
  15  use FG\ASN1\OID;
  16  use FG\ASN1\Parsable;
  17  use FG\ASN1\Composite\RDNString;
  18  use FG\ASN1\Universal\Sequence;
  19  
  20  class CertificateSubject extends Sequence implements Parsable
  21  {
  22      private $commonName;
  23      private $email;
  24      private $organization;
  25      private $locality;
  26      private $state;
  27      private $country;
  28      private $organizationalUnit;
  29  
  30      /**
  31       * @param string $commonName
  32       * @param string $email
  33       * @param string $organization
  34       * @param string $locality
  35       * @param string $state
  36       * @param string $country
  37       * @param string $organizationalUnit
  38       */
  39      public function __construct($commonName, $email, $organization, $locality, $state, $country, $organizationalUnit)
  40      {
  41          parent::__construct(
  42              new RDNString(OID::COUNTRY_NAME, $country),
  43              new RDNString(OID::STATE_OR_PROVINCE_NAME, $state),
  44              new RDNString(OID::LOCALITY_NAME, $locality),
  45              new RDNString(OID::ORGANIZATION_NAME, $organization),
  46              new RDNString(OID::OU_NAME, $organizationalUnit),
  47              new RDNString(OID::COMMON_NAME, $commonName),
  48              new RDNString(OID::PKCS9_EMAIL, $email)
  49          );
  50  
  51          $this->commonName = $commonName;
  52          $this->email = $email;
  53          $this->organization = $organization;
  54          $this->locality = $locality;
  55          $this->state = $state;
  56          $this->country = $country;
  57          $this->organizationalUnit = $organizationalUnit;
  58      }
  59  
  60      public function getCommonName()
  61      {
  62          return $this->commonName;
  63      }
  64  
  65      public function getEmail()
  66      {
  67          return $this->email;
  68      }
  69  
  70      public function getOrganization()
  71      {
  72          return $this->organization;
  73      }
  74  
  75      public function getLocality()
  76      {
  77          return $this->locality;
  78      }
  79  
  80      public function getState()
  81      {
  82          return $this->state;
  83      }
  84  
  85      public function getCountry()
  86      {
  87          return $this->country;
  88      }
  89  
  90      public function getOrganizationalUnit()
  91      {
  92          return $this->organizationalUnit;
  93      }
  94  
  95      public static function fromBinary(&$binaryData, &$offsetIndex = 0)
  96      {
  97          self::parseIdentifier($binaryData[$offsetIndex], Identifier::SEQUENCE, $offsetIndex++);
  98          $contentLength = self::parseContentLength($binaryData, $offsetIndex);
  99  
 100          $names = [];
 101          $octetsToRead = $contentLength;
 102          while ($octetsToRead > 0) {
 103              $relativeDistinguishedName = RelativeDistinguishedName::fromBinary($binaryData, $offsetIndex);
 104              $octetsToRead -= $relativeDistinguishedName->getObjectLength();
 105              $names[] = $relativeDistinguishedName;
 106          }
 107      }
 108  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer