예제 #1
0
 /**
  * Initialize from TaggedType.
  *
  * @param TaggedType $el
  * @throws \UnexpectedValueException
  * @return self
  */
 public static function fromTaggedType(TaggedType $el)
 {
     switch ($el->tag()) {
         case self::TAG_FULL_NAME:
             return new FullName(GeneralNames::fromASN1($el->asImplicit(Element::TYPE_SEQUENCE)->asSequence()));
         case self::TAG_RDN:
             return new RelativeName(RDN::fromASN1($el->asImplicit(Element::TYPE_SET)->asSet()));
         default:
             throw new \UnexpectedValueException("DistributionPointName tag " . $el->tag() . " not supported.");
     }
 }
예제 #2
0
파일: Target.php 프로젝트: sop/x509
 /**
  * Parse from ASN.1.
  *
  * @param TaggedType $el
  * @throws \UnexpectedValueException
  * @return self
  */
 public static function fromASN1(TaggedType $el)
 {
     switch ($el->tag()) {
         case self::TYPE_NAME:
             return TargetName::fromChosenASN1($el->asExplicit()->asTagged());
         case self::TYPE_GROUP:
             return TargetGroup::fromChosenASN1($el->asExplicit()->asTagged());
         case self::TYPE_CERT:
             throw new \RuntimeException("targetCert not supported.");
     }
     throw new \UnexpectedValueException("Target type " . $el->tag() . " not supported.");
 }
예제 #3
0
파일: GeneralName.php 프로젝트: sop/x509
 /**
  * Initialize from ASN.1.
  *
  * @param TaggedType $el
  * @throws \UnexpectedValueException
  * @return self
  */
 public static function fromASN1(TaggedType $el)
 {
     switch ($el->tag()) {
         // otherName
         case self::TAG_OTHER_NAME:
             return OtherName::fromChosenASN1($el->asImplicit(Element::TYPE_SEQUENCE));
             // rfc822Name
         // rfc822Name
         case self::TAG_RFC822_NAME:
             return RFC822Name::fromChosenASN1($el->asImplicit(Element::TYPE_IA5_STRING));
             // dNSName
         // dNSName
         case self::TAG_DNS_NAME:
             return DNSName::fromChosenASN1($el->asImplicit(Element::TYPE_IA5_STRING));
             // x400Address
         // x400Address
         case self::TAG_X400_ADDRESS:
             return X400Address::fromChosenASN1($el->asImplicit(Element::TYPE_SEQUENCE));
             // directoryName
         // directoryName
         case self::TAG_DIRECTORY_NAME:
             // because Name is a CHOICE, albeit having only one option,
             // explicit tagging must be used
             // (see X.680 07/2002 30.6.c)
             return DirectoryName::fromChosenASN1($el->asExplicit());
             // ediPartyName
         // ediPartyName
         case self::TAG_EDI_PARTY_NAME:
             return EDIPartyName::fromChosenASN1($el->asImplicit(Element::TYPE_SEQUENCE));
             // uniformResourceIdentifier
         // uniformResourceIdentifier
         case self::TAG_URI:
             return UniformResourceIdentifier::fromChosenASN1($el->asImplicit(Element::TYPE_IA5_STRING));
             // iPAddress
         // iPAddress
         case self::TAG_IP_ADDRESS:
             return IPAddress::fromChosenASN1($el->asImplicit(Element::TYPE_OCTET_STRING));
             // registeredID
         // registeredID
         case self::TAG_REGISTERED_ID:
             return RegisteredID::fromChosenASN1($el->asImplicit(Element::TYPE_OBJECT_IDENTIFIER));
     }
     throw new \UnexpectedValueException("GeneralName type " . $el->tag() . " not supported.");
 }