1 package org.bouncycastle.asn1.x509; 2 3 import org.bouncycastle.asn1.*; 4 5 /** 6 * <pre> 7 * GeneralName ::= CHOICE { 8 * otherName [0] OtherName, 9 * rfc822Name [1] IA5String, 10 * dNSName [2] IA5String, 11 * x400Address [3] ORAddress, 12 * directoryName [4] Name, 13 * ediPartyName [5] EDIPartyName, 14 * uniformResourceIdentifier [6] IA5String, 15 * iPAddress [7] OCTET STRING, 16 * registeredID [8] OBJECT IDENTIFIER} 17 * 18 * OtherName ::= SEQUENCE { 19 * type-id OBJECT IDENTIFIER, 20 * value [0] EXPLICIT ANY DEFINED BY type-id } 21 * 22 * EDIPartyName ::= SEQUENCE { 23 * nameAssigner [0] DirectoryString OPTIONAL, 24 * partyName [1] DirectoryString } 25 * </pre> 26 */ 27 public class GeneralName 28 implements DEREncodable 29 { 30 DEREncodable obj; 31 int tag; 32 boolean isInsideImplicit = false; // if we are in an implicitly tagged object 33 34 public GeneralName( 35 X509Name directoryName) 36 { 37 this.obj = directoryName; 38 this.tag = 4; 39 } 40 41 /** 42 * When the subjectAltName extension contains an Internet mail address, 43 * the address MUST be included as an rfc822Name. The format of an 44 * rfc822Name is an "addr-spec" as defined in RFC 822 [RFC 822]. 45 * 46 * When the subjectAltName extension contains a domain name service 47 * label, the domain name MUST be stored in the dNSName (an IA5String). 48 * The name MUST be in the "preferred name syntax," as specified by RFC 49 * 1034 [RFC 1034]. 50 * 51 * When the subjectAltName extension contains a URI, the name MUST be 52 * stored in the uniformResourceIdentifier (an IA5String). The name MUST 53 * be a non-relative URL, and MUST follow the URL syntax and encoding 54 * rules specified in [RFC 1738]. The name must include both a scheme 55 * (e.g., "http" or "ftp") and a scheme-specific-part. The scheme- 56 * specific-part must include a fully qualified domain name or IP 57 * address as the host. 58 * 59 * When the subjectAltName extension contains a iPAddress, the address 60 * MUST be stored in the octet string in "network byte order," as 61 * specified in RFC 791 [RFC 791]. The least significant bit (LSB) of 62 * each octet is the LSB of the corresponding byte in the network 63 * address. For IP Version 4, as specified in RFC 791, the octet string 64 * MUST contain exactly four octets. For IP Version 6, as specified in 65 * RFC 1883, the octet string MUST contain exactly sixteen octets [RFC 66 * 1883]. 67 */ 68 public GeneralName( 69 DERObject name, int tag) 70 { 71 this.obj = name; 72 this.tag = tag; 73 } 74 75 /** 76 * mark whether or not we are contained inside an implicitly tagged 77 * object. 78 * @deprecated 79 */ 80 public void markInsideImplicit( 81 boolean isInsideImplicit) 82 { 83 this.isInsideImplicit = isInsideImplicit; 84 } 85 86 public DERObject getDERObject() 87 { 88 if (obj.getDERObject() instanceof ASN1Sequence) 89 { 90 return new DERTaggedObject(true, tag, obj); 91 } 92 else 93 { 94 return new DERTaggedObject(false, tag, obj); 95 } 96 } 97 } 98