* GeneralName ::= CHOICE { * otherName [0] OtherName, * rfc822Name [1] IA5String, * dNSName [2] IA5String, * x400Address [3] ORAddress, * directoryName [4] Name, * ediPartyName [5] EDIPartyName, * uniformResourceIdentifier [6] IA5String, * iPAddress [7] OCTET STRING, * registeredID [8] OBJECT IDENTIFIER} * * *
 * OtherName ::= SEQUENCE {
 *  type-id    OBJECT IDENTIFIER,
 *  value      [0] EXPLICIT ANY DEFINED BY type-id }
 * 
* *
 * EDIPartyName ::= SEQUENCE {
 *  nameAssigner            [0]     DirectoryString OPTIONAL,
 *  partyName               [1]     DirectoryString
 * }
 * 
* *
 * Name ::= CHOICE { RDNSequence }
 * 
* * @package asn1 * @subpackage x509 */ class X509GeneralName { private $object; /** * Construct a new instance of X509GeneralName. */ public function __construct() { } /** * Decodes the given ASN1Tag as X509GeneralName. * * @throws GTException * @param ASN1Tag $object X509GeneralName encoded as ASN1Tag * @return void */ public function decode($object) { if (!$object instanceof ASN1Tag) { throw new GTException("Expecting an ASN1Tag"); } if ($object->getTagValue() < 0 || $object->getTagValue() > 8) { throw new GTException("Unknown TAG value: {$object->getTagValue()}"); } $this->object = $object; } /** * Gets the formatted name. * * @throws GTException * @return string formatted name used for timestamps. */ public function getFormatted() { if ($this->object == null) { return null; } switch ($this->object->getTagValue()) { case 0: throw new GTException("[0] not implemented"); case 1: return "RFC:" . $this->object->getObjectAs(ASN1_TAG_IA5_STRING)->getValue(); case 2: return "DNS:" . $this->object->getObjectAs(ASN1_TAG_IA5_STRING)->getValue(); case 3: throw new GTException("[3] not implemented"); case 4: throw new GTException("[4] not implemented"); case 5: throw new GTException("[5] not implemented"); case 6: return "URI:" . $this->object->getObjectAs(ASN1_TAG_IA5_STRING)->getValue(); case 7: throw new GTException("[7] not implemented"); case 8: return "RID: " . $this->object->getObjectAs(ASN1_TAG_OBJECT_ID)->getValue(); default: throw new GTException("Unknown TAG value {$this->object->getTagValue()}"); } } } ?>